babylon.module.d.ts 5.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590
  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 = nearest */
  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 constraint 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. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15252. /**
  15253. * Interface used to define additional presentation attributes
  15254. */
  15255. export interface IVRPresentationAttributes {
  15256. /**
  15257. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15258. */
  15259. highRefreshRate: boolean;
  15260. /**
  15261. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15262. */
  15263. foveationLevel: number;
  15264. }
  15265. module "babylonjs/Engines/engine" {
  15266. interface Engine {
  15267. /** @hidden */
  15268. _vrDisplay: any;
  15269. /** @hidden */
  15270. _vrSupported: boolean;
  15271. /** @hidden */
  15272. _oldSize: Size;
  15273. /** @hidden */
  15274. _oldHardwareScaleFactor: number;
  15275. /** @hidden */
  15276. _vrExclusivePointerMode: boolean;
  15277. /** @hidden */
  15278. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15279. /** @hidden */
  15280. _onVRDisplayPointerRestricted: () => void;
  15281. /** @hidden */
  15282. _onVRDisplayPointerUnrestricted: () => void;
  15283. /** @hidden */
  15284. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15285. /** @hidden */
  15286. _onVrDisplayDisconnect: Nullable<() => void>;
  15287. /** @hidden */
  15288. _onVrDisplayPresentChange: Nullable<() => void>;
  15289. /**
  15290. * Observable signaled when VR display mode changes
  15291. */
  15292. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15293. /**
  15294. * Observable signaled when VR request present is complete
  15295. */
  15296. onVRRequestPresentComplete: Observable<boolean>;
  15297. /**
  15298. * Observable signaled when VR request present starts
  15299. */
  15300. onVRRequestPresentStart: Observable<Engine>;
  15301. /**
  15302. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15303. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15304. */
  15305. isInVRExclusivePointerMode: boolean;
  15306. /**
  15307. * Gets a boolean indicating if a webVR device was detected
  15308. * @returns true if a webVR device was detected
  15309. */
  15310. isVRDevicePresent(): boolean;
  15311. /**
  15312. * Gets the current webVR device
  15313. * @returns the current webVR device (or null)
  15314. */
  15315. getVRDevice(): any;
  15316. /**
  15317. * Initializes a webVR display and starts listening to display change events
  15318. * The onVRDisplayChangedObservable will be notified upon these changes
  15319. * @returns A promise containing a VRDisplay and if vr is supported
  15320. */
  15321. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15322. /** @hidden */
  15323. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15324. /**
  15325. * Gets or sets the presentation attributes used to configure VR rendering
  15326. */
  15327. vrPresentationAttributes?: IVRPresentationAttributes;
  15328. /**
  15329. * Call this function to switch to webVR mode
  15330. * Will do nothing if webVR is not supported or if there is no webVR device
  15331. * @param options the webvr options provided to the camera. mainly used for multiview
  15332. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15333. */
  15334. enableVR(options: WebVROptions): void;
  15335. /** @hidden */
  15336. _onVRFullScreenTriggered(): void;
  15337. }
  15338. }
  15339. }
  15340. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15341. import { Nullable } from "babylonjs/types";
  15342. import { Observable } from "babylonjs/Misc/observable";
  15343. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15344. import { Scene } from "babylonjs/scene";
  15345. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15346. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15347. import { Node } from "babylonjs/node";
  15348. import { Ray } from "babylonjs/Culling/ray";
  15349. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15350. import "babylonjs/Engines/Extensions/engine.webVR";
  15351. /**
  15352. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15353. * IMPORTANT!! The data is right-hand data.
  15354. * @export
  15355. * @interface DevicePose
  15356. */
  15357. export interface DevicePose {
  15358. /**
  15359. * The position of the device, values in array are [x,y,z].
  15360. */
  15361. readonly position: Nullable<Float32Array>;
  15362. /**
  15363. * The linearVelocity of the device, values in array are [x,y,z].
  15364. */
  15365. readonly linearVelocity: Nullable<Float32Array>;
  15366. /**
  15367. * The linearAcceleration of the device, values in array are [x,y,z].
  15368. */
  15369. readonly linearAcceleration: Nullable<Float32Array>;
  15370. /**
  15371. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15372. */
  15373. readonly orientation: Nullable<Float32Array>;
  15374. /**
  15375. * The angularVelocity of the device, values in array are [x,y,z].
  15376. */
  15377. readonly angularVelocity: Nullable<Float32Array>;
  15378. /**
  15379. * The angularAcceleration of the device, values in array are [x,y,z].
  15380. */
  15381. readonly angularAcceleration: Nullable<Float32Array>;
  15382. }
  15383. /**
  15384. * Interface representing a pose controlled object in Babylon.
  15385. * A pose controlled object has both regular pose values as well as pose values
  15386. * from an external device such as a VR head mounted display
  15387. */
  15388. export interface PoseControlled {
  15389. /**
  15390. * The position of the object in babylon space.
  15391. */
  15392. position: Vector3;
  15393. /**
  15394. * The rotation quaternion of the object in babylon space.
  15395. */
  15396. rotationQuaternion: Quaternion;
  15397. /**
  15398. * The position of the device in babylon space.
  15399. */
  15400. devicePosition?: Vector3;
  15401. /**
  15402. * The rotation quaternion of the device in babylon space.
  15403. */
  15404. deviceRotationQuaternion: Quaternion;
  15405. /**
  15406. * The raw pose coming from the device.
  15407. */
  15408. rawPose: Nullable<DevicePose>;
  15409. /**
  15410. * The scale of the device to be used when translating from device space to babylon space.
  15411. */
  15412. deviceScaleFactor: number;
  15413. /**
  15414. * Updates the poseControlled values based on the input device pose.
  15415. * @param poseData the pose data to update the object with
  15416. */
  15417. updateFromDevice(poseData: DevicePose): void;
  15418. }
  15419. /**
  15420. * Set of options to customize the webVRCamera
  15421. */
  15422. export interface WebVROptions {
  15423. /**
  15424. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15425. */
  15426. trackPosition?: boolean;
  15427. /**
  15428. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15429. */
  15430. positionScale?: number;
  15431. /**
  15432. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15433. */
  15434. displayName?: string;
  15435. /**
  15436. * Should the native controller meshes be initialized. (default: true)
  15437. */
  15438. controllerMeshes?: boolean;
  15439. /**
  15440. * Creating a default HemiLight only on controllers. (default: true)
  15441. */
  15442. defaultLightingOnControllers?: boolean;
  15443. /**
  15444. * If you don't want to use the default VR button of the helper. (default: false)
  15445. */
  15446. useCustomVRButton?: boolean;
  15447. /**
  15448. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15449. */
  15450. customVRButton?: HTMLButtonElement;
  15451. /**
  15452. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15453. */
  15454. rayLength?: number;
  15455. /**
  15456. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15457. */
  15458. defaultHeight?: number;
  15459. /**
  15460. * If multiview should be used if availible (default: false)
  15461. */
  15462. useMultiview?: boolean;
  15463. }
  15464. /**
  15465. * This represents a WebVR camera.
  15466. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15467. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15468. */
  15469. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15470. private webVROptions;
  15471. /**
  15472. * @hidden
  15473. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15474. */
  15475. _vrDevice: any;
  15476. /**
  15477. * The rawPose of the vrDevice.
  15478. */
  15479. rawPose: Nullable<DevicePose>;
  15480. private _onVREnabled;
  15481. private _specsVersion;
  15482. private _attached;
  15483. private _frameData;
  15484. protected _descendants: Array<Node>;
  15485. private _deviceRoomPosition;
  15486. /** @hidden */
  15487. _deviceRoomRotationQuaternion: Quaternion;
  15488. private _standingMatrix;
  15489. /**
  15490. * Represents device position in babylon space.
  15491. */
  15492. devicePosition: Vector3;
  15493. /**
  15494. * Represents device rotation in babylon space.
  15495. */
  15496. deviceRotationQuaternion: Quaternion;
  15497. /**
  15498. * The scale of the device to be used when translating from device space to babylon space.
  15499. */
  15500. deviceScaleFactor: number;
  15501. private _deviceToWorld;
  15502. private _worldToDevice;
  15503. /**
  15504. * References to the webVR controllers for the vrDevice.
  15505. */
  15506. controllers: Array<WebVRController>;
  15507. /**
  15508. * Emits an event when a controller is attached.
  15509. */
  15510. onControllersAttachedObservable: Observable<WebVRController[]>;
  15511. /**
  15512. * Emits an event when a controller's mesh has been loaded;
  15513. */
  15514. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15515. /**
  15516. * Emits an event when the HMD's pose has been updated.
  15517. */
  15518. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15519. private _poseSet;
  15520. /**
  15521. * If the rig cameras be used as parent instead of this camera.
  15522. */
  15523. rigParenting: boolean;
  15524. private _lightOnControllers;
  15525. private _defaultHeight?;
  15526. /**
  15527. * Instantiates a WebVRFreeCamera.
  15528. * @param name The name of the WebVRFreeCamera
  15529. * @param position The starting anchor position for the camera
  15530. * @param scene The scene the camera belongs to
  15531. * @param webVROptions a set of customizable options for the webVRCamera
  15532. */
  15533. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15534. /**
  15535. * Gets the device distance from the ground in meters.
  15536. * @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.
  15537. */
  15538. deviceDistanceToRoomGround(): number;
  15539. /**
  15540. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15541. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15542. */
  15543. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15544. /**
  15545. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15546. * @returns A promise with a boolean set to if the standing matrix is supported.
  15547. */
  15548. useStandingMatrixAsync(): Promise<boolean>;
  15549. /**
  15550. * Disposes the camera
  15551. */
  15552. dispose(): void;
  15553. /**
  15554. * Gets a vrController by name.
  15555. * @param name The name of the controller to retreive
  15556. * @returns the controller matching the name specified or null if not found
  15557. */
  15558. getControllerByName(name: string): Nullable<WebVRController>;
  15559. private _leftController;
  15560. /**
  15561. * The controller corresponding to the users left hand.
  15562. */
  15563. readonly leftController: Nullable<WebVRController>;
  15564. private _rightController;
  15565. /**
  15566. * The controller corresponding to the users right hand.
  15567. */
  15568. readonly rightController: Nullable<WebVRController>;
  15569. /**
  15570. * Casts a ray forward from the vrCamera's gaze.
  15571. * @param length Length of the ray (default: 100)
  15572. * @returns the ray corresponding to the gaze
  15573. */
  15574. getForwardRay(length?: number): Ray;
  15575. /**
  15576. * @hidden
  15577. * Updates the camera based on device's frame data
  15578. */
  15579. _checkInputs(): void;
  15580. /**
  15581. * Updates the poseControlled values based on the input device pose.
  15582. * @param poseData Pose coming from the device
  15583. */
  15584. updateFromDevice(poseData: DevicePose): void;
  15585. private _htmlElementAttached;
  15586. private _detachIfAttached;
  15587. /**
  15588. * WebVR's attach control will start broadcasting frames to the device.
  15589. * Note that in certain browsers (chrome for example) this function must be called
  15590. * within a user-interaction callback. Example:
  15591. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15592. *
  15593. * @param element html element to attach the vrDevice to
  15594. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15595. */
  15596. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15597. /**
  15598. * Detaches the camera from the html element and disables VR
  15599. *
  15600. * @param element html element to detach from
  15601. */
  15602. detachControl(element: HTMLElement): void;
  15603. /**
  15604. * @returns the name of this class
  15605. */
  15606. getClassName(): string;
  15607. /**
  15608. * Calls resetPose on the vrDisplay
  15609. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15610. */
  15611. resetToCurrentRotation(): void;
  15612. /**
  15613. * @hidden
  15614. * Updates the rig cameras (left and right eye)
  15615. */
  15616. _updateRigCameras(): void;
  15617. private _workingVector;
  15618. private _oneVector;
  15619. private _workingMatrix;
  15620. private updateCacheCalled;
  15621. private _correctPositionIfNotTrackPosition;
  15622. /**
  15623. * @hidden
  15624. * Updates the cached values of the camera
  15625. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15626. */
  15627. _updateCache(ignoreParentClass?: boolean): void;
  15628. /**
  15629. * @hidden
  15630. * Get current device position in babylon world
  15631. */
  15632. _computeDevicePosition(): void;
  15633. /**
  15634. * Updates the current device position and rotation in the babylon world
  15635. */
  15636. update(): void;
  15637. /**
  15638. * @hidden
  15639. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15640. * @returns an identity matrix
  15641. */
  15642. _getViewMatrix(): Matrix;
  15643. private _tmpMatrix;
  15644. /**
  15645. * This function is called by the two RIG cameras.
  15646. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15647. * @hidden
  15648. */
  15649. _getWebVRViewMatrix(): Matrix;
  15650. /** @hidden */
  15651. _getWebVRProjectionMatrix(): Matrix;
  15652. private _onGamepadConnectedObserver;
  15653. private _onGamepadDisconnectedObserver;
  15654. private _updateCacheWhenTrackingDisabledObserver;
  15655. /**
  15656. * Initializes the controllers and their meshes
  15657. */
  15658. initControllers(): void;
  15659. }
  15660. }
  15661. declare module "babylonjs/PostProcesses/postProcess" {
  15662. import { Nullable } from "babylonjs/types";
  15663. import { SmartArray } from "babylonjs/Misc/smartArray";
  15664. import { Observable } from "babylonjs/Misc/observable";
  15665. import { Vector2 } from "babylonjs/Maths/math.vector";
  15666. import { Camera } from "babylonjs/Cameras/camera";
  15667. import { Effect } from "babylonjs/Materials/effect";
  15668. import "babylonjs/Shaders/postprocess.vertex";
  15669. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15670. import { Engine } from "babylonjs/Engines/engine";
  15671. import { Color4 } from "babylonjs/Maths/math.color";
  15672. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15673. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15674. /**
  15675. * Size options for a post process
  15676. */
  15677. export type PostProcessOptions = {
  15678. width: number;
  15679. height: number;
  15680. };
  15681. /**
  15682. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15683. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15684. */
  15685. export class PostProcess {
  15686. /** Name of the PostProcess. */
  15687. name: string;
  15688. /**
  15689. * Gets or sets the unique id of the post process
  15690. */
  15691. uniqueId: number;
  15692. /**
  15693. * Width of the texture to apply the post process on
  15694. */
  15695. width: number;
  15696. /**
  15697. * Height of the texture to apply the post process on
  15698. */
  15699. height: number;
  15700. /**
  15701. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15702. * @hidden
  15703. */
  15704. _outputTexture: Nullable<InternalTexture>;
  15705. /**
  15706. * Sampling mode used by the shader
  15707. * See https://doc.babylonjs.com/classes/3.1/texture
  15708. */
  15709. renderTargetSamplingMode: number;
  15710. /**
  15711. * Clear color to use when screen clearing
  15712. */
  15713. clearColor: Color4;
  15714. /**
  15715. * If the buffer needs to be cleared before applying the post process. (default: true)
  15716. * Should be set to false if shader will overwrite all previous pixels.
  15717. */
  15718. autoClear: boolean;
  15719. /**
  15720. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15721. */
  15722. alphaMode: number;
  15723. /**
  15724. * Sets the setAlphaBlendConstants of the babylon engine
  15725. */
  15726. alphaConstants: Color4;
  15727. /**
  15728. * Animations to be used for the post processing
  15729. */
  15730. animations: import("babylonjs/Animations/animation").Animation[];
  15731. /**
  15732. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15733. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15734. */
  15735. enablePixelPerfectMode: boolean;
  15736. /**
  15737. * Force the postprocess to be applied without taking in account viewport
  15738. */
  15739. forceFullscreenViewport: boolean;
  15740. /**
  15741. * List of inspectable custom properties (used by the Inspector)
  15742. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15743. */
  15744. inspectableCustomProperties: IInspectable[];
  15745. /**
  15746. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15747. *
  15748. * | Value | Type | Description |
  15749. * | ----- | ----------------------------------- | ----------- |
  15750. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15751. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15752. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15753. *
  15754. */
  15755. scaleMode: number;
  15756. /**
  15757. * Force textures to be a power of two (default: false)
  15758. */
  15759. alwaysForcePOT: boolean;
  15760. private _samples;
  15761. /**
  15762. * Number of sample textures (default: 1)
  15763. */
  15764. samples: number;
  15765. /**
  15766. * Modify the scale of the post process to be the same as the viewport (default: false)
  15767. */
  15768. adaptScaleToCurrentViewport: boolean;
  15769. private _camera;
  15770. private _scene;
  15771. private _engine;
  15772. private _options;
  15773. private _reusable;
  15774. private _textureType;
  15775. /**
  15776. * Smart array of input and output textures for the post process.
  15777. * @hidden
  15778. */
  15779. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15780. /**
  15781. * The index in _textures that corresponds to the output texture.
  15782. * @hidden
  15783. */
  15784. _currentRenderTextureInd: number;
  15785. private _effect;
  15786. private _samplers;
  15787. private _fragmentUrl;
  15788. private _vertexUrl;
  15789. private _parameters;
  15790. private _scaleRatio;
  15791. protected _indexParameters: any;
  15792. private _shareOutputWithPostProcess;
  15793. private _texelSize;
  15794. private _forcedOutputTexture;
  15795. /**
  15796. * Returns the fragment url or shader name used in the post process.
  15797. * @returns the fragment url or name in the shader store.
  15798. */
  15799. getEffectName(): string;
  15800. /**
  15801. * An event triggered when the postprocess is activated.
  15802. */
  15803. onActivateObservable: Observable<Camera>;
  15804. private _onActivateObserver;
  15805. /**
  15806. * A function that is added to the onActivateObservable
  15807. */
  15808. onActivate: Nullable<(camera: Camera) => void>;
  15809. /**
  15810. * An event triggered when the postprocess changes its size.
  15811. */
  15812. onSizeChangedObservable: Observable<PostProcess>;
  15813. private _onSizeChangedObserver;
  15814. /**
  15815. * A function that is added to the onSizeChangedObservable
  15816. */
  15817. onSizeChanged: (postProcess: PostProcess) => void;
  15818. /**
  15819. * An event triggered when the postprocess applies its effect.
  15820. */
  15821. onApplyObservable: Observable<Effect>;
  15822. private _onApplyObserver;
  15823. /**
  15824. * A function that is added to the onApplyObservable
  15825. */
  15826. onApply: (effect: Effect) => void;
  15827. /**
  15828. * An event triggered before rendering the postprocess
  15829. */
  15830. onBeforeRenderObservable: Observable<Effect>;
  15831. private _onBeforeRenderObserver;
  15832. /**
  15833. * A function that is added to the onBeforeRenderObservable
  15834. */
  15835. onBeforeRender: (effect: Effect) => void;
  15836. /**
  15837. * An event triggered after rendering the postprocess
  15838. */
  15839. onAfterRenderObservable: Observable<Effect>;
  15840. private _onAfterRenderObserver;
  15841. /**
  15842. * A function that is added to the onAfterRenderObservable
  15843. */
  15844. onAfterRender: (efect: Effect) => void;
  15845. /**
  15846. * 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
  15847. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15848. */
  15849. inputTexture: InternalTexture;
  15850. /**
  15851. * Gets the camera which post process is applied to.
  15852. * @returns The camera the post process is applied to.
  15853. */
  15854. getCamera(): Camera;
  15855. /**
  15856. * Gets the texel size of the postprocess.
  15857. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15858. */
  15859. readonly texelSize: Vector2;
  15860. /**
  15861. * Creates a new instance PostProcess
  15862. * @param name The name of the PostProcess.
  15863. * @param fragmentUrl The url of the fragment shader to be used.
  15864. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15865. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15866. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15867. * @param camera The camera to apply the render pass to.
  15868. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15869. * @param engine The engine which the post process will be applied. (default: current engine)
  15870. * @param reusable If the post process can be reused on the same frame. (default: false)
  15871. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15872. * @param textureType Type of textures used when performing the post process. (default: 0)
  15873. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15874. * @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
  15875. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15876. */
  15877. constructor(
  15878. /** Name of the PostProcess. */
  15879. 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);
  15880. /**
  15881. * Gets a string idenfifying the name of the class
  15882. * @returns "PostProcess" string
  15883. */
  15884. getClassName(): string;
  15885. /**
  15886. * Gets the engine which this post process belongs to.
  15887. * @returns The engine the post process was enabled with.
  15888. */
  15889. getEngine(): Engine;
  15890. /**
  15891. * The effect that is created when initializing the post process.
  15892. * @returns The created effect corresponding the the postprocess.
  15893. */
  15894. getEffect(): Effect;
  15895. /**
  15896. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15897. * @param postProcess The post process to share the output with.
  15898. * @returns This post process.
  15899. */
  15900. shareOutputWith(postProcess: PostProcess): PostProcess;
  15901. /**
  15902. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15903. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15904. */
  15905. useOwnOutput(): void;
  15906. /**
  15907. * Updates the effect with the current post process compile time values and recompiles the shader.
  15908. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15909. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15910. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15911. * @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
  15912. * @param onCompiled Called when the shader has been compiled.
  15913. * @param onError Called if there is an error when compiling a shader.
  15914. */
  15915. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15916. /**
  15917. * The post process is reusable if it can be used multiple times within one frame.
  15918. * @returns If the post process is reusable
  15919. */
  15920. isReusable(): boolean;
  15921. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15922. markTextureDirty(): void;
  15923. /**
  15924. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15925. * 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.
  15926. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15927. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15928. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15929. * @returns The target texture that was bound to be written to.
  15930. */
  15931. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15932. /**
  15933. * If the post process is supported.
  15934. */
  15935. readonly isSupported: boolean;
  15936. /**
  15937. * The aspect ratio of the output texture.
  15938. */
  15939. readonly aspectRatio: number;
  15940. /**
  15941. * Get a value indicating if the post-process is ready to be used
  15942. * @returns true if the post-process is ready (shader is compiled)
  15943. */
  15944. isReady(): boolean;
  15945. /**
  15946. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15947. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15948. */
  15949. apply(): Nullable<Effect>;
  15950. private _disposeTextures;
  15951. /**
  15952. * Disposes the post process.
  15953. * @param camera The camera to dispose the post process on.
  15954. */
  15955. dispose(camera?: Camera): void;
  15956. }
  15957. }
  15958. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15959. /** @hidden */
  15960. export var kernelBlurVaryingDeclaration: {
  15961. name: string;
  15962. shader: string;
  15963. };
  15964. }
  15965. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15966. /** @hidden */
  15967. export var kernelBlurFragment: {
  15968. name: string;
  15969. shader: string;
  15970. };
  15971. }
  15972. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15973. /** @hidden */
  15974. export var kernelBlurFragment2: {
  15975. name: string;
  15976. shader: string;
  15977. };
  15978. }
  15979. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15980. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15981. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15982. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15983. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15984. /** @hidden */
  15985. export var kernelBlurPixelShader: {
  15986. name: string;
  15987. shader: string;
  15988. };
  15989. }
  15990. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15991. /** @hidden */
  15992. export var kernelBlurVertex: {
  15993. name: string;
  15994. shader: string;
  15995. };
  15996. }
  15997. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15998. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15999. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16000. /** @hidden */
  16001. export var kernelBlurVertexShader: {
  16002. name: string;
  16003. shader: string;
  16004. };
  16005. }
  16006. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16007. import { Vector2 } from "babylonjs/Maths/math.vector";
  16008. import { Nullable } from "babylonjs/types";
  16009. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16010. import { Camera } from "babylonjs/Cameras/camera";
  16011. import { Effect } from "babylonjs/Materials/effect";
  16012. import { Engine } from "babylonjs/Engines/engine";
  16013. import "babylonjs/Shaders/kernelBlur.fragment";
  16014. import "babylonjs/Shaders/kernelBlur.vertex";
  16015. /**
  16016. * The Blur Post Process which blurs an image based on a kernel and direction.
  16017. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16018. */
  16019. export class BlurPostProcess extends PostProcess {
  16020. /** The direction in which to blur the image. */
  16021. direction: Vector2;
  16022. private blockCompilation;
  16023. protected _kernel: number;
  16024. protected _idealKernel: number;
  16025. protected _packedFloat: boolean;
  16026. private _staticDefines;
  16027. /**
  16028. * Sets the length in pixels of the blur sample region
  16029. */
  16030. /**
  16031. * Gets the length in pixels of the blur sample region
  16032. */
  16033. kernel: number;
  16034. /**
  16035. * Sets wether or not the blur needs to unpack/repack floats
  16036. */
  16037. /**
  16038. * Gets wether or not the blur is unpacking/repacking floats
  16039. */
  16040. packedFloat: boolean;
  16041. /**
  16042. * Creates a new instance BlurPostProcess
  16043. * @param name The name of the effect.
  16044. * @param direction The direction in which to blur the image.
  16045. * @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.
  16046. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16047. * @param camera The camera to apply the render pass to.
  16048. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16049. * @param engine The engine which the post process will be applied. (default: current engine)
  16050. * @param reusable If the post process can be reused on the same frame. (default: false)
  16051. * @param textureType Type of textures used when performing the post process. (default: 0)
  16052. * @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)
  16053. */
  16054. constructor(name: string,
  16055. /** The direction in which to blur the image. */
  16056. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16057. /**
  16058. * Updates the effect with the current post process compile time values and recompiles the shader.
  16059. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16060. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16061. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16062. * @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
  16063. * @param onCompiled Called when the shader has been compiled.
  16064. * @param onError Called if there is an error when compiling a shader.
  16065. */
  16066. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16067. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16068. /**
  16069. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16070. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16071. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16072. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16073. * The gaps between physical kernels are compensated for in the weighting of the samples
  16074. * @param idealKernel Ideal blur kernel.
  16075. * @return Nearest best kernel.
  16076. */
  16077. protected _nearestBestKernel(idealKernel: number): number;
  16078. /**
  16079. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16080. * @param x The point on the Gaussian distribution to sample.
  16081. * @return the value of the Gaussian function at x.
  16082. */
  16083. protected _gaussianWeight(x: number): number;
  16084. /**
  16085. * Generates a string that can be used as a floating point number in GLSL.
  16086. * @param x Value to print.
  16087. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16088. * @return GLSL float string.
  16089. */
  16090. protected _glslFloat(x: number, decimalFigures?: number): string;
  16091. }
  16092. }
  16093. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16094. import { Scene } from "babylonjs/scene";
  16095. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16096. import { Plane } from "babylonjs/Maths/math.plane";
  16097. /**
  16098. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16099. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16100. * You can then easily use it as a reflectionTexture on a flat surface.
  16101. * In case the surface is not a plane, please consider relying on reflection probes.
  16102. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16103. */
  16104. export class MirrorTexture extends RenderTargetTexture {
  16105. private scene;
  16106. /**
  16107. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16108. * 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.
  16109. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16110. */
  16111. mirrorPlane: Plane;
  16112. /**
  16113. * Define the blur ratio used to blur the reflection if needed.
  16114. */
  16115. blurRatio: number;
  16116. /**
  16117. * Define the adaptive blur kernel used to blur the reflection if needed.
  16118. * This will autocompute the closest best match for the `blurKernel`
  16119. */
  16120. adaptiveBlurKernel: number;
  16121. /**
  16122. * Define the blur kernel used to blur the reflection if needed.
  16123. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16124. */
  16125. blurKernel: number;
  16126. /**
  16127. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16128. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16129. */
  16130. blurKernelX: number;
  16131. /**
  16132. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16133. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16134. */
  16135. blurKernelY: number;
  16136. private _autoComputeBlurKernel;
  16137. protected _onRatioRescale(): void;
  16138. private _updateGammaSpace;
  16139. private _imageProcessingConfigChangeObserver;
  16140. private _transformMatrix;
  16141. private _mirrorMatrix;
  16142. private _savedViewMatrix;
  16143. private _blurX;
  16144. private _blurY;
  16145. private _adaptiveBlurKernel;
  16146. private _blurKernelX;
  16147. private _blurKernelY;
  16148. private _blurRatio;
  16149. /**
  16150. * Instantiates a Mirror Texture.
  16151. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16152. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16153. * You can then easily use it as a reflectionTexture on a flat surface.
  16154. * In case the surface is not a plane, please consider relying on reflection probes.
  16155. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16156. * @param name
  16157. * @param size
  16158. * @param scene
  16159. * @param generateMipMaps
  16160. * @param type
  16161. * @param samplingMode
  16162. * @param generateDepthBuffer
  16163. */
  16164. constructor(name: string, size: number | {
  16165. width: number;
  16166. height: number;
  16167. } | {
  16168. ratio: number;
  16169. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16170. private _preparePostProcesses;
  16171. /**
  16172. * Clone the mirror texture.
  16173. * @returns the cloned texture
  16174. */
  16175. clone(): MirrorTexture;
  16176. /**
  16177. * Serialize the texture to a JSON representation you could use in Parse later on
  16178. * @returns the serialized JSON representation
  16179. */
  16180. serialize(): any;
  16181. /**
  16182. * Dispose the texture and release its associated resources.
  16183. */
  16184. dispose(): void;
  16185. }
  16186. }
  16187. declare module "babylonjs/Materials/Textures/texture" {
  16188. import { Observable } from "babylonjs/Misc/observable";
  16189. import { Nullable } from "babylonjs/types";
  16190. import { Matrix } from "babylonjs/Maths/math.vector";
  16191. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16192. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16193. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16194. import { Scene } from "babylonjs/scene";
  16195. /**
  16196. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16197. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16198. */
  16199. export class Texture extends BaseTexture {
  16200. /**
  16201. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16202. */
  16203. static SerializeBuffers: boolean;
  16204. /** @hidden */
  16205. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16206. /** @hidden */
  16207. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16208. /** @hidden */
  16209. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16210. /** nearest is mag = nearest and min = nearest and mip = linear */
  16211. static readonly NEAREST_SAMPLINGMODE: number;
  16212. /** nearest is mag = nearest and min = nearest and mip = linear */
  16213. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16214. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16215. static readonly BILINEAR_SAMPLINGMODE: number;
  16216. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16217. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16218. /** Trilinear is mag = linear and min = linear and mip = linear */
  16219. static readonly TRILINEAR_SAMPLINGMODE: number;
  16220. /** Trilinear is mag = linear and min = linear and mip = linear */
  16221. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16222. /** mag = nearest and min = nearest and mip = nearest */
  16223. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16224. /** mag = nearest and min = linear and mip = nearest */
  16225. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16226. /** mag = nearest and min = linear and mip = linear */
  16227. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16228. /** mag = nearest and min = linear and mip = none */
  16229. static readonly NEAREST_LINEAR: number;
  16230. /** mag = nearest and min = nearest and mip = none */
  16231. static readonly NEAREST_NEAREST: number;
  16232. /** mag = linear and min = nearest and mip = nearest */
  16233. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16234. /** mag = linear and min = nearest and mip = linear */
  16235. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16236. /** mag = linear and min = linear and mip = none */
  16237. static readonly LINEAR_LINEAR: number;
  16238. /** mag = linear and min = nearest and mip = none */
  16239. static readonly LINEAR_NEAREST: number;
  16240. /** Explicit coordinates mode */
  16241. static readonly EXPLICIT_MODE: number;
  16242. /** Spherical coordinates mode */
  16243. static readonly SPHERICAL_MODE: number;
  16244. /** Planar coordinates mode */
  16245. static readonly PLANAR_MODE: number;
  16246. /** Cubic coordinates mode */
  16247. static readonly CUBIC_MODE: number;
  16248. /** Projection coordinates mode */
  16249. static readonly PROJECTION_MODE: number;
  16250. /** Inverse Cubic coordinates mode */
  16251. static readonly SKYBOX_MODE: number;
  16252. /** Inverse Cubic coordinates mode */
  16253. static readonly INVCUBIC_MODE: number;
  16254. /** Equirectangular coordinates mode */
  16255. static readonly EQUIRECTANGULAR_MODE: number;
  16256. /** Equirectangular Fixed coordinates mode */
  16257. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16258. /** Equirectangular Fixed Mirrored coordinates mode */
  16259. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16260. /** Texture is not repeating outside of 0..1 UVs */
  16261. static readonly CLAMP_ADDRESSMODE: number;
  16262. /** Texture is repeating outside of 0..1 UVs */
  16263. static readonly WRAP_ADDRESSMODE: number;
  16264. /** Texture is repeating and mirrored */
  16265. static readonly MIRROR_ADDRESSMODE: number;
  16266. /**
  16267. * 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
  16268. */
  16269. static UseSerializedUrlIfAny: boolean;
  16270. /**
  16271. * Define the url of the texture.
  16272. */
  16273. url: Nullable<string>;
  16274. /**
  16275. * Define an offset on the texture to offset the u coordinates of the UVs
  16276. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16277. */
  16278. uOffset: number;
  16279. /**
  16280. * Define an offset on the texture to offset the v coordinates of the UVs
  16281. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16282. */
  16283. vOffset: number;
  16284. /**
  16285. * Define an offset on the texture to scale the u coordinates of the UVs
  16286. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16287. */
  16288. uScale: number;
  16289. /**
  16290. * Define an offset on the texture to scale the v coordinates of the UVs
  16291. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16292. */
  16293. vScale: number;
  16294. /**
  16295. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16296. * @see http://doc.babylonjs.com/how_to/more_materials
  16297. */
  16298. uAng: number;
  16299. /**
  16300. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16301. * @see http://doc.babylonjs.com/how_to/more_materials
  16302. */
  16303. vAng: number;
  16304. /**
  16305. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16306. * @see http://doc.babylonjs.com/how_to/more_materials
  16307. */
  16308. wAng: number;
  16309. /**
  16310. * Defines the center of rotation (U)
  16311. */
  16312. uRotationCenter: number;
  16313. /**
  16314. * Defines the center of rotation (V)
  16315. */
  16316. vRotationCenter: number;
  16317. /**
  16318. * Defines the center of rotation (W)
  16319. */
  16320. wRotationCenter: number;
  16321. /**
  16322. * Are mip maps generated for this texture or not.
  16323. */
  16324. readonly noMipmap: boolean;
  16325. /**
  16326. * List of inspectable custom properties (used by the Inspector)
  16327. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16328. */
  16329. inspectableCustomProperties: Nullable<IInspectable[]>;
  16330. private _noMipmap;
  16331. /** @hidden */
  16332. _invertY: boolean;
  16333. private _rowGenerationMatrix;
  16334. private _cachedTextureMatrix;
  16335. private _projectionModeMatrix;
  16336. private _t0;
  16337. private _t1;
  16338. private _t2;
  16339. private _cachedUOffset;
  16340. private _cachedVOffset;
  16341. private _cachedUScale;
  16342. private _cachedVScale;
  16343. private _cachedUAng;
  16344. private _cachedVAng;
  16345. private _cachedWAng;
  16346. private _cachedProjectionMatrixId;
  16347. private _cachedCoordinatesMode;
  16348. /** @hidden */
  16349. protected _initialSamplingMode: number;
  16350. /** @hidden */
  16351. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16352. private _deleteBuffer;
  16353. protected _format: Nullable<number>;
  16354. private _delayedOnLoad;
  16355. private _delayedOnError;
  16356. private _mimeType?;
  16357. /**
  16358. * Observable triggered once the texture has been loaded.
  16359. */
  16360. onLoadObservable: Observable<Texture>;
  16361. protected _isBlocking: boolean;
  16362. /**
  16363. * Is the texture preventing material to render while loading.
  16364. * If false, a default texture will be used instead of the loading one during the preparation step.
  16365. */
  16366. isBlocking: boolean;
  16367. /**
  16368. * Get the current sampling mode associated with the texture.
  16369. */
  16370. readonly samplingMode: number;
  16371. /**
  16372. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16373. */
  16374. readonly invertY: boolean;
  16375. /**
  16376. * Instantiates a new texture.
  16377. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16378. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16379. * @param url defines the url of the picture to load as a texture
  16380. * @param scene defines the scene or engine the texture will belong to
  16381. * @param noMipmap defines if the texture will require mip maps or not
  16382. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16383. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16384. * @param onLoad defines a callback triggered when the texture has been loaded
  16385. * @param onError defines a callback triggered when an error occurred during the loading session
  16386. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16387. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16388. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16389. * @param mimeType defines an optional mime type information
  16390. */
  16391. 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);
  16392. /**
  16393. * Update the url (and optional buffer) of this texture if url was null during construction.
  16394. * @param url the url of the texture
  16395. * @param buffer the buffer of the texture (defaults to null)
  16396. * @param onLoad callback called when the texture is loaded (defaults to null)
  16397. */
  16398. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16399. /**
  16400. * Finish the loading sequence of a texture flagged as delayed load.
  16401. * @hidden
  16402. */
  16403. delayLoad(): void;
  16404. private _prepareRowForTextureGeneration;
  16405. /**
  16406. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16407. * @returns the transform matrix of the texture.
  16408. */
  16409. getTextureMatrix(): Matrix;
  16410. /**
  16411. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16412. * @returns The reflection texture transform
  16413. */
  16414. getReflectionTextureMatrix(): Matrix;
  16415. /**
  16416. * Clones the texture.
  16417. * @returns the cloned texture
  16418. */
  16419. clone(): Texture;
  16420. /**
  16421. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16422. * @returns The JSON representation of the texture
  16423. */
  16424. serialize(): any;
  16425. /**
  16426. * Get the current class name of the texture useful for serialization or dynamic coding.
  16427. * @returns "Texture"
  16428. */
  16429. getClassName(): string;
  16430. /**
  16431. * Dispose the texture and release its associated resources.
  16432. */
  16433. dispose(): void;
  16434. /**
  16435. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16436. * @param parsedTexture Define the JSON representation of the texture
  16437. * @param scene Define the scene the parsed texture should be instantiated in
  16438. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16439. * @returns The parsed texture if successful
  16440. */
  16441. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16442. /**
  16443. * Creates a texture from its base 64 representation.
  16444. * @param data Define the base64 payload without the data: prefix
  16445. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16446. * @param scene Define the scene the texture should belong to
  16447. * @param noMipmap Forces the texture to not create mip map information if true
  16448. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16449. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16450. * @param onLoad define a callback triggered when the texture has been loaded
  16451. * @param onError define a callback triggered when an error occurred during the loading session
  16452. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16453. * @returns the created texture
  16454. */
  16455. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16456. /**
  16457. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16458. * @param data Define the base64 payload without the data: prefix
  16459. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16460. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16461. * @param scene Define the scene the texture should belong to
  16462. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16463. * @param noMipmap Forces the texture to not create mip map information if true
  16464. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16465. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16466. * @param onLoad define a callback triggered when the texture has been loaded
  16467. * @param onError define a callback triggered when an error occurred during the loading session
  16468. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16469. * @returns the created texture
  16470. */
  16471. 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;
  16472. }
  16473. }
  16474. declare module "babylonjs/PostProcesses/postProcessManager" {
  16475. import { Nullable } from "babylonjs/types";
  16476. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16477. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16478. import { Scene } from "babylonjs/scene";
  16479. /**
  16480. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16481. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16482. */
  16483. export class PostProcessManager {
  16484. private _scene;
  16485. private _indexBuffer;
  16486. private _vertexBuffers;
  16487. /**
  16488. * Creates a new instance PostProcess
  16489. * @param scene The scene that the post process is associated with.
  16490. */
  16491. constructor(scene: Scene);
  16492. private _prepareBuffers;
  16493. private _buildIndexBuffer;
  16494. /**
  16495. * Rebuilds the vertex buffers of the manager.
  16496. * @hidden
  16497. */
  16498. _rebuild(): void;
  16499. /**
  16500. * Prepares a frame to be run through a post process.
  16501. * @param sourceTexture The input texture to the post procesess. (default: null)
  16502. * @param postProcesses An array of post processes to be run. (default: null)
  16503. * @returns True if the post processes were able to be run.
  16504. * @hidden
  16505. */
  16506. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16507. /**
  16508. * Manually render a set of post processes to a texture.
  16509. * @param postProcesses An array of post processes to be run.
  16510. * @param targetTexture The target texture to render to.
  16511. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16512. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16513. * @param lodLevel defines which lod of the texture to render to
  16514. */
  16515. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16516. /**
  16517. * Finalize the result of the output of the postprocesses.
  16518. * @param doNotPresent If true the result will not be displayed to the screen.
  16519. * @param targetTexture The target texture to render to.
  16520. * @param faceIndex The index of the face to bind the target texture to.
  16521. * @param postProcesses The array of post processes to render.
  16522. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16523. * @hidden
  16524. */
  16525. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16526. /**
  16527. * Disposes of the post process manager.
  16528. */
  16529. dispose(): void;
  16530. }
  16531. }
  16532. declare module "babylonjs/Misc/gradients" {
  16533. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16534. /** Interface used by value gradients (color, factor, ...) */
  16535. export interface IValueGradient {
  16536. /**
  16537. * Gets or sets the gradient value (between 0 and 1)
  16538. */
  16539. gradient: number;
  16540. }
  16541. /** Class used to store color4 gradient */
  16542. export class ColorGradient implements IValueGradient {
  16543. /**
  16544. * Gets or sets the gradient value (between 0 and 1)
  16545. */
  16546. gradient: number;
  16547. /**
  16548. * Gets or sets first associated color
  16549. */
  16550. color1: Color4;
  16551. /**
  16552. * Gets or sets second associated color
  16553. */
  16554. color2?: Color4;
  16555. /**
  16556. * Will get a color picked randomly between color1 and color2.
  16557. * If color2 is undefined then color1 will be used
  16558. * @param result defines the target Color4 to store the result in
  16559. */
  16560. getColorToRef(result: Color4): void;
  16561. }
  16562. /** Class used to store color 3 gradient */
  16563. export class Color3Gradient implements IValueGradient {
  16564. /**
  16565. * Gets or sets the gradient value (between 0 and 1)
  16566. */
  16567. gradient: number;
  16568. /**
  16569. * Gets or sets the associated color
  16570. */
  16571. color: Color3;
  16572. }
  16573. /** Class used to store factor gradient */
  16574. export class FactorGradient implements IValueGradient {
  16575. /**
  16576. * Gets or sets the gradient value (between 0 and 1)
  16577. */
  16578. gradient: number;
  16579. /**
  16580. * Gets or sets first associated factor
  16581. */
  16582. factor1: number;
  16583. /**
  16584. * Gets or sets second associated factor
  16585. */
  16586. factor2?: number;
  16587. /**
  16588. * Will get a number picked randomly between factor1 and factor2.
  16589. * If factor2 is undefined then factor1 will be used
  16590. * @returns the picked number
  16591. */
  16592. getFactor(): number;
  16593. }
  16594. /**
  16595. * Helper used to simplify some generic gradient tasks
  16596. */
  16597. export class GradientHelper {
  16598. /**
  16599. * Gets the current gradient from an array of IValueGradient
  16600. * @param ratio defines the current ratio to get
  16601. * @param gradients defines the array of IValueGradient
  16602. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16603. */
  16604. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16605. }
  16606. }
  16607. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16608. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16609. import { Nullable } from "babylonjs/types";
  16610. module "babylonjs/Engines/thinEngine" {
  16611. interface ThinEngine {
  16612. /**
  16613. * Creates a dynamic texture
  16614. * @param width defines the width of the texture
  16615. * @param height defines the height of the texture
  16616. * @param generateMipMaps defines if the engine should generate the mip levels
  16617. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16618. * @returns the dynamic texture inside an InternalTexture
  16619. */
  16620. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16621. /**
  16622. * Update the content of a dynamic texture
  16623. * @param texture defines the texture to update
  16624. * @param canvas defines the canvas containing the source
  16625. * @param invertY defines if data must be stored with Y axis inverted
  16626. * @param premulAlpha defines if alpha is stored as premultiplied
  16627. * @param format defines the format of the data
  16628. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16629. */
  16630. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16631. }
  16632. }
  16633. }
  16634. declare module "babylonjs/Misc/canvasGenerator" {
  16635. /**
  16636. * Helper class used to generate a canvas to manipulate images
  16637. */
  16638. export class CanvasGenerator {
  16639. /**
  16640. * Create a new canvas (or offscreen canvas depending on the context)
  16641. * @param width defines the expected width
  16642. * @param height defines the expected height
  16643. * @return a new canvas or offscreen canvas
  16644. */
  16645. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16646. }
  16647. }
  16648. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16649. import { Scene } from "babylonjs/scene";
  16650. import { Texture } from "babylonjs/Materials/Textures/texture";
  16651. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16652. /**
  16653. * A class extending Texture allowing drawing on a texture
  16654. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16655. */
  16656. export class DynamicTexture extends Texture {
  16657. private _generateMipMaps;
  16658. private _canvas;
  16659. private _context;
  16660. private _engine;
  16661. /**
  16662. * Creates a DynamicTexture
  16663. * @param name defines the name of the texture
  16664. * @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
  16665. * @param scene defines the scene where you want the texture
  16666. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16667. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16668. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16669. */
  16670. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16671. /**
  16672. * Get the current class name of the texture useful for serialization or dynamic coding.
  16673. * @returns "DynamicTexture"
  16674. */
  16675. getClassName(): string;
  16676. /**
  16677. * Gets the current state of canRescale
  16678. */
  16679. readonly canRescale: boolean;
  16680. private _recreate;
  16681. /**
  16682. * Scales the texture
  16683. * @param ratio the scale factor to apply to both width and height
  16684. */
  16685. scale(ratio: number): void;
  16686. /**
  16687. * Resizes the texture
  16688. * @param width the new width
  16689. * @param height the new height
  16690. */
  16691. scaleTo(width: number, height: number): void;
  16692. /**
  16693. * Gets the context of the canvas used by the texture
  16694. * @returns the canvas context of the dynamic texture
  16695. */
  16696. getContext(): CanvasRenderingContext2D;
  16697. /**
  16698. * Clears the texture
  16699. */
  16700. clear(): void;
  16701. /**
  16702. * Updates the texture
  16703. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16704. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16705. */
  16706. update(invertY?: boolean, premulAlpha?: boolean): void;
  16707. /**
  16708. * Draws text onto the texture
  16709. * @param text defines the text to be drawn
  16710. * @param x defines the placement of the text from the left
  16711. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16712. * @param font defines the font to be used with font-style, font-size, font-name
  16713. * @param color defines the color used for the text
  16714. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16715. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16716. * @param update defines whether texture is immediately update (default is true)
  16717. */
  16718. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16719. /**
  16720. * Clones the texture
  16721. * @returns the clone of the texture.
  16722. */
  16723. clone(): DynamicTexture;
  16724. /**
  16725. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16726. * @returns a serialized dynamic texture object
  16727. */
  16728. serialize(): any;
  16729. /** @hidden */
  16730. _rebuild(): void;
  16731. }
  16732. }
  16733. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16734. import { Scene } from "babylonjs/scene";
  16735. import { ISceneComponent } from "babylonjs/sceneComponent";
  16736. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16737. module "babylonjs/abstractScene" {
  16738. interface AbstractScene {
  16739. /**
  16740. * The list of procedural textures added to the scene
  16741. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16742. */
  16743. proceduralTextures: Array<ProceduralTexture>;
  16744. }
  16745. }
  16746. /**
  16747. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16748. * in a given scene.
  16749. */
  16750. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16751. /**
  16752. * The component name helpfull to identify the component in the list of scene components.
  16753. */
  16754. readonly name: string;
  16755. /**
  16756. * The scene the component belongs to.
  16757. */
  16758. scene: Scene;
  16759. /**
  16760. * Creates a new instance of the component for the given scene
  16761. * @param scene Defines the scene to register the component in
  16762. */
  16763. constructor(scene: Scene);
  16764. /**
  16765. * Registers the component in a given scene
  16766. */
  16767. register(): void;
  16768. /**
  16769. * Rebuilds the elements related to this component in case of
  16770. * context lost for instance.
  16771. */
  16772. rebuild(): void;
  16773. /**
  16774. * Disposes the component and the associated ressources.
  16775. */
  16776. dispose(): void;
  16777. private _beforeClear;
  16778. }
  16779. }
  16780. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16781. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16782. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16783. module "babylonjs/Engines/thinEngine" {
  16784. interface ThinEngine {
  16785. /**
  16786. * Creates a new render target cube texture
  16787. * @param size defines the size of the texture
  16788. * @param options defines the options used to create the texture
  16789. * @returns a new render target cube texture stored in an InternalTexture
  16790. */
  16791. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16792. }
  16793. }
  16794. }
  16795. declare module "babylonjs/Shaders/procedural.vertex" {
  16796. /** @hidden */
  16797. export var proceduralVertexShader: {
  16798. name: string;
  16799. shader: string;
  16800. };
  16801. }
  16802. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16803. import { Observable } from "babylonjs/Misc/observable";
  16804. import { Nullable } from "babylonjs/types";
  16805. import { Scene } from "babylonjs/scene";
  16806. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16807. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16808. import { Effect } from "babylonjs/Materials/effect";
  16809. import { Texture } from "babylonjs/Materials/Textures/texture";
  16810. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16811. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16812. import "babylonjs/Shaders/procedural.vertex";
  16813. /**
  16814. * 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.
  16815. * This is the base class of any Procedural texture and contains most of the shareable code.
  16816. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16817. */
  16818. export class ProceduralTexture extends Texture {
  16819. isCube: boolean;
  16820. /**
  16821. * Define if the texture is enabled or not (disabled texture will not render)
  16822. */
  16823. isEnabled: boolean;
  16824. /**
  16825. * Define if the texture must be cleared before rendering (default is true)
  16826. */
  16827. autoClear: boolean;
  16828. /**
  16829. * Callback called when the texture is generated
  16830. */
  16831. onGenerated: () => void;
  16832. /**
  16833. * Event raised when the texture is generated
  16834. */
  16835. onGeneratedObservable: Observable<ProceduralTexture>;
  16836. /** @hidden */
  16837. _generateMipMaps: boolean;
  16838. /** @hidden **/
  16839. _effect: Effect;
  16840. /** @hidden */
  16841. _textures: {
  16842. [key: string]: Texture;
  16843. };
  16844. private _size;
  16845. private _currentRefreshId;
  16846. private _refreshRate;
  16847. private _vertexBuffers;
  16848. private _indexBuffer;
  16849. private _uniforms;
  16850. private _samplers;
  16851. private _fragment;
  16852. private _floats;
  16853. private _ints;
  16854. private _floatsArrays;
  16855. private _colors3;
  16856. private _colors4;
  16857. private _vectors2;
  16858. private _vectors3;
  16859. private _matrices;
  16860. private _fallbackTexture;
  16861. private _fallbackTextureUsed;
  16862. private _engine;
  16863. private _cachedDefines;
  16864. private _contentUpdateId;
  16865. private _contentData;
  16866. /**
  16867. * Instantiates a new procedural texture.
  16868. * 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.
  16869. * This is the base class of any Procedural texture and contains most of the shareable code.
  16870. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16871. * @param name Define the name of the texture
  16872. * @param size Define the size of the texture to create
  16873. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16874. * @param scene Define the scene the texture belongs to
  16875. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16876. * @param generateMipMaps Define if the texture should creates mip maps or not
  16877. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16878. */
  16879. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16880. /**
  16881. * The effect that is created when initializing the post process.
  16882. * @returns The created effect corresponding the the postprocess.
  16883. */
  16884. getEffect(): Effect;
  16885. /**
  16886. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16887. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16888. */
  16889. getContent(): Nullable<ArrayBufferView>;
  16890. private _createIndexBuffer;
  16891. /** @hidden */
  16892. _rebuild(): void;
  16893. /**
  16894. * Resets the texture in order to recreate its associated resources.
  16895. * This can be called in case of context loss
  16896. */
  16897. reset(): void;
  16898. protected _getDefines(): string;
  16899. /**
  16900. * Is the texture ready to be used ? (rendered at least once)
  16901. * @returns true if ready, otherwise, false.
  16902. */
  16903. isReady(): boolean;
  16904. /**
  16905. * Resets the refresh counter of the texture and start bak from scratch.
  16906. * Could be useful to regenerate the texture if it is setup to render only once.
  16907. */
  16908. resetRefreshCounter(): void;
  16909. /**
  16910. * Set the fragment shader to use in order to render the texture.
  16911. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16912. */
  16913. setFragment(fragment: any): void;
  16914. /**
  16915. * Define the refresh rate of the texture or the rendering frequency.
  16916. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16917. */
  16918. refreshRate: number;
  16919. /** @hidden */
  16920. _shouldRender(): boolean;
  16921. /**
  16922. * Get the size the texture is rendering at.
  16923. * @returns the size (texture is always squared)
  16924. */
  16925. getRenderSize(): number;
  16926. /**
  16927. * Resize the texture to new value.
  16928. * @param size Define the new size the texture should have
  16929. * @param generateMipMaps Define whether the new texture should create mip maps
  16930. */
  16931. resize(size: number, generateMipMaps: boolean): void;
  16932. private _checkUniform;
  16933. /**
  16934. * Set a texture in the shader program used to render.
  16935. * @param name Define the name of the uniform samplers as defined in the shader
  16936. * @param texture Define the texture to bind to this sampler
  16937. * @return the texture itself allowing "fluent" like uniform updates
  16938. */
  16939. setTexture(name: string, texture: Texture): ProceduralTexture;
  16940. /**
  16941. * Set a float in the shader.
  16942. * @param name Define the name of the uniform as defined in the shader
  16943. * @param value Define the value to give to the uniform
  16944. * @return the texture itself allowing "fluent" like uniform updates
  16945. */
  16946. setFloat(name: string, value: number): ProceduralTexture;
  16947. /**
  16948. * Set a int in the shader.
  16949. * @param name Define the name of the uniform as defined in the shader
  16950. * @param value Define the value to give to the uniform
  16951. * @return the texture itself allowing "fluent" like uniform updates
  16952. */
  16953. setInt(name: string, value: number): ProceduralTexture;
  16954. /**
  16955. * Set an array of floats in the shader.
  16956. * @param name Define the name of the uniform as defined in the shader
  16957. * @param value Define the value to give to the uniform
  16958. * @return the texture itself allowing "fluent" like uniform updates
  16959. */
  16960. setFloats(name: string, value: number[]): ProceduralTexture;
  16961. /**
  16962. * Set a vec3 in the shader from a Color3.
  16963. * @param name Define the name of the uniform as defined in the shader
  16964. * @param value Define the value to give to the uniform
  16965. * @return the texture itself allowing "fluent" like uniform updates
  16966. */
  16967. setColor3(name: string, value: Color3): ProceduralTexture;
  16968. /**
  16969. * Set a vec4 in the shader from a Color4.
  16970. * @param name Define the name of the uniform as defined in the shader
  16971. * @param value Define the value to give to the uniform
  16972. * @return the texture itself allowing "fluent" like uniform updates
  16973. */
  16974. setColor4(name: string, value: Color4): ProceduralTexture;
  16975. /**
  16976. * Set a vec2 in the shader from a Vector2.
  16977. * @param name Define the name of the uniform as defined in the shader
  16978. * @param value Define the value to give to the uniform
  16979. * @return the texture itself allowing "fluent" like uniform updates
  16980. */
  16981. setVector2(name: string, value: Vector2): ProceduralTexture;
  16982. /**
  16983. * Set a vec3 in the shader from a Vector3.
  16984. * @param name Define the name of the uniform as defined in the shader
  16985. * @param value Define the value to give to the uniform
  16986. * @return the texture itself allowing "fluent" like uniform updates
  16987. */
  16988. setVector3(name: string, value: Vector3): ProceduralTexture;
  16989. /**
  16990. * Set a mat4 in the shader from a MAtrix.
  16991. * @param name Define the name of the uniform as defined in the shader
  16992. * @param value Define the value to give to the uniform
  16993. * @return the texture itself allowing "fluent" like uniform updates
  16994. */
  16995. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16996. /**
  16997. * Render the texture to its associated render target.
  16998. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16999. */
  17000. render(useCameraPostProcess?: boolean): void;
  17001. /**
  17002. * Clone the texture.
  17003. * @returns the cloned texture
  17004. */
  17005. clone(): ProceduralTexture;
  17006. /**
  17007. * Dispose the texture and release its asoociated resources.
  17008. */
  17009. dispose(): void;
  17010. }
  17011. }
  17012. declare module "babylonjs/Particles/baseParticleSystem" {
  17013. import { Nullable } from "babylonjs/types";
  17014. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17016. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17017. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17018. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17019. import { Scene } from "babylonjs/scene";
  17020. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17021. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17022. import { Texture } from "babylonjs/Materials/Textures/texture";
  17023. import { Color4 } from "babylonjs/Maths/math.color";
  17024. import { Animation } from "babylonjs/Animations/animation";
  17025. /**
  17026. * This represents the base class for particle system in Babylon.
  17027. * 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.
  17028. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17029. * @example https://doc.babylonjs.com/babylon101/particles
  17030. */
  17031. export class BaseParticleSystem {
  17032. /**
  17033. * Source color is added to the destination color without alpha affecting the result
  17034. */
  17035. static BLENDMODE_ONEONE: number;
  17036. /**
  17037. * Blend current color and particle color using particle’s alpha
  17038. */
  17039. static BLENDMODE_STANDARD: number;
  17040. /**
  17041. * Add current color and particle color multiplied by particle’s alpha
  17042. */
  17043. static BLENDMODE_ADD: number;
  17044. /**
  17045. * Multiply current color with particle color
  17046. */
  17047. static BLENDMODE_MULTIPLY: number;
  17048. /**
  17049. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17050. */
  17051. static BLENDMODE_MULTIPLYADD: number;
  17052. /**
  17053. * List of animations used by the particle system.
  17054. */
  17055. animations: Animation[];
  17056. /**
  17057. * The id of the Particle system.
  17058. */
  17059. id: string;
  17060. /**
  17061. * The friendly name of the Particle system.
  17062. */
  17063. name: string;
  17064. /**
  17065. * The rendering group used by the Particle system to chose when to render.
  17066. */
  17067. renderingGroupId: number;
  17068. /**
  17069. * The emitter represents the Mesh or position we are attaching the particle system to.
  17070. */
  17071. emitter: Nullable<AbstractMesh | Vector3>;
  17072. /**
  17073. * The maximum number of particles to emit per frame
  17074. */
  17075. emitRate: number;
  17076. /**
  17077. * If you want to launch only a few particles at once, that can be done, as well.
  17078. */
  17079. manualEmitCount: number;
  17080. /**
  17081. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17082. */
  17083. updateSpeed: number;
  17084. /**
  17085. * The amount of time the particle system is running (depends of the overall update speed).
  17086. */
  17087. targetStopDuration: number;
  17088. /**
  17089. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17090. */
  17091. disposeOnStop: boolean;
  17092. /**
  17093. * Minimum power of emitting particles.
  17094. */
  17095. minEmitPower: number;
  17096. /**
  17097. * Maximum power of emitting particles.
  17098. */
  17099. maxEmitPower: number;
  17100. /**
  17101. * Minimum life time of emitting particles.
  17102. */
  17103. minLifeTime: number;
  17104. /**
  17105. * Maximum life time of emitting particles.
  17106. */
  17107. maxLifeTime: number;
  17108. /**
  17109. * Minimum Size of emitting particles.
  17110. */
  17111. minSize: number;
  17112. /**
  17113. * Maximum Size of emitting particles.
  17114. */
  17115. maxSize: number;
  17116. /**
  17117. * Minimum scale of emitting particles on X axis.
  17118. */
  17119. minScaleX: number;
  17120. /**
  17121. * Maximum scale of emitting particles on X axis.
  17122. */
  17123. maxScaleX: number;
  17124. /**
  17125. * Minimum scale of emitting particles on Y axis.
  17126. */
  17127. minScaleY: number;
  17128. /**
  17129. * Maximum scale of emitting particles on Y axis.
  17130. */
  17131. maxScaleY: number;
  17132. /**
  17133. * Gets or sets the minimal initial rotation in radians.
  17134. */
  17135. minInitialRotation: number;
  17136. /**
  17137. * Gets or sets the maximal initial rotation in radians.
  17138. */
  17139. maxInitialRotation: number;
  17140. /**
  17141. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17142. */
  17143. minAngularSpeed: number;
  17144. /**
  17145. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17146. */
  17147. maxAngularSpeed: number;
  17148. /**
  17149. * The texture used to render each particle. (this can be a spritesheet)
  17150. */
  17151. particleTexture: Nullable<Texture>;
  17152. /**
  17153. * The layer mask we are rendering the particles through.
  17154. */
  17155. layerMask: number;
  17156. /**
  17157. * This can help using your own shader to render the particle system.
  17158. * The according effect will be created
  17159. */
  17160. customShader: any;
  17161. /**
  17162. * By default particle system starts as soon as they are created. This prevents the
  17163. * automatic start to happen and let you decide when to start emitting particles.
  17164. */
  17165. preventAutoStart: boolean;
  17166. private _noiseTexture;
  17167. /**
  17168. * Gets or sets a texture used to add random noise to particle positions
  17169. */
  17170. noiseTexture: Nullable<ProceduralTexture>;
  17171. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17172. noiseStrength: Vector3;
  17173. /**
  17174. * Callback triggered when the particle animation is ending.
  17175. */
  17176. onAnimationEnd: Nullable<() => void>;
  17177. /**
  17178. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17179. */
  17180. blendMode: number;
  17181. /**
  17182. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17183. * to override the particles.
  17184. */
  17185. forceDepthWrite: boolean;
  17186. /** 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 */
  17187. preWarmCycles: number;
  17188. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17189. preWarmStepOffset: number;
  17190. /**
  17191. * 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)
  17192. */
  17193. spriteCellChangeSpeed: number;
  17194. /**
  17195. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17196. */
  17197. startSpriteCellID: number;
  17198. /**
  17199. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17200. */
  17201. endSpriteCellID: number;
  17202. /**
  17203. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17204. */
  17205. spriteCellWidth: number;
  17206. /**
  17207. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17208. */
  17209. spriteCellHeight: number;
  17210. /**
  17211. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17212. */
  17213. spriteRandomStartCell: boolean;
  17214. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17215. translationPivot: Vector2;
  17216. /** @hidden */
  17217. protected _isAnimationSheetEnabled: boolean;
  17218. /**
  17219. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17220. */
  17221. beginAnimationOnStart: boolean;
  17222. /**
  17223. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17224. */
  17225. beginAnimationFrom: number;
  17226. /**
  17227. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17228. */
  17229. beginAnimationTo: number;
  17230. /**
  17231. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17232. */
  17233. beginAnimationLoop: boolean;
  17234. /**
  17235. * Gets or sets a world offset applied to all particles
  17236. */
  17237. worldOffset: Vector3;
  17238. /**
  17239. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17240. */
  17241. isAnimationSheetEnabled: boolean;
  17242. /**
  17243. * Get hosting scene
  17244. * @returns the scene
  17245. */
  17246. getScene(): Scene;
  17247. /**
  17248. * You can use gravity if you want to give an orientation to your particles.
  17249. */
  17250. gravity: Vector3;
  17251. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17252. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17253. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17254. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17255. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17256. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17257. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17258. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17259. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17260. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17261. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17262. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17263. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17264. /**
  17265. * Defines the delay in milliseconds before starting the system (0 by default)
  17266. */
  17267. startDelay: number;
  17268. /**
  17269. * Gets the current list of drag gradients.
  17270. * You must use addDragGradient and removeDragGradient to udpate this list
  17271. * @returns the list of drag gradients
  17272. */
  17273. getDragGradients(): Nullable<Array<FactorGradient>>;
  17274. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17275. limitVelocityDamping: number;
  17276. /**
  17277. * Gets the current list of limit velocity gradients.
  17278. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17279. * @returns the list of limit velocity gradients
  17280. */
  17281. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17282. /**
  17283. * Gets the current list of color gradients.
  17284. * You must use addColorGradient and removeColorGradient to udpate this list
  17285. * @returns the list of color gradients
  17286. */
  17287. getColorGradients(): Nullable<Array<ColorGradient>>;
  17288. /**
  17289. * Gets the current list of size gradients.
  17290. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17291. * @returns the list of size gradients
  17292. */
  17293. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17294. /**
  17295. * Gets the current list of color remap gradients.
  17296. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17297. * @returns the list of color remap gradients
  17298. */
  17299. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17300. /**
  17301. * Gets the current list of alpha remap gradients.
  17302. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17303. * @returns the list of alpha remap gradients
  17304. */
  17305. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17306. /**
  17307. * Gets the current list of life time gradients.
  17308. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17309. * @returns the list of life time gradients
  17310. */
  17311. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17312. /**
  17313. * Gets the current list of angular speed gradients.
  17314. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17315. * @returns the list of angular speed gradients
  17316. */
  17317. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17318. /**
  17319. * Gets the current list of velocity gradients.
  17320. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17321. * @returns the list of velocity gradients
  17322. */
  17323. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17324. /**
  17325. * Gets the current list of start size gradients.
  17326. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17327. * @returns the list of start size gradients
  17328. */
  17329. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17330. /**
  17331. * Gets the current list of emit rate gradients.
  17332. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17333. * @returns the list of emit rate gradients
  17334. */
  17335. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17336. /**
  17337. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17338. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17339. */
  17340. direction1: Vector3;
  17341. /**
  17342. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17343. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17344. */
  17345. direction2: Vector3;
  17346. /**
  17347. * 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.
  17348. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17349. */
  17350. minEmitBox: Vector3;
  17351. /**
  17352. * 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.
  17353. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17354. */
  17355. maxEmitBox: Vector3;
  17356. /**
  17357. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17358. */
  17359. color1: Color4;
  17360. /**
  17361. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17362. */
  17363. color2: Color4;
  17364. /**
  17365. * Color the particle will have at the end of its lifetime
  17366. */
  17367. colorDead: Color4;
  17368. /**
  17369. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17370. */
  17371. textureMask: Color4;
  17372. /**
  17373. * The particle emitter type defines the emitter used by the particle system.
  17374. * It can be for example box, sphere, or cone...
  17375. */
  17376. particleEmitterType: IParticleEmitterType;
  17377. /** @hidden */
  17378. _isSubEmitter: boolean;
  17379. /**
  17380. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17381. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17382. */
  17383. billboardMode: number;
  17384. protected _isBillboardBased: boolean;
  17385. /**
  17386. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17387. */
  17388. isBillboardBased: boolean;
  17389. /**
  17390. * The scene the particle system belongs to.
  17391. */
  17392. protected _scene: Scene;
  17393. /**
  17394. * Local cache of defines for image processing.
  17395. */
  17396. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17397. /**
  17398. * Default configuration related to image processing available in the standard Material.
  17399. */
  17400. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17401. /**
  17402. * Gets the image processing configuration used either in this material.
  17403. */
  17404. /**
  17405. * Sets the Default image processing configuration used either in the this material.
  17406. *
  17407. * If sets to null, the scene one is in use.
  17408. */
  17409. imageProcessingConfiguration: ImageProcessingConfiguration;
  17410. /**
  17411. * Attaches a new image processing configuration to the Standard Material.
  17412. * @param configuration
  17413. */
  17414. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17415. /** @hidden */
  17416. protected _reset(): void;
  17417. /** @hidden */
  17418. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17419. /**
  17420. * Instantiates a particle system.
  17421. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17422. * @param name The name of the particle system
  17423. */
  17424. constructor(name: string);
  17425. /**
  17426. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17427. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17428. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17429. * @returns the emitter
  17430. */
  17431. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17432. /**
  17433. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17434. * @param radius The radius of the hemisphere to emit from
  17435. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17436. * @returns the emitter
  17437. */
  17438. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17439. /**
  17440. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17441. * @param radius The radius of the sphere to emit from
  17442. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17443. * @returns the emitter
  17444. */
  17445. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17446. /**
  17447. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17448. * @param radius The radius of the sphere to emit from
  17449. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17450. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17451. * @returns the emitter
  17452. */
  17453. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17454. /**
  17455. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17456. * @param radius The radius of the emission cylinder
  17457. * @param height The height of the emission cylinder
  17458. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17459. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17460. * @returns the emitter
  17461. */
  17462. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17463. /**
  17464. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17465. * @param radius The radius of the cylinder to emit from
  17466. * @param height The height of the emission cylinder
  17467. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17468. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17469. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17470. * @returns the emitter
  17471. */
  17472. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17473. /**
  17474. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17475. * @param radius The radius of the cone to emit from
  17476. * @param angle The base angle of the cone
  17477. * @returns the emitter
  17478. */
  17479. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17480. /**
  17481. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17482. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17483. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17484. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17485. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17486. * @returns the emitter
  17487. */
  17488. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17489. }
  17490. }
  17491. declare module "babylonjs/Particles/subEmitter" {
  17492. import { Scene } from "babylonjs/scene";
  17493. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17494. /**
  17495. * Type of sub emitter
  17496. */
  17497. export enum SubEmitterType {
  17498. /**
  17499. * Attached to the particle over it's lifetime
  17500. */
  17501. ATTACHED = 0,
  17502. /**
  17503. * Created when the particle dies
  17504. */
  17505. END = 1
  17506. }
  17507. /**
  17508. * Sub emitter class used to emit particles from an existing particle
  17509. */
  17510. export class SubEmitter {
  17511. /**
  17512. * the particle system to be used by the sub emitter
  17513. */
  17514. particleSystem: ParticleSystem;
  17515. /**
  17516. * Type of the submitter (Default: END)
  17517. */
  17518. type: SubEmitterType;
  17519. /**
  17520. * 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)
  17521. * Note: This only is supported when using an emitter of type Mesh
  17522. */
  17523. inheritDirection: boolean;
  17524. /**
  17525. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17526. */
  17527. inheritedVelocityAmount: number;
  17528. /**
  17529. * Creates a sub emitter
  17530. * @param particleSystem the particle system to be used by the sub emitter
  17531. */
  17532. constructor(
  17533. /**
  17534. * the particle system to be used by the sub emitter
  17535. */
  17536. particleSystem: ParticleSystem);
  17537. /**
  17538. * Clones the sub emitter
  17539. * @returns the cloned sub emitter
  17540. */
  17541. clone(): SubEmitter;
  17542. /**
  17543. * Serialize current object to a JSON object
  17544. * @returns the serialized object
  17545. */
  17546. serialize(): any;
  17547. /** @hidden */
  17548. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17549. /**
  17550. * Creates a new SubEmitter from a serialized JSON version
  17551. * @param serializationObject defines the JSON object to read from
  17552. * @param scene defines the hosting scene
  17553. * @param rootUrl defines the rootUrl for data loading
  17554. * @returns a new SubEmitter
  17555. */
  17556. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17557. /** Release associated resources */
  17558. dispose(): void;
  17559. }
  17560. }
  17561. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17562. /** @hidden */
  17563. export var clipPlaneFragmentDeclaration: {
  17564. name: string;
  17565. shader: string;
  17566. };
  17567. }
  17568. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17569. /** @hidden */
  17570. export var imageProcessingDeclaration: {
  17571. name: string;
  17572. shader: string;
  17573. };
  17574. }
  17575. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17576. /** @hidden */
  17577. export var imageProcessingFunctions: {
  17578. name: string;
  17579. shader: string;
  17580. };
  17581. }
  17582. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17583. /** @hidden */
  17584. export var clipPlaneFragment: {
  17585. name: string;
  17586. shader: string;
  17587. };
  17588. }
  17589. declare module "babylonjs/Shaders/particles.fragment" {
  17590. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17591. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17592. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17593. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17594. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17595. /** @hidden */
  17596. export var particlesPixelShader: {
  17597. name: string;
  17598. shader: string;
  17599. };
  17600. }
  17601. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17602. /** @hidden */
  17603. export var clipPlaneVertexDeclaration: {
  17604. name: string;
  17605. shader: string;
  17606. };
  17607. }
  17608. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17609. /** @hidden */
  17610. export var clipPlaneVertex: {
  17611. name: string;
  17612. shader: string;
  17613. };
  17614. }
  17615. declare module "babylonjs/Shaders/particles.vertex" {
  17616. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17617. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17618. /** @hidden */
  17619. export var particlesVertexShader: {
  17620. name: string;
  17621. shader: string;
  17622. };
  17623. }
  17624. declare module "babylonjs/Particles/particleSystem" {
  17625. import { Nullable } from "babylonjs/types";
  17626. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17627. import { Observable } from "babylonjs/Misc/observable";
  17628. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17629. import { Effect } from "babylonjs/Materials/effect";
  17630. import { Scene, IDisposable } from "babylonjs/scene";
  17631. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17632. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17633. import { Particle } from "babylonjs/Particles/particle";
  17634. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17635. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17636. import "babylonjs/Shaders/particles.fragment";
  17637. import "babylonjs/Shaders/particles.vertex";
  17638. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17639. /**
  17640. * This represents a particle system in Babylon.
  17641. * 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.
  17642. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17643. * @example https://doc.babylonjs.com/babylon101/particles
  17644. */
  17645. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17646. /**
  17647. * Billboard mode will only apply to Y axis
  17648. */
  17649. static readonly BILLBOARDMODE_Y: number;
  17650. /**
  17651. * Billboard mode will apply to all axes
  17652. */
  17653. static readonly BILLBOARDMODE_ALL: number;
  17654. /**
  17655. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17656. */
  17657. static readonly BILLBOARDMODE_STRETCHED: number;
  17658. /**
  17659. * This function can be defined to provide custom update for active particles.
  17660. * This function will be called instead of regular update (age, position, color, etc.).
  17661. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17662. */
  17663. updateFunction: (particles: Particle[]) => void;
  17664. private _emitterWorldMatrix;
  17665. /**
  17666. * This function can be defined to specify initial direction for every new particle.
  17667. * It by default use the emitterType defined function
  17668. */
  17669. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17670. /**
  17671. * This function can be defined to specify initial position for every new particle.
  17672. * It by default use the emitterType defined function
  17673. */
  17674. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17675. /**
  17676. * @hidden
  17677. */
  17678. _inheritedVelocityOffset: Vector3;
  17679. /**
  17680. * An event triggered when the system is disposed
  17681. */
  17682. onDisposeObservable: Observable<ParticleSystem>;
  17683. private _onDisposeObserver;
  17684. /**
  17685. * Sets a callback that will be triggered when the system is disposed
  17686. */
  17687. onDispose: () => void;
  17688. private _particles;
  17689. private _epsilon;
  17690. private _capacity;
  17691. private _stockParticles;
  17692. private _newPartsExcess;
  17693. private _vertexData;
  17694. private _vertexBuffer;
  17695. private _vertexBuffers;
  17696. private _spriteBuffer;
  17697. private _indexBuffer;
  17698. private _effect;
  17699. private _customEffect;
  17700. private _cachedDefines;
  17701. private _scaledColorStep;
  17702. private _colorDiff;
  17703. private _scaledDirection;
  17704. private _scaledGravity;
  17705. private _currentRenderId;
  17706. private _alive;
  17707. private _useInstancing;
  17708. private _started;
  17709. private _stopped;
  17710. private _actualFrame;
  17711. private _scaledUpdateSpeed;
  17712. private _vertexBufferSize;
  17713. /** @hidden */
  17714. _currentEmitRateGradient: Nullable<FactorGradient>;
  17715. /** @hidden */
  17716. _currentEmitRate1: number;
  17717. /** @hidden */
  17718. _currentEmitRate2: number;
  17719. /** @hidden */
  17720. _currentStartSizeGradient: Nullable<FactorGradient>;
  17721. /** @hidden */
  17722. _currentStartSize1: number;
  17723. /** @hidden */
  17724. _currentStartSize2: number;
  17725. private readonly _rawTextureWidth;
  17726. private _rampGradientsTexture;
  17727. private _useRampGradients;
  17728. /** Gets or sets a boolean indicating that ramp gradients must be used
  17729. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17730. */
  17731. useRampGradients: boolean;
  17732. /**
  17733. * 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.
  17734. * 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: [])
  17735. */
  17736. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17737. private _subEmitters;
  17738. /**
  17739. * @hidden
  17740. * If the particle systems emitter should be disposed when the particle system is disposed
  17741. */
  17742. _disposeEmitterOnDispose: boolean;
  17743. /**
  17744. * The current active Sub-systems, this property is used by the root particle system only.
  17745. */
  17746. activeSubSystems: Array<ParticleSystem>;
  17747. private _rootParticleSystem;
  17748. /**
  17749. * Gets the current list of active particles
  17750. */
  17751. readonly particles: Particle[];
  17752. /**
  17753. * Returns the string "ParticleSystem"
  17754. * @returns a string containing the class name
  17755. */
  17756. getClassName(): string;
  17757. /**
  17758. * Instantiates a particle system.
  17759. * 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.
  17760. * @param name The name of the particle system
  17761. * @param capacity The max number of particles alive at the same time
  17762. * @param scene The scene the particle system belongs to
  17763. * @param customEffect a custom effect used to change the way particles are rendered by default
  17764. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17765. * @param epsilon Offset used to render the particles
  17766. */
  17767. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17768. private _addFactorGradient;
  17769. private _removeFactorGradient;
  17770. /**
  17771. * Adds a new life time gradient
  17772. * @param gradient defines the gradient to use (between 0 and 1)
  17773. * @param factor defines the life time factor to affect to the specified gradient
  17774. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17775. * @returns the current particle system
  17776. */
  17777. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17778. /**
  17779. * Remove a specific life time gradient
  17780. * @param gradient defines the gradient to remove
  17781. * @returns the current particle system
  17782. */
  17783. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17784. /**
  17785. * Adds a new size gradient
  17786. * @param gradient defines the gradient to use (between 0 and 1)
  17787. * @param factor defines the size factor to affect to the specified gradient
  17788. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17789. * @returns the current particle system
  17790. */
  17791. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17792. /**
  17793. * Remove a specific size gradient
  17794. * @param gradient defines the gradient to remove
  17795. * @returns the current particle system
  17796. */
  17797. removeSizeGradient(gradient: number): IParticleSystem;
  17798. /**
  17799. * Adds a new color remap gradient
  17800. * @param gradient defines the gradient to use (between 0 and 1)
  17801. * @param min defines the color remap minimal range
  17802. * @param max defines the color remap maximal range
  17803. * @returns the current particle system
  17804. */
  17805. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17806. /**
  17807. * Remove a specific color remap gradient
  17808. * @param gradient defines the gradient to remove
  17809. * @returns the current particle system
  17810. */
  17811. removeColorRemapGradient(gradient: number): IParticleSystem;
  17812. /**
  17813. * Adds a new alpha remap gradient
  17814. * @param gradient defines the gradient to use (between 0 and 1)
  17815. * @param min defines the alpha remap minimal range
  17816. * @param max defines the alpha remap maximal range
  17817. * @returns the current particle system
  17818. */
  17819. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17820. /**
  17821. * Remove a specific alpha remap gradient
  17822. * @param gradient defines the gradient to remove
  17823. * @returns the current particle system
  17824. */
  17825. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17826. /**
  17827. * Adds a new angular speed gradient
  17828. * @param gradient defines the gradient to use (between 0 and 1)
  17829. * @param factor defines the angular speed to affect to the specified gradient
  17830. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17831. * @returns the current particle system
  17832. */
  17833. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17834. /**
  17835. * Remove a specific angular speed gradient
  17836. * @param gradient defines the gradient to remove
  17837. * @returns the current particle system
  17838. */
  17839. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17840. /**
  17841. * Adds a new velocity gradient
  17842. * @param gradient defines the gradient to use (between 0 and 1)
  17843. * @param factor defines the velocity to affect to the specified gradient
  17844. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17845. * @returns the current particle system
  17846. */
  17847. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17848. /**
  17849. * Remove a specific velocity gradient
  17850. * @param gradient defines the gradient to remove
  17851. * @returns the current particle system
  17852. */
  17853. removeVelocityGradient(gradient: number): IParticleSystem;
  17854. /**
  17855. * Adds a new limit velocity gradient
  17856. * @param gradient defines the gradient to use (between 0 and 1)
  17857. * @param factor defines the limit velocity value to affect to the specified gradient
  17858. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17859. * @returns the current particle system
  17860. */
  17861. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17862. /**
  17863. * Remove a specific limit velocity gradient
  17864. * @param gradient defines the gradient to remove
  17865. * @returns the current particle system
  17866. */
  17867. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17868. /**
  17869. * Adds a new drag gradient
  17870. * @param gradient defines the gradient to use (between 0 and 1)
  17871. * @param factor defines the drag value to affect to the specified gradient
  17872. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17873. * @returns the current particle system
  17874. */
  17875. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17876. /**
  17877. * Remove a specific drag gradient
  17878. * @param gradient defines the gradient to remove
  17879. * @returns the current particle system
  17880. */
  17881. removeDragGradient(gradient: number): IParticleSystem;
  17882. /**
  17883. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17884. * @param gradient defines the gradient to use (between 0 and 1)
  17885. * @param factor defines the emit rate value to affect to the specified gradient
  17886. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17887. * @returns the current particle system
  17888. */
  17889. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17890. /**
  17891. * Remove a specific emit rate gradient
  17892. * @param gradient defines the gradient to remove
  17893. * @returns the current particle system
  17894. */
  17895. removeEmitRateGradient(gradient: number): IParticleSystem;
  17896. /**
  17897. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17898. * @param gradient defines the gradient to use (between 0 and 1)
  17899. * @param factor defines the start size value to affect to the specified gradient
  17900. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17901. * @returns the current particle system
  17902. */
  17903. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17904. /**
  17905. * Remove a specific start size gradient
  17906. * @param gradient defines the gradient to remove
  17907. * @returns the current particle system
  17908. */
  17909. removeStartSizeGradient(gradient: number): IParticleSystem;
  17910. private _createRampGradientTexture;
  17911. /**
  17912. * Gets the current list of ramp gradients.
  17913. * You must use addRampGradient and removeRampGradient to udpate this list
  17914. * @returns the list of ramp gradients
  17915. */
  17916. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17917. /**
  17918. * Adds a new ramp gradient used to remap particle colors
  17919. * @param gradient defines the gradient to use (between 0 and 1)
  17920. * @param color defines the color to affect to the specified gradient
  17921. * @returns the current particle system
  17922. */
  17923. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17924. /**
  17925. * Remove a specific ramp gradient
  17926. * @param gradient defines the gradient to remove
  17927. * @returns the current particle system
  17928. */
  17929. removeRampGradient(gradient: number): ParticleSystem;
  17930. /**
  17931. * Adds a new color gradient
  17932. * @param gradient defines the gradient to use (between 0 and 1)
  17933. * @param color1 defines the color to affect to the specified gradient
  17934. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17935. * @returns this particle system
  17936. */
  17937. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17938. /**
  17939. * Remove a specific color gradient
  17940. * @param gradient defines the gradient to remove
  17941. * @returns this particle system
  17942. */
  17943. removeColorGradient(gradient: number): IParticleSystem;
  17944. private _fetchR;
  17945. protected _reset(): void;
  17946. private _resetEffect;
  17947. private _createVertexBuffers;
  17948. private _createIndexBuffer;
  17949. /**
  17950. * Gets the maximum number of particles active at the same time.
  17951. * @returns The max number of active particles.
  17952. */
  17953. getCapacity(): number;
  17954. /**
  17955. * Gets whether there are still active particles in the system.
  17956. * @returns True if it is alive, otherwise false.
  17957. */
  17958. isAlive(): boolean;
  17959. /**
  17960. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17961. * @returns True if it has been started, otherwise false.
  17962. */
  17963. isStarted(): boolean;
  17964. private _prepareSubEmitterInternalArray;
  17965. /**
  17966. * Starts the particle system and begins to emit
  17967. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17968. */
  17969. start(delay?: number): void;
  17970. /**
  17971. * Stops the particle system.
  17972. * @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.
  17973. */
  17974. stop(stopSubEmitters?: boolean): void;
  17975. /**
  17976. * Remove all active particles
  17977. */
  17978. reset(): void;
  17979. /**
  17980. * @hidden (for internal use only)
  17981. */
  17982. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17983. /**
  17984. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17985. * Its lifetime will start back at 0.
  17986. */
  17987. recycleParticle: (particle: Particle) => void;
  17988. private _stopSubEmitters;
  17989. private _createParticle;
  17990. private _removeFromRoot;
  17991. private _emitFromParticle;
  17992. private _update;
  17993. /** @hidden */
  17994. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17995. /** @hidden */
  17996. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17997. /** @hidden */
  17998. private _getEffect;
  17999. /**
  18000. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18001. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18002. */
  18003. animate(preWarmOnly?: boolean): void;
  18004. private _appendParticleVertices;
  18005. /**
  18006. * Rebuilds the particle system.
  18007. */
  18008. rebuild(): void;
  18009. /**
  18010. * Is this system ready to be used/rendered
  18011. * @return true if the system is ready
  18012. */
  18013. isReady(): boolean;
  18014. private _render;
  18015. /**
  18016. * Renders the particle system in its current state.
  18017. * @returns the current number of particles
  18018. */
  18019. render(): number;
  18020. /**
  18021. * Disposes the particle system and free the associated resources
  18022. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18023. */
  18024. dispose(disposeTexture?: boolean): void;
  18025. /**
  18026. * Clones the particle system.
  18027. * @param name The name of the cloned object
  18028. * @param newEmitter The new emitter to use
  18029. * @returns the cloned particle system
  18030. */
  18031. clone(name: string, newEmitter: any): ParticleSystem;
  18032. /**
  18033. * Serializes the particle system to a JSON object.
  18034. * @returns the JSON object
  18035. */
  18036. serialize(): any;
  18037. /** @hidden */
  18038. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18039. /** @hidden */
  18040. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18041. /**
  18042. * Parses a JSON object to create a particle system.
  18043. * @param parsedParticleSystem The JSON object to parse
  18044. * @param scene The scene to create the particle system in
  18045. * @param rootUrl The root url to use to load external dependencies like texture
  18046. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18047. * @returns the Parsed particle system
  18048. */
  18049. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18050. }
  18051. }
  18052. declare module "babylonjs/Particles/particle" {
  18053. import { Nullable } from "babylonjs/types";
  18054. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18055. import { Color4 } from "babylonjs/Maths/math.color";
  18056. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18057. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18058. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18059. /**
  18060. * A particle represents one of the element emitted by a particle system.
  18061. * This is mainly define by its coordinates, direction, velocity and age.
  18062. */
  18063. export class Particle {
  18064. /**
  18065. * The particle system the particle belongs to.
  18066. */
  18067. particleSystem: ParticleSystem;
  18068. private static _Count;
  18069. /**
  18070. * Unique ID of the particle
  18071. */
  18072. id: number;
  18073. /**
  18074. * The world position of the particle in the scene.
  18075. */
  18076. position: Vector3;
  18077. /**
  18078. * The world direction of the particle in the scene.
  18079. */
  18080. direction: Vector3;
  18081. /**
  18082. * The color of the particle.
  18083. */
  18084. color: Color4;
  18085. /**
  18086. * The color change of the particle per step.
  18087. */
  18088. colorStep: Color4;
  18089. /**
  18090. * Defines how long will the life of the particle be.
  18091. */
  18092. lifeTime: number;
  18093. /**
  18094. * The current age of the particle.
  18095. */
  18096. age: number;
  18097. /**
  18098. * The current size of the particle.
  18099. */
  18100. size: number;
  18101. /**
  18102. * The current scale of the particle.
  18103. */
  18104. scale: Vector2;
  18105. /**
  18106. * The current angle of the particle.
  18107. */
  18108. angle: number;
  18109. /**
  18110. * Defines how fast is the angle changing.
  18111. */
  18112. angularSpeed: number;
  18113. /**
  18114. * Defines the cell index used by the particle to be rendered from a sprite.
  18115. */
  18116. cellIndex: number;
  18117. /**
  18118. * The information required to support color remapping
  18119. */
  18120. remapData: Vector4;
  18121. /** @hidden */
  18122. _randomCellOffset?: number;
  18123. /** @hidden */
  18124. _initialDirection: Nullable<Vector3>;
  18125. /** @hidden */
  18126. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18127. /** @hidden */
  18128. _initialStartSpriteCellID: number;
  18129. /** @hidden */
  18130. _initialEndSpriteCellID: number;
  18131. /** @hidden */
  18132. _currentColorGradient: Nullable<ColorGradient>;
  18133. /** @hidden */
  18134. _currentColor1: Color4;
  18135. /** @hidden */
  18136. _currentColor2: Color4;
  18137. /** @hidden */
  18138. _currentSizeGradient: Nullable<FactorGradient>;
  18139. /** @hidden */
  18140. _currentSize1: number;
  18141. /** @hidden */
  18142. _currentSize2: number;
  18143. /** @hidden */
  18144. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18145. /** @hidden */
  18146. _currentAngularSpeed1: number;
  18147. /** @hidden */
  18148. _currentAngularSpeed2: number;
  18149. /** @hidden */
  18150. _currentVelocityGradient: Nullable<FactorGradient>;
  18151. /** @hidden */
  18152. _currentVelocity1: number;
  18153. /** @hidden */
  18154. _currentVelocity2: number;
  18155. /** @hidden */
  18156. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18157. /** @hidden */
  18158. _currentLimitVelocity1: number;
  18159. /** @hidden */
  18160. _currentLimitVelocity2: number;
  18161. /** @hidden */
  18162. _currentDragGradient: Nullable<FactorGradient>;
  18163. /** @hidden */
  18164. _currentDrag1: number;
  18165. /** @hidden */
  18166. _currentDrag2: number;
  18167. /** @hidden */
  18168. _randomNoiseCoordinates1: Vector3;
  18169. /** @hidden */
  18170. _randomNoiseCoordinates2: Vector3;
  18171. /**
  18172. * Creates a new instance Particle
  18173. * @param particleSystem the particle system the particle belongs to
  18174. */
  18175. constructor(
  18176. /**
  18177. * The particle system the particle belongs to.
  18178. */
  18179. particleSystem: ParticleSystem);
  18180. private updateCellInfoFromSystem;
  18181. /**
  18182. * Defines how the sprite cell index is updated for the particle
  18183. */
  18184. updateCellIndex(): void;
  18185. /** @hidden */
  18186. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18187. /** @hidden */
  18188. _inheritParticleInfoToSubEmitters(): void;
  18189. /** @hidden */
  18190. _reset(): void;
  18191. /**
  18192. * Copy the properties of particle to another one.
  18193. * @param other the particle to copy the information to.
  18194. */
  18195. copyTo(other: Particle): void;
  18196. }
  18197. }
  18198. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18199. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18200. import { Effect } from "babylonjs/Materials/effect";
  18201. import { Particle } from "babylonjs/Particles/particle";
  18202. /**
  18203. * Particle emitter represents a volume emitting particles.
  18204. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18205. */
  18206. export interface IParticleEmitterType {
  18207. /**
  18208. * Called by the particle System when the direction is computed for the created particle.
  18209. * @param worldMatrix is the world matrix of the particle system
  18210. * @param directionToUpdate is the direction vector to update with the result
  18211. * @param particle is the particle we are computed the direction for
  18212. */
  18213. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18214. /**
  18215. * Called by the particle System when the position is computed for the created particle.
  18216. * @param worldMatrix is the world matrix of the particle system
  18217. * @param positionToUpdate is the position vector to update with the result
  18218. * @param particle is the particle we are computed the position for
  18219. */
  18220. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18221. /**
  18222. * Clones the current emitter and returns a copy of it
  18223. * @returns the new emitter
  18224. */
  18225. clone(): IParticleEmitterType;
  18226. /**
  18227. * Called by the GPUParticleSystem to setup the update shader
  18228. * @param effect defines the update shader
  18229. */
  18230. applyToShader(effect: Effect): void;
  18231. /**
  18232. * Returns a string to use to update the GPU particles update shader
  18233. * @returns the effect defines string
  18234. */
  18235. getEffectDefines(): string;
  18236. /**
  18237. * Returns a string representing the class name
  18238. * @returns a string containing the class name
  18239. */
  18240. getClassName(): string;
  18241. /**
  18242. * Serializes the particle system to a JSON object.
  18243. * @returns the JSON object
  18244. */
  18245. serialize(): any;
  18246. /**
  18247. * Parse properties from a JSON object
  18248. * @param serializationObject defines the JSON object
  18249. */
  18250. parse(serializationObject: any): void;
  18251. }
  18252. }
  18253. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18254. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18255. import { Effect } from "babylonjs/Materials/effect";
  18256. import { Particle } from "babylonjs/Particles/particle";
  18257. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18258. /**
  18259. * Particle emitter emitting particles from the inside of a box.
  18260. * It emits the particles randomly between 2 given directions.
  18261. */
  18262. export class BoxParticleEmitter implements IParticleEmitterType {
  18263. /**
  18264. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18265. */
  18266. direction1: Vector3;
  18267. /**
  18268. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18269. */
  18270. direction2: Vector3;
  18271. /**
  18272. * 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.
  18273. */
  18274. minEmitBox: Vector3;
  18275. /**
  18276. * 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.
  18277. */
  18278. maxEmitBox: Vector3;
  18279. /**
  18280. * Creates a new instance BoxParticleEmitter
  18281. */
  18282. constructor();
  18283. /**
  18284. * Called by the particle System when the direction is computed for the created particle.
  18285. * @param worldMatrix is the world matrix of the particle system
  18286. * @param directionToUpdate is the direction vector to update with the result
  18287. * @param particle is the particle we are computed the direction for
  18288. */
  18289. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18290. /**
  18291. * Called by the particle System when the position is computed for the created particle.
  18292. * @param worldMatrix is the world matrix of the particle system
  18293. * @param positionToUpdate is the position vector to update with the result
  18294. * @param particle is the particle we are computed the position for
  18295. */
  18296. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18297. /**
  18298. * Clones the current emitter and returns a copy of it
  18299. * @returns the new emitter
  18300. */
  18301. clone(): BoxParticleEmitter;
  18302. /**
  18303. * Called by the GPUParticleSystem to setup the update shader
  18304. * @param effect defines the update shader
  18305. */
  18306. applyToShader(effect: Effect): void;
  18307. /**
  18308. * Returns a string to use to update the GPU particles update shader
  18309. * @returns a string containng the defines string
  18310. */
  18311. getEffectDefines(): string;
  18312. /**
  18313. * Returns the string "BoxParticleEmitter"
  18314. * @returns a string containing the class name
  18315. */
  18316. getClassName(): string;
  18317. /**
  18318. * Serializes the particle system to a JSON object.
  18319. * @returns the JSON object
  18320. */
  18321. serialize(): any;
  18322. /**
  18323. * Parse properties from a JSON object
  18324. * @param serializationObject defines the JSON object
  18325. */
  18326. parse(serializationObject: any): void;
  18327. }
  18328. }
  18329. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18330. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18331. import { Effect } from "babylonjs/Materials/effect";
  18332. import { Particle } from "babylonjs/Particles/particle";
  18333. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18334. /**
  18335. * Particle emitter emitting particles from the inside of a cone.
  18336. * It emits the particles alongside the cone volume from the base to the particle.
  18337. * The emission direction might be randomized.
  18338. */
  18339. export class ConeParticleEmitter implements IParticleEmitterType {
  18340. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18341. directionRandomizer: number;
  18342. private _radius;
  18343. private _angle;
  18344. private _height;
  18345. /**
  18346. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18347. */
  18348. radiusRange: number;
  18349. /**
  18350. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18351. */
  18352. heightRange: number;
  18353. /**
  18354. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18355. */
  18356. emitFromSpawnPointOnly: boolean;
  18357. /**
  18358. * Gets or sets the radius of the emission cone
  18359. */
  18360. radius: number;
  18361. /**
  18362. * Gets or sets the angle of the emission cone
  18363. */
  18364. angle: number;
  18365. private _buildHeight;
  18366. /**
  18367. * Creates a new instance ConeParticleEmitter
  18368. * @param radius the radius of the emission cone (1 by default)
  18369. * @param angle the cone base angle (PI by default)
  18370. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18371. */
  18372. constructor(radius?: number, angle?: number,
  18373. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18374. directionRandomizer?: number);
  18375. /**
  18376. * Called by the particle System when the direction is computed for the created particle.
  18377. * @param worldMatrix is the world matrix of the particle system
  18378. * @param directionToUpdate is the direction vector to update with the result
  18379. * @param particle is the particle we are computed the direction for
  18380. */
  18381. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18382. /**
  18383. * Called by the particle System when the position is computed for the created particle.
  18384. * @param worldMatrix is the world matrix of the particle system
  18385. * @param positionToUpdate is the position vector to update with the result
  18386. * @param particle is the particle we are computed the position for
  18387. */
  18388. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18389. /**
  18390. * Clones the current emitter and returns a copy of it
  18391. * @returns the new emitter
  18392. */
  18393. clone(): ConeParticleEmitter;
  18394. /**
  18395. * Called by the GPUParticleSystem to setup the update shader
  18396. * @param effect defines the update shader
  18397. */
  18398. applyToShader(effect: Effect): void;
  18399. /**
  18400. * Returns a string to use to update the GPU particles update shader
  18401. * @returns a string containng the defines string
  18402. */
  18403. getEffectDefines(): string;
  18404. /**
  18405. * Returns the string "ConeParticleEmitter"
  18406. * @returns a string containing the class name
  18407. */
  18408. getClassName(): string;
  18409. /**
  18410. * Serializes the particle system to a JSON object.
  18411. * @returns the JSON object
  18412. */
  18413. serialize(): any;
  18414. /**
  18415. * Parse properties from a JSON object
  18416. * @param serializationObject defines the JSON object
  18417. */
  18418. parse(serializationObject: any): void;
  18419. }
  18420. }
  18421. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18422. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18423. import { Effect } from "babylonjs/Materials/effect";
  18424. import { Particle } from "babylonjs/Particles/particle";
  18425. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18426. /**
  18427. * Particle emitter emitting particles from the inside of a cylinder.
  18428. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18429. */
  18430. export class CylinderParticleEmitter implements IParticleEmitterType {
  18431. /**
  18432. * The radius of the emission cylinder.
  18433. */
  18434. radius: number;
  18435. /**
  18436. * The height of the emission cylinder.
  18437. */
  18438. height: number;
  18439. /**
  18440. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18441. */
  18442. radiusRange: number;
  18443. /**
  18444. * How much to randomize the particle direction [0-1].
  18445. */
  18446. directionRandomizer: number;
  18447. /**
  18448. * Creates a new instance CylinderParticleEmitter
  18449. * @param radius the radius of the emission cylinder (1 by default)
  18450. * @param height the height of the emission cylinder (1 by default)
  18451. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18452. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18453. */
  18454. constructor(
  18455. /**
  18456. * The radius of the emission cylinder.
  18457. */
  18458. radius?: number,
  18459. /**
  18460. * The height of the emission cylinder.
  18461. */
  18462. height?: number,
  18463. /**
  18464. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18465. */
  18466. radiusRange?: number,
  18467. /**
  18468. * How much to randomize the particle direction [0-1].
  18469. */
  18470. directionRandomizer?: number);
  18471. /**
  18472. * Called by the particle System when the direction is computed for the created particle.
  18473. * @param worldMatrix is the world matrix of the particle system
  18474. * @param directionToUpdate is the direction vector to update with the result
  18475. * @param particle is the particle we are computed the direction for
  18476. */
  18477. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18478. /**
  18479. * Called by the particle System when the position is computed for the created particle.
  18480. * @param worldMatrix is the world matrix of the particle system
  18481. * @param positionToUpdate is the position vector to update with the result
  18482. * @param particle is the particle we are computed the position for
  18483. */
  18484. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18485. /**
  18486. * Clones the current emitter and returns a copy of it
  18487. * @returns the new emitter
  18488. */
  18489. clone(): CylinderParticleEmitter;
  18490. /**
  18491. * Called by the GPUParticleSystem to setup the update shader
  18492. * @param effect defines the update shader
  18493. */
  18494. applyToShader(effect: Effect): void;
  18495. /**
  18496. * Returns a string to use to update the GPU particles update shader
  18497. * @returns a string containng the defines string
  18498. */
  18499. getEffectDefines(): string;
  18500. /**
  18501. * Returns the string "CylinderParticleEmitter"
  18502. * @returns a string containing the class name
  18503. */
  18504. getClassName(): string;
  18505. /**
  18506. * Serializes the particle system to a JSON object.
  18507. * @returns the JSON object
  18508. */
  18509. serialize(): any;
  18510. /**
  18511. * Parse properties from a JSON object
  18512. * @param serializationObject defines the JSON object
  18513. */
  18514. parse(serializationObject: any): void;
  18515. }
  18516. /**
  18517. * Particle emitter emitting particles from the inside of a cylinder.
  18518. * It emits the particles randomly between two vectors.
  18519. */
  18520. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18521. /**
  18522. * The min limit of the emission direction.
  18523. */
  18524. direction1: Vector3;
  18525. /**
  18526. * The max limit of the emission direction.
  18527. */
  18528. direction2: Vector3;
  18529. /**
  18530. * Creates a new instance CylinderDirectedParticleEmitter
  18531. * @param radius the radius of the emission cylinder (1 by default)
  18532. * @param height the height of the emission cylinder (1 by default)
  18533. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18534. * @param direction1 the min limit of the emission direction (up vector by default)
  18535. * @param direction2 the max limit of the emission direction (up vector by default)
  18536. */
  18537. constructor(radius?: number, height?: number, radiusRange?: number,
  18538. /**
  18539. * The min limit of the emission direction.
  18540. */
  18541. direction1?: Vector3,
  18542. /**
  18543. * The max limit of the emission direction.
  18544. */
  18545. direction2?: Vector3);
  18546. /**
  18547. * Called by the particle System when the direction is computed for the created particle.
  18548. * @param worldMatrix is the world matrix of the particle system
  18549. * @param directionToUpdate is the direction vector to update with the result
  18550. * @param particle is the particle we are computed the direction for
  18551. */
  18552. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18553. /**
  18554. * Clones the current emitter and returns a copy of it
  18555. * @returns the new emitter
  18556. */
  18557. clone(): CylinderDirectedParticleEmitter;
  18558. /**
  18559. * Called by the GPUParticleSystem to setup the update shader
  18560. * @param effect defines the update shader
  18561. */
  18562. applyToShader(effect: Effect): void;
  18563. /**
  18564. * Returns a string to use to update the GPU particles update shader
  18565. * @returns a string containng the defines string
  18566. */
  18567. getEffectDefines(): string;
  18568. /**
  18569. * Returns the string "CylinderDirectedParticleEmitter"
  18570. * @returns a string containing the class name
  18571. */
  18572. getClassName(): string;
  18573. /**
  18574. * Serializes the particle system to a JSON object.
  18575. * @returns the JSON object
  18576. */
  18577. serialize(): any;
  18578. /**
  18579. * Parse properties from a JSON object
  18580. * @param serializationObject defines the JSON object
  18581. */
  18582. parse(serializationObject: any): void;
  18583. }
  18584. }
  18585. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18586. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18587. import { Effect } from "babylonjs/Materials/effect";
  18588. import { Particle } from "babylonjs/Particles/particle";
  18589. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18590. /**
  18591. * Particle emitter emitting particles from the inside of a hemisphere.
  18592. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18593. */
  18594. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18595. /**
  18596. * The radius of the emission hemisphere.
  18597. */
  18598. radius: number;
  18599. /**
  18600. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18601. */
  18602. radiusRange: number;
  18603. /**
  18604. * How much to randomize the particle direction [0-1].
  18605. */
  18606. directionRandomizer: number;
  18607. /**
  18608. * Creates a new instance HemisphericParticleEmitter
  18609. * @param radius the radius of the emission hemisphere (1 by default)
  18610. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18611. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18612. */
  18613. constructor(
  18614. /**
  18615. * The radius of the emission hemisphere.
  18616. */
  18617. radius?: number,
  18618. /**
  18619. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18620. */
  18621. radiusRange?: number,
  18622. /**
  18623. * How much to randomize the particle direction [0-1].
  18624. */
  18625. directionRandomizer?: number);
  18626. /**
  18627. * Called by the particle System when the direction is computed for the created particle.
  18628. * @param worldMatrix is the world matrix of the particle system
  18629. * @param directionToUpdate is the direction vector to update with the result
  18630. * @param particle is the particle we are computed the direction for
  18631. */
  18632. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18633. /**
  18634. * Called by the particle System when the position is computed for the created particle.
  18635. * @param worldMatrix is the world matrix of the particle system
  18636. * @param positionToUpdate is the position vector to update with the result
  18637. * @param particle is the particle we are computed the position for
  18638. */
  18639. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18640. /**
  18641. * Clones the current emitter and returns a copy of it
  18642. * @returns the new emitter
  18643. */
  18644. clone(): HemisphericParticleEmitter;
  18645. /**
  18646. * Called by the GPUParticleSystem to setup the update shader
  18647. * @param effect defines the update shader
  18648. */
  18649. applyToShader(effect: Effect): void;
  18650. /**
  18651. * Returns a string to use to update the GPU particles update shader
  18652. * @returns a string containng the defines string
  18653. */
  18654. getEffectDefines(): string;
  18655. /**
  18656. * Returns the string "HemisphericParticleEmitter"
  18657. * @returns a string containing the class name
  18658. */
  18659. getClassName(): string;
  18660. /**
  18661. * Serializes the particle system to a JSON object.
  18662. * @returns the JSON object
  18663. */
  18664. serialize(): any;
  18665. /**
  18666. * Parse properties from a JSON object
  18667. * @param serializationObject defines the JSON object
  18668. */
  18669. parse(serializationObject: any): void;
  18670. }
  18671. }
  18672. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18673. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18674. import { Effect } from "babylonjs/Materials/effect";
  18675. import { Particle } from "babylonjs/Particles/particle";
  18676. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18677. /**
  18678. * Particle emitter emitting particles from a point.
  18679. * It emits the particles randomly between 2 given directions.
  18680. */
  18681. export class PointParticleEmitter implements IParticleEmitterType {
  18682. /**
  18683. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18684. */
  18685. direction1: Vector3;
  18686. /**
  18687. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18688. */
  18689. direction2: Vector3;
  18690. /**
  18691. * Creates a new instance PointParticleEmitter
  18692. */
  18693. constructor();
  18694. /**
  18695. * Called by the particle System when the direction is computed for the created particle.
  18696. * @param worldMatrix is the world matrix of the particle system
  18697. * @param directionToUpdate is the direction vector to update with the result
  18698. * @param particle is the particle we are computed the direction for
  18699. */
  18700. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18701. /**
  18702. * Called by the particle System when the position is computed for the created particle.
  18703. * @param worldMatrix is the world matrix of the particle system
  18704. * @param positionToUpdate is the position vector to update with the result
  18705. * @param particle is the particle we are computed the position for
  18706. */
  18707. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18708. /**
  18709. * Clones the current emitter and returns a copy of it
  18710. * @returns the new emitter
  18711. */
  18712. clone(): PointParticleEmitter;
  18713. /**
  18714. * Called by the GPUParticleSystem to setup the update shader
  18715. * @param effect defines the update shader
  18716. */
  18717. applyToShader(effect: Effect): void;
  18718. /**
  18719. * Returns a string to use to update the GPU particles update shader
  18720. * @returns a string containng the defines string
  18721. */
  18722. getEffectDefines(): string;
  18723. /**
  18724. * Returns the string "PointParticleEmitter"
  18725. * @returns a string containing the class name
  18726. */
  18727. getClassName(): string;
  18728. /**
  18729. * Serializes the particle system to a JSON object.
  18730. * @returns the JSON object
  18731. */
  18732. serialize(): any;
  18733. /**
  18734. * Parse properties from a JSON object
  18735. * @param serializationObject defines the JSON object
  18736. */
  18737. parse(serializationObject: any): void;
  18738. }
  18739. }
  18740. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18741. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18742. import { Effect } from "babylonjs/Materials/effect";
  18743. import { Particle } from "babylonjs/Particles/particle";
  18744. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18745. /**
  18746. * Particle emitter emitting particles from the inside of a sphere.
  18747. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18748. */
  18749. export class SphereParticleEmitter implements IParticleEmitterType {
  18750. /**
  18751. * The radius of the emission sphere.
  18752. */
  18753. radius: number;
  18754. /**
  18755. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18756. */
  18757. radiusRange: number;
  18758. /**
  18759. * How much to randomize the particle direction [0-1].
  18760. */
  18761. directionRandomizer: number;
  18762. /**
  18763. * Creates a new instance SphereParticleEmitter
  18764. * @param radius the radius of the emission sphere (1 by default)
  18765. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18766. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18767. */
  18768. constructor(
  18769. /**
  18770. * The radius of the emission sphere.
  18771. */
  18772. radius?: number,
  18773. /**
  18774. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18775. */
  18776. radiusRange?: number,
  18777. /**
  18778. * How much to randomize the particle direction [0-1].
  18779. */
  18780. directionRandomizer?: number);
  18781. /**
  18782. * Called by the particle System when the direction is computed for the created particle.
  18783. * @param worldMatrix is the world matrix of the particle system
  18784. * @param directionToUpdate is the direction vector to update with the result
  18785. * @param particle is the particle we are computed the direction for
  18786. */
  18787. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18788. /**
  18789. * Called by the particle System when the position is computed for the created particle.
  18790. * @param worldMatrix is the world matrix of the particle system
  18791. * @param positionToUpdate is the position vector to update with the result
  18792. * @param particle is the particle we are computed the position for
  18793. */
  18794. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18795. /**
  18796. * Clones the current emitter and returns a copy of it
  18797. * @returns the new emitter
  18798. */
  18799. clone(): SphereParticleEmitter;
  18800. /**
  18801. * Called by the GPUParticleSystem to setup the update shader
  18802. * @param effect defines the update shader
  18803. */
  18804. applyToShader(effect: Effect): void;
  18805. /**
  18806. * Returns a string to use to update the GPU particles update shader
  18807. * @returns a string containng the defines string
  18808. */
  18809. getEffectDefines(): string;
  18810. /**
  18811. * Returns the string "SphereParticleEmitter"
  18812. * @returns a string containing the class name
  18813. */
  18814. getClassName(): string;
  18815. /**
  18816. * Serializes the particle system to a JSON object.
  18817. * @returns the JSON object
  18818. */
  18819. serialize(): any;
  18820. /**
  18821. * Parse properties from a JSON object
  18822. * @param serializationObject defines the JSON object
  18823. */
  18824. parse(serializationObject: any): void;
  18825. }
  18826. /**
  18827. * Particle emitter emitting particles from the inside of a sphere.
  18828. * It emits the particles randomly between two vectors.
  18829. */
  18830. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18831. /**
  18832. * The min limit of the emission direction.
  18833. */
  18834. direction1: Vector3;
  18835. /**
  18836. * The max limit of the emission direction.
  18837. */
  18838. direction2: Vector3;
  18839. /**
  18840. * Creates a new instance SphereDirectedParticleEmitter
  18841. * @param radius the radius of the emission sphere (1 by default)
  18842. * @param direction1 the min limit of the emission direction (up vector by default)
  18843. * @param direction2 the max limit of the emission direction (up vector by default)
  18844. */
  18845. constructor(radius?: number,
  18846. /**
  18847. * The min limit of the emission direction.
  18848. */
  18849. direction1?: Vector3,
  18850. /**
  18851. * The max limit of the emission direction.
  18852. */
  18853. direction2?: Vector3);
  18854. /**
  18855. * Called by the particle System when the direction is computed for the created particle.
  18856. * @param worldMatrix is the world matrix of the particle system
  18857. * @param directionToUpdate is the direction vector to update with the result
  18858. * @param particle is the particle we are computed the direction for
  18859. */
  18860. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18861. /**
  18862. * Clones the current emitter and returns a copy of it
  18863. * @returns the new emitter
  18864. */
  18865. clone(): SphereDirectedParticleEmitter;
  18866. /**
  18867. * Called by the GPUParticleSystem to setup the update shader
  18868. * @param effect defines the update shader
  18869. */
  18870. applyToShader(effect: Effect): void;
  18871. /**
  18872. * Returns a string to use to update the GPU particles update shader
  18873. * @returns a string containng the defines string
  18874. */
  18875. getEffectDefines(): string;
  18876. /**
  18877. * Returns the string "SphereDirectedParticleEmitter"
  18878. * @returns a string containing the class name
  18879. */
  18880. getClassName(): string;
  18881. /**
  18882. * Serializes the particle system to a JSON object.
  18883. * @returns the JSON object
  18884. */
  18885. serialize(): any;
  18886. /**
  18887. * Parse properties from a JSON object
  18888. * @param serializationObject defines the JSON object
  18889. */
  18890. parse(serializationObject: any): void;
  18891. }
  18892. }
  18893. declare module "babylonjs/Particles/EmitterTypes/index" {
  18894. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18895. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18896. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18897. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18898. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18899. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18900. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18901. }
  18902. declare module "babylonjs/Particles/IParticleSystem" {
  18903. import { Nullable } from "babylonjs/types";
  18904. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18905. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18907. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18908. import { Texture } from "babylonjs/Materials/Textures/texture";
  18909. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18910. import { Scene } from "babylonjs/scene";
  18911. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18912. import { Animation } from "babylonjs/Animations/animation";
  18913. /**
  18914. * Interface representing a particle system in Babylon.js.
  18915. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18916. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18917. */
  18918. export interface IParticleSystem {
  18919. /**
  18920. * List of animations used by the particle system.
  18921. */
  18922. animations: Animation[];
  18923. /**
  18924. * The id of the Particle system.
  18925. */
  18926. id: string;
  18927. /**
  18928. * The name of the Particle system.
  18929. */
  18930. name: string;
  18931. /**
  18932. * The emitter represents the Mesh or position we are attaching the particle system to.
  18933. */
  18934. emitter: Nullable<AbstractMesh | Vector3>;
  18935. /**
  18936. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18937. */
  18938. isBillboardBased: boolean;
  18939. /**
  18940. * The rendering group used by the Particle system to chose when to render.
  18941. */
  18942. renderingGroupId: number;
  18943. /**
  18944. * The layer mask we are rendering the particles through.
  18945. */
  18946. layerMask: number;
  18947. /**
  18948. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18949. */
  18950. updateSpeed: number;
  18951. /**
  18952. * The amount of time the particle system is running (depends of the overall update speed).
  18953. */
  18954. targetStopDuration: number;
  18955. /**
  18956. * The texture used to render each particle. (this can be a spritesheet)
  18957. */
  18958. particleTexture: Nullable<Texture>;
  18959. /**
  18960. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18961. */
  18962. blendMode: number;
  18963. /**
  18964. * Minimum life time of emitting particles.
  18965. */
  18966. minLifeTime: number;
  18967. /**
  18968. * Maximum life time of emitting particles.
  18969. */
  18970. maxLifeTime: number;
  18971. /**
  18972. * Minimum Size of emitting particles.
  18973. */
  18974. minSize: number;
  18975. /**
  18976. * Maximum Size of emitting particles.
  18977. */
  18978. maxSize: number;
  18979. /**
  18980. * Minimum scale of emitting particles on X axis.
  18981. */
  18982. minScaleX: number;
  18983. /**
  18984. * Maximum scale of emitting particles on X axis.
  18985. */
  18986. maxScaleX: number;
  18987. /**
  18988. * Minimum scale of emitting particles on Y axis.
  18989. */
  18990. minScaleY: number;
  18991. /**
  18992. * Maximum scale of emitting particles on Y axis.
  18993. */
  18994. maxScaleY: number;
  18995. /**
  18996. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18997. */
  18998. color1: Color4;
  18999. /**
  19000. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19001. */
  19002. color2: Color4;
  19003. /**
  19004. * Color the particle will have at the end of its lifetime.
  19005. */
  19006. colorDead: Color4;
  19007. /**
  19008. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19009. */
  19010. emitRate: number;
  19011. /**
  19012. * You can use gravity if you want to give an orientation to your particles.
  19013. */
  19014. gravity: Vector3;
  19015. /**
  19016. * Minimum power of emitting particles.
  19017. */
  19018. minEmitPower: number;
  19019. /**
  19020. * Maximum power of emitting particles.
  19021. */
  19022. maxEmitPower: number;
  19023. /**
  19024. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19025. */
  19026. minAngularSpeed: number;
  19027. /**
  19028. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19029. */
  19030. maxAngularSpeed: number;
  19031. /**
  19032. * Gets or sets the minimal initial rotation in radians.
  19033. */
  19034. minInitialRotation: number;
  19035. /**
  19036. * Gets or sets the maximal initial rotation in radians.
  19037. */
  19038. maxInitialRotation: number;
  19039. /**
  19040. * The particle emitter type defines the emitter used by the particle system.
  19041. * It can be for example box, sphere, or cone...
  19042. */
  19043. particleEmitterType: Nullable<IParticleEmitterType>;
  19044. /**
  19045. * Defines the delay in milliseconds before starting the system (0 by default)
  19046. */
  19047. startDelay: number;
  19048. /**
  19049. * 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
  19050. */
  19051. preWarmCycles: number;
  19052. /**
  19053. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19054. */
  19055. preWarmStepOffset: number;
  19056. /**
  19057. * 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)
  19058. */
  19059. spriteCellChangeSpeed: number;
  19060. /**
  19061. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19062. */
  19063. startSpriteCellID: number;
  19064. /**
  19065. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19066. */
  19067. endSpriteCellID: number;
  19068. /**
  19069. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19070. */
  19071. spriteCellWidth: number;
  19072. /**
  19073. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19074. */
  19075. spriteCellHeight: number;
  19076. /**
  19077. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19078. */
  19079. spriteRandomStartCell: boolean;
  19080. /**
  19081. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19082. */
  19083. isAnimationSheetEnabled: boolean;
  19084. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19085. translationPivot: Vector2;
  19086. /**
  19087. * Gets or sets a texture used to add random noise to particle positions
  19088. */
  19089. noiseTexture: Nullable<BaseTexture>;
  19090. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19091. noiseStrength: Vector3;
  19092. /**
  19093. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19094. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19095. */
  19096. billboardMode: number;
  19097. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19098. limitVelocityDamping: number;
  19099. /**
  19100. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19101. */
  19102. beginAnimationOnStart: boolean;
  19103. /**
  19104. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19105. */
  19106. beginAnimationFrom: number;
  19107. /**
  19108. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19109. */
  19110. beginAnimationTo: number;
  19111. /**
  19112. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19113. */
  19114. beginAnimationLoop: boolean;
  19115. /**
  19116. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19117. */
  19118. disposeOnStop: boolean;
  19119. /**
  19120. * Gets the maximum number of particles active at the same time.
  19121. * @returns The max number of active particles.
  19122. */
  19123. getCapacity(): number;
  19124. /**
  19125. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19126. * @returns True if it has been started, otherwise false.
  19127. */
  19128. isStarted(): boolean;
  19129. /**
  19130. * Animates the particle system for this frame.
  19131. */
  19132. animate(): void;
  19133. /**
  19134. * Renders the particle system in its current state.
  19135. * @returns the current number of particles
  19136. */
  19137. render(): number;
  19138. /**
  19139. * Dispose the particle system and frees its associated resources.
  19140. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19141. */
  19142. dispose(disposeTexture?: boolean): void;
  19143. /**
  19144. * Clones the particle system.
  19145. * @param name The name of the cloned object
  19146. * @param newEmitter The new emitter to use
  19147. * @returns the cloned particle system
  19148. */
  19149. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19150. /**
  19151. * Serializes the particle system to a JSON object.
  19152. * @returns the JSON object
  19153. */
  19154. serialize(): any;
  19155. /**
  19156. * Rebuild the particle system
  19157. */
  19158. rebuild(): void;
  19159. /**
  19160. * Starts the particle system and begins to emit
  19161. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19162. */
  19163. start(delay?: number): void;
  19164. /**
  19165. * Stops the particle system.
  19166. */
  19167. stop(): void;
  19168. /**
  19169. * Remove all active particles
  19170. */
  19171. reset(): void;
  19172. /**
  19173. * Is this system ready to be used/rendered
  19174. * @return true if the system is ready
  19175. */
  19176. isReady(): boolean;
  19177. /**
  19178. * Adds a new color gradient
  19179. * @param gradient defines the gradient to use (between 0 and 1)
  19180. * @param color1 defines the color to affect to the specified gradient
  19181. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19182. * @returns the current particle system
  19183. */
  19184. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19185. /**
  19186. * Remove a specific color gradient
  19187. * @param gradient defines the gradient to remove
  19188. * @returns the current particle system
  19189. */
  19190. removeColorGradient(gradient: number): IParticleSystem;
  19191. /**
  19192. * Adds a new size gradient
  19193. * @param gradient defines the gradient to use (between 0 and 1)
  19194. * @param factor defines the size factor to affect to the specified gradient
  19195. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19196. * @returns the current particle system
  19197. */
  19198. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19199. /**
  19200. * Remove a specific size gradient
  19201. * @param gradient defines the gradient to remove
  19202. * @returns the current particle system
  19203. */
  19204. removeSizeGradient(gradient: number): IParticleSystem;
  19205. /**
  19206. * Gets the current list of color gradients.
  19207. * You must use addColorGradient and removeColorGradient to udpate this list
  19208. * @returns the list of color gradients
  19209. */
  19210. getColorGradients(): Nullable<Array<ColorGradient>>;
  19211. /**
  19212. * Gets the current list of size gradients.
  19213. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19214. * @returns the list of size gradients
  19215. */
  19216. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19217. /**
  19218. * Gets the current list of angular speed gradients.
  19219. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19220. * @returns the list of angular speed gradients
  19221. */
  19222. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19223. /**
  19224. * Adds a new angular speed gradient
  19225. * @param gradient defines the gradient to use (between 0 and 1)
  19226. * @param factor defines the angular speed to affect to the specified gradient
  19227. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19228. * @returns the current particle system
  19229. */
  19230. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19231. /**
  19232. * Remove a specific angular speed gradient
  19233. * @param gradient defines the gradient to remove
  19234. * @returns the current particle system
  19235. */
  19236. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19237. /**
  19238. * Gets the current list of velocity gradients.
  19239. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19240. * @returns the list of velocity gradients
  19241. */
  19242. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19243. /**
  19244. * Adds a new velocity gradient
  19245. * @param gradient defines the gradient to use (between 0 and 1)
  19246. * @param factor defines the velocity to affect to the specified gradient
  19247. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19248. * @returns the current particle system
  19249. */
  19250. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19251. /**
  19252. * Remove a specific velocity gradient
  19253. * @param gradient defines the gradient to remove
  19254. * @returns the current particle system
  19255. */
  19256. removeVelocityGradient(gradient: number): IParticleSystem;
  19257. /**
  19258. * Gets the current list of limit velocity gradients.
  19259. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19260. * @returns the list of limit velocity gradients
  19261. */
  19262. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19263. /**
  19264. * Adds a new limit velocity gradient
  19265. * @param gradient defines the gradient to use (between 0 and 1)
  19266. * @param factor defines the limit velocity to affect to the specified gradient
  19267. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19268. * @returns the current particle system
  19269. */
  19270. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19271. /**
  19272. * Remove a specific limit velocity gradient
  19273. * @param gradient defines the gradient to remove
  19274. * @returns the current particle system
  19275. */
  19276. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19277. /**
  19278. * Adds a new drag gradient
  19279. * @param gradient defines the gradient to use (between 0 and 1)
  19280. * @param factor defines the drag to affect to the specified gradient
  19281. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19282. * @returns the current particle system
  19283. */
  19284. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19285. /**
  19286. * Remove a specific drag gradient
  19287. * @param gradient defines the gradient to remove
  19288. * @returns the current particle system
  19289. */
  19290. removeDragGradient(gradient: number): IParticleSystem;
  19291. /**
  19292. * Gets the current list of drag gradients.
  19293. * You must use addDragGradient and removeDragGradient to udpate this list
  19294. * @returns the list of drag gradients
  19295. */
  19296. getDragGradients(): Nullable<Array<FactorGradient>>;
  19297. /**
  19298. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19299. * @param gradient defines the gradient to use (between 0 and 1)
  19300. * @param factor defines the emit rate to affect to the specified gradient
  19301. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19302. * @returns the current particle system
  19303. */
  19304. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19305. /**
  19306. * Remove a specific emit rate gradient
  19307. * @param gradient defines the gradient to remove
  19308. * @returns the current particle system
  19309. */
  19310. removeEmitRateGradient(gradient: number): IParticleSystem;
  19311. /**
  19312. * Gets the current list of emit rate gradients.
  19313. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19314. * @returns the list of emit rate gradients
  19315. */
  19316. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19317. /**
  19318. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19319. * @param gradient defines the gradient to use (between 0 and 1)
  19320. * @param factor defines the start size to affect to the specified gradient
  19321. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19322. * @returns the current particle system
  19323. */
  19324. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19325. /**
  19326. * Remove a specific start size gradient
  19327. * @param gradient defines the gradient to remove
  19328. * @returns the current particle system
  19329. */
  19330. removeStartSizeGradient(gradient: number): IParticleSystem;
  19331. /**
  19332. * Gets the current list of start size gradients.
  19333. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19334. * @returns the list of start size gradients
  19335. */
  19336. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19337. /**
  19338. * Adds a new life time gradient
  19339. * @param gradient defines the gradient to use (between 0 and 1)
  19340. * @param factor defines the life time factor to affect to the specified gradient
  19341. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19342. * @returns the current particle system
  19343. */
  19344. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19345. /**
  19346. * Remove a specific life time gradient
  19347. * @param gradient defines the gradient to remove
  19348. * @returns the current particle system
  19349. */
  19350. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19351. /**
  19352. * Gets the current list of life time gradients.
  19353. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19354. * @returns the list of life time gradients
  19355. */
  19356. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19357. /**
  19358. * Gets the current list of color gradients.
  19359. * You must use addColorGradient and removeColorGradient to udpate this list
  19360. * @returns the list of color gradients
  19361. */
  19362. getColorGradients(): Nullable<Array<ColorGradient>>;
  19363. /**
  19364. * Adds a new ramp gradient used to remap particle colors
  19365. * @param gradient defines the gradient to use (between 0 and 1)
  19366. * @param color defines the color to affect to the specified gradient
  19367. * @returns the current particle system
  19368. */
  19369. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19370. /**
  19371. * Gets the current list of ramp gradients.
  19372. * You must use addRampGradient and removeRampGradient to udpate this list
  19373. * @returns the list of ramp gradients
  19374. */
  19375. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19376. /** Gets or sets a boolean indicating that ramp gradients must be used
  19377. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19378. */
  19379. useRampGradients: boolean;
  19380. /**
  19381. * Adds a new color remap gradient
  19382. * @param gradient defines the gradient to use (between 0 and 1)
  19383. * @param min defines the color remap minimal range
  19384. * @param max defines the color remap maximal range
  19385. * @returns the current particle system
  19386. */
  19387. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19388. /**
  19389. * Gets the current list of color remap gradients.
  19390. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19391. * @returns the list of color remap gradients
  19392. */
  19393. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19394. /**
  19395. * Adds a new alpha remap gradient
  19396. * @param gradient defines the gradient to use (between 0 and 1)
  19397. * @param min defines the alpha remap minimal range
  19398. * @param max defines the alpha remap maximal range
  19399. * @returns the current particle system
  19400. */
  19401. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19402. /**
  19403. * Gets the current list of alpha remap gradients.
  19404. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19405. * @returns the list of alpha remap gradients
  19406. */
  19407. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19408. /**
  19409. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19410. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19411. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19412. * @returns the emitter
  19413. */
  19414. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19415. /**
  19416. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19417. * @param radius The radius of the hemisphere to emit from
  19418. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19419. * @returns the emitter
  19420. */
  19421. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19422. /**
  19423. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19424. * @param radius The radius of the sphere to emit from
  19425. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19426. * @returns the emitter
  19427. */
  19428. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19429. /**
  19430. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19431. * @param radius The radius of the sphere to emit from
  19432. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19433. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19434. * @returns the emitter
  19435. */
  19436. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19437. /**
  19438. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19439. * @param radius The radius of the emission cylinder
  19440. * @param height The height of the emission cylinder
  19441. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19442. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19443. * @returns the emitter
  19444. */
  19445. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19446. /**
  19447. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19448. * @param radius The radius of the cylinder to emit from
  19449. * @param height The height of the emission cylinder
  19450. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19451. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19452. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19453. * @returns the emitter
  19454. */
  19455. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19456. /**
  19457. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19458. * @param radius The radius of the cone to emit from
  19459. * @param angle The base angle of the cone
  19460. * @returns the emitter
  19461. */
  19462. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19463. /**
  19464. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19465. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19466. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19467. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19468. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19469. * @returns the emitter
  19470. */
  19471. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19472. /**
  19473. * Get hosting scene
  19474. * @returns the scene
  19475. */
  19476. getScene(): Scene;
  19477. }
  19478. }
  19479. declare module "babylonjs/Meshes/instancedMesh" {
  19480. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19481. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19482. import { Camera } from "babylonjs/Cameras/camera";
  19483. import { Node } from "babylonjs/node";
  19484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19485. import { Mesh } from "babylonjs/Meshes/mesh";
  19486. import { Material } from "babylonjs/Materials/material";
  19487. import { Skeleton } from "babylonjs/Bones/skeleton";
  19488. import { Light } from "babylonjs/Lights/light";
  19489. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19490. /**
  19491. * Creates an instance based on a source mesh.
  19492. */
  19493. export class InstancedMesh extends AbstractMesh {
  19494. private _sourceMesh;
  19495. private _currentLOD;
  19496. /** @hidden */
  19497. _indexInSourceMeshInstanceArray: number;
  19498. constructor(name: string, source: Mesh);
  19499. /**
  19500. * Returns the string "InstancedMesh".
  19501. */
  19502. getClassName(): string;
  19503. /** Gets the list of lights affecting that mesh */
  19504. readonly lightSources: Light[];
  19505. _resyncLightSources(): void;
  19506. _resyncLighSource(light: Light): void;
  19507. _removeLightSource(light: Light, dispose: boolean): void;
  19508. /**
  19509. * If the source mesh receives shadows
  19510. */
  19511. readonly receiveShadows: boolean;
  19512. /**
  19513. * The material of the source mesh
  19514. */
  19515. readonly material: Nullable<Material>;
  19516. /**
  19517. * Visibility of the source mesh
  19518. */
  19519. readonly visibility: number;
  19520. /**
  19521. * Skeleton of the source mesh
  19522. */
  19523. readonly skeleton: Nullable<Skeleton>;
  19524. /**
  19525. * Rendering ground id of the source mesh
  19526. */
  19527. renderingGroupId: number;
  19528. /**
  19529. * Returns the total number of vertices (integer).
  19530. */
  19531. getTotalVertices(): number;
  19532. /**
  19533. * Returns a positive integer : the total number of indices in this mesh geometry.
  19534. * @returns the numner of indices or zero if the mesh has no geometry.
  19535. */
  19536. getTotalIndices(): number;
  19537. /**
  19538. * The source mesh of the instance
  19539. */
  19540. readonly sourceMesh: Mesh;
  19541. /**
  19542. * Is this node ready to be used/rendered
  19543. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19544. * @return {boolean} is it ready
  19545. */
  19546. isReady(completeCheck?: boolean): boolean;
  19547. /**
  19548. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19549. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19550. * @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.
  19551. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19552. */
  19553. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19554. /**
  19555. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19556. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19557. * The `data` are either a numeric array either a Float32Array.
  19558. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19559. * 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).
  19560. * Note that a new underlying VertexBuffer object is created each call.
  19561. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19562. *
  19563. * Possible `kind` values :
  19564. * - VertexBuffer.PositionKind
  19565. * - VertexBuffer.UVKind
  19566. * - VertexBuffer.UV2Kind
  19567. * - VertexBuffer.UV3Kind
  19568. * - VertexBuffer.UV4Kind
  19569. * - VertexBuffer.UV5Kind
  19570. * - VertexBuffer.UV6Kind
  19571. * - VertexBuffer.ColorKind
  19572. * - VertexBuffer.MatricesIndicesKind
  19573. * - VertexBuffer.MatricesIndicesExtraKind
  19574. * - VertexBuffer.MatricesWeightsKind
  19575. * - VertexBuffer.MatricesWeightsExtraKind
  19576. *
  19577. * Returns the Mesh.
  19578. */
  19579. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19580. /**
  19581. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19582. * If the mesh has no geometry, it is simply returned as it is.
  19583. * The `data` are either a numeric array either a Float32Array.
  19584. * No new underlying VertexBuffer object is created.
  19585. * 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.
  19586. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19587. *
  19588. * Possible `kind` values :
  19589. * - VertexBuffer.PositionKind
  19590. * - VertexBuffer.UVKind
  19591. * - VertexBuffer.UV2Kind
  19592. * - VertexBuffer.UV3Kind
  19593. * - VertexBuffer.UV4Kind
  19594. * - VertexBuffer.UV5Kind
  19595. * - VertexBuffer.UV6Kind
  19596. * - VertexBuffer.ColorKind
  19597. * - VertexBuffer.MatricesIndicesKind
  19598. * - VertexBuffer.MatricesIndicesExtraKind
  19599. * - VertexBuffer.MatricesWeightsKind
  19600. * - VertexBuffer.MatricesWeightsExtraKind
  19601. *
  19602. * Returns the Mesh.
  19603. */
  19604. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19605. /**
  19606. * Sets the mesh indices.
  19607. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19608. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19609. * This method creates a new index buffer each call.
  19610. * Returns the Mesh.
  19611. */
  19612. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19613. /**
  19614. * Boolean : True if the mesh owns the requested kind of data.
  19615. */
  19616. isVerticesDataPresent(kind: string): boolean;
  19617. /**
  19618. * Returns an array of indices (IndicesArray).
  19619. */
  19620. getIndices(): Nullable<IndicesArray>;
  19621. readonly _positions: Nullable<Vector3[]>;
  19622. /**
  19623. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19624. * This means the mesh underlying bounding box and sphere are recomputed.
  19625. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19626. * @returns the current mesh
  19627. */
  19628. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19629. /** @hidden */
  19630. _preActivate(): InstancedMesh;
  19631. /** @hidden */
  19632. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19633. /** @hidden */
  19634. _postActivate(): void;
  19635. getWorldMatrix(): Matrix;
  19636. readonly isAnInstance: boolean;
  19637. /**
  19638. * Returns the current associated LOD AbstractMesh.
  19639. */
  19640. getLOD(camera: Camera): AbstractMesh;
  19641. /** @hidden */
  19642. _syncSubMeshes(): InstancedMesh;
  19643. /** @hidden */
  19644. _generatePointsArray(): boolean;
  19645. /**
  19646. * Creates a new InstancedMesh from the current mesh.
  19647. * - name (string) : the cloned mesh name
  19648. * - newParent (optional Node) : the optional Node to parent the clone to.
  19649. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19650. *
  19651. * Returns the clone.
  19652. */
  19653. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19654. /**
  19655. * Disposes the InstancedMesh.
  19656. * Returns nothing.
  19657. */
  19658. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19659. }
  19660. module "babylonjs/Meshes/mesh" {
  19661. interface Mesh {
  19662. /**
  19663. * Register a custom buffer that will be instanced
  19664. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19665. * @param kind defines the buffer kind
  19666. * @param stride defines the stride in floats
  19667. */
  19668. registerInstancedBuffer(kind: string, stride: number): void;
  19669. /** @hidden */
  19670. _userInstancedBuffersStorage: {
  19671. data: {
  19672. [key: string]: Float32Array;
  19673. };
  19674. sizes: {
  19675. [key: string]: number;
  19676. };
  19677. vertexBuffers: {
  19678. [key: string]: Nullable<VertexBuffer>;
  19679. };
  19680. strides: {
  19681. [key: string]: number;
  19682. };
  19683. };
  19684. }
  19685. }
  19686. module "babylonjs/Meshes/abstractMesh" {
  19687. interface AbstractMesh {
  19688. /**
  19689. * Object used to store instanced buffers defined by user
  19690. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19691. */
  19692. instancedBuffers: {
  19693. [key: string]: any;
  19694. };
  19695. }
  19696. }
  19697. }
  19698. declare module "babylonjs/Materials/shaderMaterial" {
  19699. import { Scene } from "babylonjs/scene";
  19700. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19701. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19702. import { Mesh } from "babylonjs/Meshes/mesh";
  19703. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19704. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19705. import { Texture } from "babylonjs/Materials/Textures/texture";
  19706. import { Material } from "babylonjs/Materials/material";
  19707. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19708. /**
  19709. * Defines the options associated with the creation of a shader material.
  19710. */
  19711. export interface IShaderMaterialOptions {
  19712. /**
  19713. * Does the material work in alpha blend mode
  19714. */
  19715. needAlphaBlending: boolean;
  19716. /**
  19717. * Does the material work in alpha test mode
  19718. */
  19719. needAlphaTesting: boolean;
  19720. /**
  19721. * The list of attribute names used in the shader
  19722. */
  19723. attributes: string[];
  19724. /**
  19725. * The list of unifrom names used in the shader
  19726. */
  19727. uniforms: string[];
  19728. /**
  19729. * The list of UBO names used in the shader
  19730. */
  19731. uniformBuffers: string[];
  19732. /**
  19733. * The list of sampler names used in the shader
  19734. */
  19735. samplers: string[];
  19736. /**
  19737. * The list of defines used in the shader
  19738. */
  19739. defines: string[];
  19740. }
  19741. /**
  19742. * 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.
  19743. *
  19744. * This returned material effects how the mesh will look based on the code in the shaders.
  19745. *
  19746. * @see http://doc.babylonjs.com/how_to/shader_material
  19747. */
  19748. export class ShaderMaterial extends Material {
  19749. private _shaderPath;
  19750. private _options;
  19751. private _textures;
  19752. private _textureArrays;
  19753. private _floats;
  19754. private _ints;
  19755. private _floatsArrays;
  19756. private _colors3;
  19757. private _colors3Arrays;
  19758. private _colors4;
  19759. private _colors4Arrays;
  19760. private _vectors2;
  19761. private _vectors3;
  19762. private _vectors4;
  19763. private _matrices;
  19764. private _matrixArrays;
  19765. private _matrices3x3;
  19766. private _matrices2x2;
  19767. private _vectors2Arrays;
  19768. private _vectors3Arrays;
  19769. private _vectors4Arrays;
  19770. private _cachedWorldViewMatrix;
  19771. private _cachedWorldViewProjectionMatrix;
  19772. private _renderId;
  19773. private _multiview;
  19774. /**
  19775. * Instantiate a new shader material.
  19776. * 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.
  19777. * This returned material effects how the mesh will look based on the code in the shaders.
  19778. * @see http://doc.babylonjs.com/how_to/shader_material
  19779. * @param name Define the name of the material in the scene
  19780. * @param scene Define the scene the material belongs to
  19781. * @param shaderPath Defines the route to the shader code in one of three ways:
  19782. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19783. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19784. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19785. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19786. * @param options Define the options used to create the shader
  19787. */
  19788. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19789. /**
  19790. * Gets the shader path used to define the shader code
  19791. * It can be modified to trigger a new compilation
  19792. */
  19793. /**
  19794. * Sets the shader path used to define the shader code
  19795. * It can be modified to trigger a new compilation
  19796. */
  19797. shaderPath: any;
  19798. /**
  19799. * Gets the options used to compile the shader.
  19800. * They can be modified to trigger a new compilation
  19801. */
  19802. readonly options: IShaderMaterialOptions;
  19803. /**
  19804. * Gets the current class name of the material e.g. "ShaderMaterial"
  19805. * Mainly use in serialization.
  19806. * @returns the class name
  19807. */
  19808. getClassName(): string;
  19809. /**
  19810. * Specifies if the material will require alpha blending
  19811. * @returns a boolean specifying if alpha blending is needed
  19812. */
  19813. needAlphaBlending(): boolean;
  19814. /**
  19815. * Specifies if this material should be rendered in alpha test mode
  19816. * @returns a boolean specifying if an alpha test is needed.
  19817. */
  19818. needAlphaTesting(): boolean;
  19819. private _checkUniform;
  19820. /**
  19821. * Set a texture in the shader.
  19822. * @param name Define the name of the uniform samplers as defined in the shader
  19823. * @param texture Define the texture to bind to this sampler
  19824. * @return the material itself allowing "fluent" like uniform updates
  19825. */
  19826. setTexture(name: string, texture: Texture): ShaderMaterial;
  19827. /**
  19828. * Set a texture array in the shader.
  19829. * @param name Define the name of the uniform sampler array as defined in the shader
  19830. * @param textures Define the list of textures to bind to this sampler
  19831. * @return the material itself allowing "fluent" like uniform updates
  19832. */
  19833. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19834. /**
  19835. * Set a float in the shader.
  19836. * @param name Define the name of the uniform as defined in the shader
  19837. * @param value Define the value to give to the uniform
  19838. * @return the material itself allowing "fluent" like uniform updates
  19839. */
  19840. setFloat(name: string, value: number): ShaderMaterial;
  19841. /**
  19842. * Set a int in the shader.
  19843. * @param name Define the name of the uniform as defined in the shader
  19844. * @param value Define the value to give to the uniform
  19845. * @return the material itself allowing "fluent" like uniform updates
  19846. */
  19847. setInt(name: string, value: number): ShaderMaterial;
  19848. /**
  19849. * Set an array of floats in the shader.
  19850. * @param name Define the name of the uniform as defined in the shader
  19851. * @param value Define the value to give to the uniform
  19852. * @return the material itself allowing "fluent" like uniform updates
  19853. */
  19854. setFloats(name: string, value: number[]): ShaderMaterial;
  19855. /**
  19856. * Set a vec3 in the shader from a Color3.
  19857. * @param name Define the name of the uniform as defined in the shader
  19858. * @param value Define the value to give to the uniform
  19859. * @return the material itself allowing "fluent" like uniform updates
  19860. */
  19861. setColor3(name: string, value: Color3): ShaderMaterial;
  19862. /**
  19863. * Set a vec3 array in the shader from a Color3 array.
  19864. * @param name Define the name of the uniform as defined in the shader
  19865. * @param value Define the value to give to the uniform
  19866. * @return the material itself allowing "fluent" like uniform updates
  19867. */
  19868. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19869. /**
  19870. * Set a vec4 in the shader from a Color4.
  19871. * @param name Define the name of the uniform as defined in the shader
  19872. * @param value Define the value to give to the uniform
  19873. * @return the material itself allowing "fluent" like uniform updates
  19874. */
  19875. setColor4(name: string, value: Color4): ShaderMaterial;
  19876. /**
  19877. * Set a vec4 array in the shader from a Color4 array.
  19878. * @param name Define the name of the uniform as defined in the shader
  19879. * @param value Define the value to give to the uniform
  19880. * @return the material itself allowing "fluent" like uniform updates
  19881. */
  19882. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19883. /**
  19884. * Set a vec2 in the shader from a Vector2.
  19885. * @param name Define the name of the uniform as defined in the shader
  19886. * @param value Define the value to give to the uniform
  19887. * @return the material itself allowing "fluent" like uniform updates
  19888. */
  19889. setVector2(name: string, value: Vector2): ShaderMaterial;
  19890. /**
  19891. * Set a vec3 in the shader from a Vector3.
  19892. * @param name Define the name of the uniform as defined in the shader
  19893. * @param value Define the value to give to the uniform
  19894. * @return the material itself allowing "fluent" like uniform updates
  19895. */
  19896. setVector3(name: string, value: Vector3): ShaderMaterial;
  19897. /**
  19898. * Set a vec4 in the shader from a Vector4.
  19899. * @param name Define the name of the uniform as defined in the shader
  19900. * @param value Define the value to give to the uniform
  19901. * @return the material itself allowing "fluent" like uniform updates
  19902. */
  19903. setVector4(name: string, value: Vector4): ShaderMaterial;
  19904. /**
  19905. * Set a mat4 in the shader from a Matrix.
  19906. * @param name Define the name of the uniform as defined in the shader
  19907. * @param value Define the value to give to the uniform
  19908. * @return the material itself allowing "fluent" like uniform updates
  19909. */
  19910. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19911. /**
  19912. * Set a float32Array in the shader from a matrix array.
  19913. * @param name Define the name of the uniform as defined in the shader
  19914. * @param value Define the value to give to the uniform
  19915. * @return the material itself allowing "fluent" like uniform updates
  19916. */
  19917. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19918. /**
  19919. * Set a mat3 in the shader from a Float32Array.
  19920. * @param name Define the name of the uniform as defined in the shader
  19921. * @param value Define the value to give to the uniform
  19922. * @return the material itself allowing "fluent" like uniform updates
  19923. */
  19924. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19925. /**
  19926. * Set a mat2 in the shader from a Float32Array.
  19927. * @param name Define the name of the uniform as defined in the shader
  19928. * @param value Define the value to give to the uniform
  19929. * @return the material itself allowing "fluent" like uniform updates
  19930. */
  19931. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19932. /**
  19933. * Set a vec2 array in the shader from a number array.
  19934. * @param name Define the name of the uniform as defined in the shader
  19935. * @param value Define the value to give to the uniform
  19936. * @return the material itself allowing "fluent" like uniform updates
  19937. */
  19938. setArray2(name: string, value: number[]): ShaderMaterial;
  19939. /**
  19940. * Set a vec3 array in the shader from a number array.
  19941. * @param name Define the name of the uniform as defined in the shader
  19942. * @param value Define the value to give to the uniform
  19943. * @return the material itself allowing "fluent" like uniform updates
  19944. */
  19945. setArray3(name: string, value: number[]): ShaderMaterial;
  19946. /**
  19947. * Set a vec4 array in the shader from a number array.
  19948. * @param name Define the name of the uniform as defined in the shader
  19949. * @param value Define the value to give to the uniform
  19950. * @return the material itself allowing "fluent" like uniform updates
  19951. */
  19952. setArray4(name: string, value: number[]): ShaderMaterial;
  19953. private _checkCache;
  19954. /**
  19955. * Specifies that the submesh is ready to be used
  19956. * @param mesh defines the mesh to check
  19957. * @param subMesh defines which submesh to check
  19958. * @param useInstances specifies that instances should be used
  19959. * @returns a boolean indicating that the submesh is ready or not
  19960. */
  19961. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19962. /**
  19963. * Checks if the material is ready to render the requested mesh
  19964. * @param mesh Define the mesh to render
  19965. * @param useInstances Define whether or not the material is used with instances
  19966. * @returns true if ready, otherwise false
  19967. */
  19968. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19969. /**
  19970. * Binds the world matrix to the material
  19971. * @param world defines the world transformation matrix
  19972. */
  19973. bindOnlyWorldMatrix(world: Matrix): void;
  19974. /**
  19975. * Binds the material to the mesh
  19976. * @param world defines the world transformation matrix
  19977. * @param mesh defines the mesh to bind the material to
  19978. */
  19979. bind(world: Matrix, mesh?: Mesh): void;
  19980. /**
  19981. * Gets the active textures from the material
  19982. * @returns an array of textures
  19983. */
  19984. getActiveTextures(): BaseTexture[];
  19985. /**
  19986. * Specifies if the material uses a texture
  19987. * @param texture defines the texture to check against the material
  19988. * @returns a boolean specifying if the material uses the texture
  19989. */
  19990. hasTexture(texture: BaseTexture): boolean;
  19991. /**
  19992. * Makes a duplicate of the material, and gives it a new name
  19993. * @param name defines the new name for the duplicated material
  19994. * @returns the cloned material
  19995. */
  19996. clone(name: string): ShaderMaterial;
  19997. /**
  19998. * Disposes the material
  19999. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20000. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20001. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20002. */
  20003. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20004. /**
  20005. * Serializes this material in a JSON representation
  20006. * @returns the serialized material object
  20007. */
  20008. serialize(): any;
  20009. /**
  20010. * Creates a shader material from parsed shader material data
  20011. * @param source defines the JSON represnetation of the material
  20012. * @param scene defines the hosting scene
  20013. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20014. * @returns a new material
  20015. */
  20016. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20017. }
  20018. }
  20019. declare module "babylonjs/Shaders/color.fragment" {
  20020. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20021. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20022. /** @hidden */
  20023. export var colorPixelShader: {
  20024. name: string;
  20025. shader: string;
  20026. };
  20027. }
  20028. declare module "babylonjs/Shaders/color.vertex" {
  20029. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20030. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20031. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20032. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20033. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20034. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20035. /** @hidden */
  20036. export var colorVertexShader: {
  20037. name: string;
  20038. shader: string;
  20039. };
  20040. }
  20041. declare module "babylonjs/Meshes/linesMesh" {
  20042. import { Nullable } from "babylonjs/types";
  20043. import { Scene } from "babylonjs/scene";
  20044. import { Color3 } from "babylonjs/Maths/math.color";
  20045. import { Node } from "babylonjs/node";
  20046. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20047. import { Mesh } from "babylonjs/Meshes/mesh";
  20048. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20049. import { Effect } from "babylonjs/Materials/effect";
  20050. import { Material } from "babylonjs/Materials/material";
  20051. import "babylonjs/Shaders/color.fragment";
  20052. import "babylonjs/Shaders/color.vertex";
  20053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20054. /**
  20055. * Line mesh
  20056. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20057. */
  20058. export class LinesMesh extends Mesh {
  20059. /**
  20060. * If vertex color should be applied to the mesh
  20061. */
  20062. readonly useVertexColor?: boolean | undefined;
  20063. /**
  20064. * If vertex alpha should be applied to the mesh
  20065. */
  20066. readonly useVertexAlpha?: boolean | undefined;
  20067. /**
  20068. * Color of the line (Default: White)
  20069. */
  20070. color: Color3;
  20071. /**
  20072. * Alpha of the line (Default: 1)
  20073. */
  20074. alpha: number;
  20075. /**
  20076. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20077. * This margin is expressed in world space coordinates, so its value may vary.
  20078. * Default value is 0.1
  20079. */
  20080. intersectionThreshold: number;
  20081. private _colorShader;
  20082. private color4;
  20083. /**
  20084. * Creates a new LinesMesh
  20085. * @param name defines the name
  20086. * @param scene defines the hosting scene
  20087. * @param parent defines the parent mesh if any
  20088. * @param source defines the optional source LinesMesh used to clone data from
  20089. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20090. * When false, achieved by calling a clone(), also passing False.
  20091. * This will make creation of children, recursive.
  20092. * @param useVertexColor defines if this LinesMesh supports vertex color
  20093. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20094. */
  20095. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20096. /**
  20097. * If vertex color should be applied to the mesh
  20098. */
  20099. useVertexColor?: boolean | undefined,
  20100. /**
  20101. * If vertex alpha should be applied to the mesh
  20102. */
  20103. useVertexAlpha?: boolean | undefined);
  20104. private _addClipPlaneDefine;
  20105. private _removeClipPlaneDefine;
  20106. isReady(): boolean;
  20107. /**
  20108. * Returns the string "LineMesh"
  20109. */
  20110. getClassName(): string;
  20111. /**
  20112. * @hidden
  20113. */
  20114. /**
  20115. * @hidden
  20116. */
  20117. material: Material;
  20118. /**
  20119. * @hidden
  20120. */
  20121. readonly checkCollisions: boolean;
  20122. /** @hidden */
  20123. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20124. /** @hidden */
  20125. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20126. /**
  20127. * Disposes of the line mesh
  20128. * @param doNotRecurse If children should be disposed
  20129. */
  20130. dispose(doNotRecurse?: boolean): void;
  20131. /**
  20132. * Returns a new LineMesh object cloned from the current one.
  20133. */
  20134. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20135. /**
  20136. * Creates a new InstancedLinesMesh object from the mesh model.
  20137. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20138. * @param name defines the name of the new instance
  20139. * @returns a new InstancedLinesMesh
  20140. */
  20141. createInstance(name: string): InstancedLinesMesh;
  20142. }
  20143. /**
  20144. * Creates an instance based on a source LinesMesh
  20145. */
  20146. export class InstancedLinesMesh extends InstancedMesh {
  20147. /**
  20148. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20149. * This margin is expressed in world space coordinates, so its value may vary.
  20150. * Initilized with the intersectionThreshold value of the source LinesMesh
  20151. */
  20152. intersectionThreshold: number;
  20153. constructor(name: string, source: LinesMesh);
  20154. /**
  20155. * Returns the string "InstancedLinesMesh".
  20156. */
  20157. getClassName(): string;
  20158. }
  20159. }
  20160. declare module "babylonjs/Shaders/line.fragment" {
  20161. /** @hidden */
  20162. export var linePixelShader: {
  20163. name: string;
  20164. shader: string;
  20165. };
  20166. }
  20167. declare module "babylonjs/Shaders/line.vertex" {
  20168. /** @hidden */
  20169. export var lineVertexShader: {
  20170. name: string;
  20171. shader: string;
  20172. };
  20173. }
  20174. declare module "babylonjs/Rendering/edgesRenderer" {
  20175. import { Nullable } from "babylonjs/types";
  20176. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20178. import { Vector3 } from "babylonjs/Maths/math.vector";
  20179. import { IDisposable } from "babylonjs/scene";
  20180. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20181. import "babylonjs/Shaders/line.fragment";
  20182. import "babylonjs/Shaders/line.vertex";
  20183. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20184. module "babylonjs/Meshes/abstractMesh" {
  20185. interface AbstractMesh {
  20186. /**
  20187. * Gets the edgesRenderer associated with the mesh
  20188. */
  20189. edgesRenderer: Nullable<EdgesRenderer>;
  20190. }
  20191. }
  20192. module "babylonjs/Meshes/linesMesh" {
  20193. interface LinesMesh {
  20194. /**
  20195. * Enables the edge rendering mode on the mesh.
  20196. * This mode makes the mesh edges visible
  20197. * @param epsilon defines the maximal distance between two angles to detect a face
  20198. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20199. * @returns the currentAbstractMesh
  20200. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20201. */
  20202. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20203. }
  20204. }
  20205. module "babylonjs/Meshes/linesMesh" {
  20206. interface InstancedLinesMesh {
  20207. /**
  20208. * Enables the edge rendering mode on the mesh.
  20209. * This mode makes the mesh edges visible
  20210. * @param epsilon defines the maximal distance between two angles to detect a face
  20211. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20212. * @returns the current InstancedLinesMesh
  20213. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20214. */
  20215. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20216. }
  20217. }
  20218. /**
  20219. * Defines the minimum contract an Edges renderer should follow.
  20220. */
  20221. export interface IEdgesRenderer extends IDisposable {
  20222. /**
  20223. * Gets or sets a boolean indicating if the edgesRenderer is active
  20224. */
  20225. isEnabled: boolean;
  20226. /**
  20227. * Renders the edges of the attached mesh,
  20228. */
  20229. render(): void;
  20230. /**
  20231. * Checks wether or not the edges renderer is ready to render.
  20232. * @return true if ready, otherwise false.
  20233. */
  20234. isReady(): boolean;
  20235. }
  20236. /**
  20237. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20238. */
  20239. export class EdgesRenderer implements IEdgesRenderer {
  20240. /**
  20241. * Define the size of the edges with an orthographic camera
  20242. */
  20243. edgesWidthScalerForOrthographic: number;
  20244. /**
  20245. * Define the size of the edges with a perspective camera
  20246. */
  20247. edgesWidthScalerForPerspective: number;
  20248. protected _source: AbstractMesh;
  20249. protected _linesPositions: number[];
  20250. protected _linesNormals: number[];
  20251. protected _linesIndices: number[];
  20252. protected _epsilon: number;
  20253. protected _indicesCount: number;
  20254. protected _lineShader: ShaderMaterial;
  20255. protected _ib: DataBuffer;
  20256. protected _buffers: {
  20257. [key: string]: Nullable<VertexBuffer>;
  20258. };
  20259. protected _checkVerticesInsteadOfIndices: boolean;
  20260. private _meshRebuildObserver;
  20261. private _meshDisposeObserver;
  20262. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20263. isEnabled: boolean;
  20264. /**
  20265. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20266. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20267. * @param source Mesh used to create edges
  20268. * @param epsilon sum of angles in adjacency to check for edge
  20269. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20270. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20271. */
  20272. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20273. protected _prepareRessources(): void;
  20274. /** @hidden */
  20275. _rebuild(): void;
  20276. /**
  20277. * Releases the required resources for the edges renderer
  20278. */
  20279. dispose(): void;
  20280. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20281. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20282. /**
  20283. * Checks if the pair of p0 and p1 is en edge
  20284. * @param faceIndex
  20285. * @param edge
  20286. * @param faceNormals
  20287. * @param p0
  20288. * @param p1
  20289. * @private
  20290. */
  20291. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20292. /**
  20293. * push line into the position, normal and index buffer
  20294. * @protected
  20295. */
  20296. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20297. /**
  20298. * Generates lines edges from adjacencjes
  20299. * @private
  20300. */
  20301. _generateEdgesLines(): void;
  20302. /**
  20303. * Checks wether or not the edges renderer is ready to render.
  20304. * @return true if ready, otherwise false.
  20305. */
  20306. isReady(): boolean;
  20307. /**
  20308. * Renders the edges of the attached mesh,
  20309. */
  20310. render(): void;
  20311. }
  20312. /**
  20313. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20314. */
  20315. export class LineEdgesRenderer extends EdgesRenderer {
  20316. /**
  20317. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20318. * @param source LineMesh used to generate edges
  20319. * @param epsilon not important (specified angle for edge detection)
  20320. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20321. */
  20322. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20323. /**
  20324. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20325. */
  20326. _generateEdgesLines(): void;
  20327. }
  20328. }
  20329. declare module "babylonjs/Rendering/renderingGroup" {
  20330. import { SmartArray } from "babylonjs/Misc/smartArray";
  20331. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20333. import { Nullable } from "babylonjs/types";
  20334. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20335. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20336. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20337. import { Material } from "babylonjs/Materials/material";
  20338. import { Scene } from "babylonjs/scene";
  20339. /**
  20340. * This represents the object necessary to create a rendering group.
  20341. * This is exclusively used and created by the rendering manager.
  20342. * To modify the behavior, you use the available helpers in your scene or meshes.
  20343. * @hidden
  20344. */
  20345. export class RenderingGroup {
  20346. index: number;
  20347. private static _zeroVector;
  20348. private _scene;
  20349. private _opaqueSubMeshes;
  20350. private _transparentSubMeshes;
  20351. private _alphaTestSubMeshes;
  20352. private _depthOnlySubMeshes;
  20353. private _particleSystems;
  20354. private _spriteManagers;
  20355. private _opaqueSortCompareFn;
  20356. private _alphaTestSortCompareFn;
  20357. private _transparentSortCompareFn;
  20358. private _renderOpaque;
  20359. private _renderAlphaTest;
  20360. private _renderTransparent;
  20361. /** @hidden */
  20362. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20363. onBeforeTransparentRendering: () => void;
  20364. /**
  20365. * Set the opaque sort comparison function.
  20366. * If null the sub meshes will be render in the order they were created
  20367. */
  20368. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20369. /**
  20370. * Set the alpha test sort comparison function.
  20371. * If null the sub meshes will be render in the order they were created
  20372. */
  20373. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20374. /**
  20375. * Set the transparent sort comparison function.
  20376. * If null the sub meshes will be render in the order they were created
  20377. */
  20378. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20379. /**
  20380. * Creates a new rendering group.
  20381. * @param index The rendering group index
  20382. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20383. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20384. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20385. */
  20386. 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>);
  20387. /**
  20388. * Render all the sub meshes contained in the group.
  20389. * @param customRenderFunction Used to override the default render behaviour of the group.
  20390. * @returns true if rendered some submeshes.
  20391. */
  20392. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20393. /**
  20394. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20395. * @param subMeshes The submeshes to render
  20396. */
  20397. private renderOpaqueSorted;
  20398. /**
  20399. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20400. * @param subMeshes The submeshes to render
  20401. */
  20402. private renderAlphaTestSorted;
  20403. /**
  20404. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20405. * @param subMeshes The submeshes to render
  20406. */
  20407. private renderTransparentSorted;
  20408. /**
  20409. * Renders the submeshes in a specified order.
  20410. * @param subMeshes The submeshes to sort before render
  20411. * @param sortCompareFn The comparison function use to sort
  20412. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20413. * @param transparent Specifies to activate blending if true
  20414. */
  20415. private static renderSorted;
  20416. /**
  20417. * Renders the submeshes in the order they were dispatched (no sort applied).
  20418. * @param subMeshes The submeshes to render
  20419. */
  20420. private static renderUnsorted;
  20421. /**
  20422. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20423. * are rendered back to front if in the same alpha index.
  20424. *
  20425. * @param a The first submesh
  20426. * @param b The second submesh
  20427. * @returns The result of the comparison
  20428. */
  20429. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20430. /**
  20431. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20432. * are rendered back to front.
  20433. *
  20434. * @param a The first submesh
  20435. * @param b The second submesh
  20436. * @returns The result of the comparison
  20437. */
  20438. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20439. /**
  20440. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20441. * are rendered front to back (prevent overdraw).
  20442. *
  20443. * @param a The first submesh
  20444. * @param b The second submesh
  20445. * @returns The result of the comparison
  20446. */
  20447. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20448. /**
  20449. * Resets the different lists of submeshes to prepare a new frame.
  20450. */
  20451. prepare(): void;
  20452. dispose(): void;
  20453. /**
  20454. * Inserts the submesh in its correct queue depending on its material.
  20455. * @param subMesh The submesh to dispatch
  20456. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20457. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20458. */
  20459. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20460. dispatchSprites(spriteManager: ISpriteManager): void;
  20461. dispatchParticles(particleSystem: IParticleSystem): void;
  20462. private _renderParticles;
  20463. private _renderSprites;
  20464. }
  20465. }
  20466. declare module "babylonjs/Rendering/renderingManager" {
  20467. import { Nullable } from "babylonjs/types";
  20468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20469. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20470. import { SmartArray } from "babylonjs/Misc/smartArray";
  20471. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20472. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20473. import { Material } from "babylonjs/Materials/material";
  20474. import { Scene } from "babylonjs/scene";
  20475. import { Camera } from "babylonjs/Cameras/camera";
  20476. /**
  20477. * Interface describing the different options available in the rendering manager
  20478. * regarding Auto Clear between groups.
  20479. */
  20480. export interface IRenderingManagerAutoClearSetup {
  20481. /**
  20482. * Defines whether or not autoclear is enable.
  20483. */
  20484. autoClear: boolean;
  20485. /**
  20486. * Defines whether or not to autoclear the depth buffer.
  20487. */
  20488. depth: boolean;
  20489. /**
  20490. * Defines whether or not to autoclear the stencil buffer.
  20491. */
  20492. stencil: boolean;
  20493. }
  20494. /**
  20495. * This class is used by the onRenderingGroupObservable
  20496. */
  20497. export class RenderingGroupInfo {
  20498. /**
  20499. * The Scene that being rendered
  20500. */
  20501. scene: Scene;
  20502. /**
  20503. * The camera currently used for the rendering pass
  20504. */
  20505. camera: Nullable<Camera>;
  20506. /**
  20507. * The ID of the renderingGroup being processed
  20508. */
  20509. renderingGroupId: number;
  20510. }
  20511. /**
  20512. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20513. * It is enable to manage the different groups as well as the different necessary sort functions.
  20514. * This should not be used directly aside of the few static configurations
  20515. */
  20516. export class RenderingManager {
  20517. /**
  20518. * The max id used for rendering groups (not included)
  20519. */
  20520. static MAX_RENDERINGGROUPS: number;
  20521. /**
  20522. * The min id used for rendering groups (included)
  20523. */
  20524. static MIN_RENDERINGGROUPS: number;
  20525. /**
  20526. * Used to globally prevent autoclearing scenes.
  20527. */
  20528. static AUTOCLEAR: boolean;
  20529. /**
  20530. * @hidden
  20531. */
  20532. _useSceneAutoClearSetup: boolean;
  20533. private _scene;
  20534. private _renderingGroups;
  20535. private _depthStencilBufferAlreadyCleaned;
  20536. private _autoClearDepthStencil;
  20537. private _customOpaqueSortCompareFn;
  20538. private _customAlphaTestSortCompareFn;
  20539. private _customTransparentSortCompareFn;
  20540. private _renderingGroupInfo;
  20541. /**
  20542. * Instantiates a new rendering group for a particular scene
  20543. * @param scene Defines the scene the groups belongs to
  20544. */
  20545. constructor(scene: Scene);
  20546. private _clearDepthStencilBuffer;
  20547. /**
  20548. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20549. * @hidden
  20550. */
  20551. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20552. /**
  20553. * Resets the different information of the group to prepare a new frame
  20554. * @hidden
  20555. */
  20556. reset(): void;
  20557. /**
  20558. * Dispose and release the group and its associated resources.
  20559. * @hidden
  20560. */
  20561. dispose(): void;
  20562. /**
  20563. * Clear the info related to rendering groups preventing retention points during dispose.
  20564. */
  20565. freeRenderingGroups(): void;
  20566. private _prepareRenderingGroup;
  20567. /**
  20568. * Add a sprite manager to the rendering manager in order to render it this frame.
  20569. * @param spriteManager Define the sprite manager to render
  20570. */
  20571. dispatchSprites(spriteManager: ISpriteManager): void;
  20572. /**
  20573. * Add a particle system to the rendering manager in order to render it this frame.
  20574. * @param particleSystem Define the particle system to render
  20575. */
  20576. dispatchParticles(particleSystem: IParticleSystem): void;
  20577. /**
  20578. * Add a submesh to the manager in order to render it this frame
  20579. * @param subMesh The submesh to dispatch
  20580. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20581. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20582. */
  20583. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20584. /**
  20585. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20586. * This allowed control for front to back rendering or reversly depending of the special needs.
  20587. *
  20588. * @param renderingGroupId The rendering group id corresponding to its index
  20589. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20590. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20591. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20592. */
  20593. 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;
  20594. /**
  20595. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20596. *
  20597. * @param renderingGroupId The rendering group id corresponding to its index
  20598. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20599. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20600. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20601. */
  20602. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20603. /**
  20604. * Gets the current auto clear configuration for one rendering group of the rendering
  20605. * manager.
  20606. * @param index the rendering group index to get the information for
  20607. * @returns The auto clear setup for the requested rendering group
  20608. */
  20609. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20610. }
  20611. }
  20612. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20613. import { Observable } from "babylonjs/Misc/observable";
  20614. import { SmartArray } from "babylonjs/Misc/smartArray";
  20615. import { Nullable } from "babylonjs/types";
  20616. import { Camera } from "babylonjs/Cameras/camera";
  20617. import { Scene } from "babylonjs/scene";
  20618. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20619. import { Color4 } from "babylonjs/Maths/math.color";
  20620. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20622. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20623. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20624. import { Texture } from "babylonjs/Materials/Textures/texture";
  20625. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20626. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20627. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20628. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20629. import { Engine } from "babylonjs/Engines/engine";
  20630. /**
  20631. * This Helps creating a texture that will be created from a camera in your scene.
  20632. * It is basically a dynamic texture that could be used to create special effects for instance.
  20633. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20634. */
  20635. export class RenderTargetTexture extends Texture {
  20636. isCube: boolean;
  20637. /**
  20638. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20639. */
  20640. static readonly REFRESHRATE_RENDER_ONCE: number;
  20641. /**
  20642. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20643. */
  20644. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20645. /**
  20646. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20647. * the central point of your effect and can save a lot of performances.
  20648. */
  20649. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20650. /**
  20651. * Use this predicate to dynamically define the list of mesh you want to render.
  20652. * If set, the renderList property will be overwritten.
  20653. */
  20654. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20655. private _renderList;
  20656. /**
  20657. * Use this list to define the list of mesh you want to render.
  20658. */
  20659. renderList: Nullable<Array<AbstractMesh>>;
  20660. private _hookArray;
  20661. /**
  20662. * Define if particles should be rendered in your texture.
  20663. */
  20664. renderParticles: boolean;
  20665. /**
  20666. * Define if sprites should be rendered in your texture.
  20667. */
  20668. renderSprites: boolean;
  20669. /**
  20670. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20671. */
  20672. coordinatesMode: number;
  20673. /**
  20674. * Define the camera used to render the texture.
  20675. */
  20676. activeCamera: Nullable<Camera>;
  20677. /**
  20678. * Override the render function of the texture with your own one.
  20679. */
  20680. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20681. /**
  20682. * Define if camera post processes should be use while rendering the texture.
  20683. */
  20684. useCameraPostProcesses: boolean;
  20685. /**
  20686. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20687. */
  20688. ignoreCameraViewport: boolean;
  20689. private _postProcessManager;
  20690. private _postProcesses;
  20691. private _resizeObserver;
  20692. /**
  20693. * An event triggered when the texture is unbind.
  20694. */
  20695. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20696. /**
  20697. * An event triggered when the texture is unbind.
  20698. */
  20699. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20700. private _onAfterUnbindObserver;
  20701. /**
  20702. * Set a after unbind callback in the texture.
  20703. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20704. */
  20705. onAfterUnbind: () => void;
  20706. /**
  20707. * An event triggered before rendering the texture
  20708. */
  20709. onBeforeRenderObservable: Observable<number>;
  20710. private _onBeforeRenderObserver;
  20711. /**
  20712. * Set a before render callback in the texture.
  20713. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20714. */
  20715. onBeforeRender: (faceIndex: number) => void;
  20716. /**
  20717. * An event triggered after rendering the texture
  20718. */
  20719. onAfterRenderObservable: Observable<number>;
  20720. private _onAfterRenderObserver;
  20721. /**
  20722. * Set a after render callback in the texture.
  20723. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20724. */
  20725. onAfterRender: (faceIndex: number) => void;
  20726. /**
  20727. * An event triggered after the texture clear
  20728. */
  20729. onClearObservable: Observable<Engine>;
  20730. private _onClearObserver;
  20731. /**
  20732. * Set a clear callback in the texture.
  20733. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20734. */
  20735. onClear: (Engine: Engine) => void;
  20736. /**
  20737. * An event triggered when the texture is resized.
  20738. */
  20739. onResizeObservable: Observable<RenderTargetTexture>;
  20740. /**
  20741. * Define the clear color of the Render Target if it should be different from the scene.
  20742. */
  20743. clearColor: Color4;
  20744. protected _size: number | {
  20745. width: number;
  20746. height: number;
  20747. };
  20748. protected _initialSizeParameter: number | {
  20749. width: number;
  20750. height: number;
  20751. } | {
  20752. ratio: number;
  20753. };
  20754. protected _sizeRatio: Nullable<number>;
  20755. /** @hidden */
  20756. _generateMipMaps: boolean;
  20757. protected _renderingManager: RenderingManager;
  20758. /** @hidden */
  20759. _waitingRenderList: string[];
  20760. protected _doNotChangeAspectRatio: boolean;
  20761. protected _currentRefreshId: number;
  20762. protected _refreshRate: number;
  20763. protected _textureMatrix: Matrix;
  20764. protected _samples: number;
  20765. protected _renderTargetOptions: RenderTargetCreationOptions;
  20766. /**
  20767. * Gets render target creation options that were used.
  20768. */
  20769. readonly renderTargetOptions: RenderTargetCreationOptions;
  20770. protected _engine: Engine;
  20771. protected _onRatioRescale(): void;
  20772. /**
  20773. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20774. * It must define where the camera used to render the texture is set
  20775. */
  20776. boundingBoxPosition: Vector3;
  20777. private _boundingBoxSize;
  20778. /**
  20779. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20780. * When defined, the cubemap will switch to local mode
  20781. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20782. * @example https://www.babylonjs-playground.com/#RNASML
  20783. */
  20784. boundingBoxSize: Vector3;
  20785. /**
  20786. * In case the RTT has been created with a depth texture, get the associated
  20787. * depth texture.
  20788. * Otherwise, return null.
  20789. */
  20790. depthStencilTexture: Nullable<InternalTexture>;
  20791. /**
  20792. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20793. * or used a shadow, depth texture...
  20794. * @param name The friendly name of the texture
  20795. * @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)
  20796. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20797. * @param generateMipMaps True if mip maps need to be generated after render.
  20798. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20799. * @param type The type of the buffer in the RTT (int, half float, float...)
  20800. * @param isCube True if a cube texture needs to be created
  20801. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20802. * @param generateDepthBuffer True to generate a depth buffer
  20803. * @param generateStencilBuffer True to generate a stencil buffer
  20804. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20805. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20806. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20807. */
  20808. constructor(name: string, size: number | {
  20809. width: number;
  20810. height: number;
  20811. } | {
  20812. ratio: number;
  20813. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20814. /**
  20815. * Creates a depth stencil texture.
  20816. * This is only available in WebGL 2 or with the depth texture extension available.
  20817. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20818. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20819. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20820. */
  20821. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20822. private _processSizeParameter;
  20823. /**
  20824. * Define the number of samples to use in case of MSAA.
  20825. * It defaults to one meaning no MSAA has been enabled.
  20826. */
  20827. samples: number;
  20828. /**
  20829. * Resets the refresh counter of the texture and start bak from scratch.
  20830. * Could be useful to regenerate the texture if it is setup to render only once.
  20831. */
  20832. resetRefreshCounter(): void;
  20833. /**
  20834. * Define the refresh rate of the texture or the rendering frequency.
  20835. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20836. */
  20837. refreshRate: number;
  20838. /**
  20839. * Adds a post process to the render target rendering passes.
  20840. * @param postProcess define the post process to add
  20841. */
  20842. addPostProcess(postProcess: PostProcess): void;
  20843. /**
  20844. * Clear all the post processes attached to the render target
  20845. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20846. */
  20847. clearPostProcesses(dispose?: boolean): void;
  20848. /**
  20849. * Remove one of the post process from the list of attached post processes to the texture
  20850. * @param postProcess define the post process to remove from the list
  20851. */
  20852. removePostProcess(postProcess: PostProcess): void;
  20853. /** @hidden */
  20854. _shouldRender(): boolean;
  20855. /**
  20856. * Gets the actual render size of the texture.
  20857. * @returns the width of the render size
  20858. */
  20859. getRenderSize(): number;
  20860. /**
  20861. * Gets the actual render width of the texture.
  20862. * @returns the width of the render size
  20863. */
  20864. getRenderWidth(): number;
  20865. /**
  20866. * Gets the actual render height of the texture.
  20867. * @returns the height of the render size
  20868. */
  20869. getRenderHeight(): number;
  20870. /**
  20871. * Get if the texture can be rescaled or not.
  20872. */
  20873. readonly canRescale: boolean;
  20874. /**
  20875. * Resize the texture using a ratio.
  20876. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20877. */
  20878. scale(ratio: number): void;
  20879. /**
  20880. * Get the texture reflection matrix used to rotate/transform the reflection.
  20881. * @returns the reflection matrix
  20882. */
  20883. getReflectionTextureMatrix(): Matrix;
  20884. /**
  20885. * Resize the texture to a new desired size.
  20886. * Be carrefull as it will recreate all the data in the new texture.
  20887. * @param size Define the new size. It can be:
  20888. * - a number for squared texture,
  20889. * - an object containing { width: number, height: number }
  20890. * - or an object containing a ratio { ratio: number }
  20891. */
  20892. resize(size: number | {
  20893. width: number;
  20894. height: number;
  20895. } | {
  20896. ratio: number;
  20897. }): void;
  20898. /**
  20899. * Renders all the objects from the render list into the texture.
  20900. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20901. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20902. */
  20903. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20904. private _bestReflectionRenderTargetDimension;
  20905. /**
  20906. * @hidden
  20907. * @param faceIndex face index to bind to if this is a cubetexture
  20908. */
  20909. _bindFrameBuffer(faceIndex?: number): void;
  20910. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20911. private renderToTarget;
  20912. /**
  20913. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20914. * This allowed control for front to back rendering or reversly depending of the special needs.
  20915. *
  20916. * @param renderingGroupId The rendering group id corresponding to its index
  20917. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20918. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20919. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20920. */
  20921. 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;
  20922. /**
  20923. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20924. *
  20925. * @param renderingGroupId The rendering group id corresponding to its index
  20926. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20927. */
  20928. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20929. /**
  20930. * Clones the texture.
  20931. * @returns the cloned texture
  20932. */
  20933. clone(): RenderTargetTexture;
  20934. /**
  20935. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20936. * @returns The JSON representation of the texture
  20937. */
  20938. serialize(): any;
  20939. /**
  20940. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20941. */
  20942. disposeFramebufferObjects(): void;
  20943. /**
  20944. * Dispose the texture and release its associated resources.
  20945. */
  20946. dispose(): void;
  20947. /** @hidden */
  20948. _rebuild(): void;
  20949. /**
  20950. * Clear the info related to rendering groups preventing retention point in material dispose.
  20951. */
  20952. freeRenderingGroups(): void;
  20953. /**
  20954. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20955. * @returns the view count
  20956. */
  20957. getViewCount(): number;
  20958. }
  20959. }
  20960. declare module "babylonjs/Materials/material" {
  20961. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20962. import { SmartArray } from "babylonjs/Misc/smartArray";
  20963. import { Observable } from "babylonjs/Misc/observable";
  20964. import { Nullable } from "babylonjs/types";
  20965. import { Scene } from "babylonjs/scene";
  20966. import { Matrix } from "babylonjs/Maths/math.vector";
  20967. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20969. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20970. import { Effect } from "babylonjs/Materials/effect";
  20971. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20972. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20973. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20974. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20975. import { Mesh } from "babylonjs/Meshes/mesh";
  20976. import { Animation } from "babylonjs/Animations/animation";
  20977. /**
  20978. * Options for compiling materials.
  20979. */
  20980. export interface IMaterialCompilationOptions {
  20981. /**
  20982. * Defines whether clip planes are enabled.
  20983. */
  20984. clipPlane: boolean;
  20985. /**
  20986. * Defines whether instances are enabled.
  20987. */
  20988. useInstances: boolean;
  20989. }
  20990. /**
  20991. * Base class for the main features of a material in Babylon.js
  20992. */
  20993. export class Material implements IAnimatable {
  20994. /**
  20995. * Returns the triangle fill mode
  20996. */
  20997. static readonly TriangleFillMode: number;
  20998. /**
  20999. * Returns the wireframe mode
  21000. */
  21001. static readonly WireFrameFillMode: number;
  21002. /**
  21003. * Returns the point fill mode
  21004. */
  21005. static readonly PointFillMode: number;
  21006. /**
  21007. * Returns the point list draw mode
  21008. */
  21009. static readonly PointListDrawMode: number;
  21010. /**
  21011. * Returns the line list draw mode
  21012. */
  21013. static readonly LineListDrawMode: number;
  21014. /**
  21015. * Returns the line loop draw mode
  21016. */
  21017. static readonly LineLoopDrawMode: number;
  21018. /**
  21019. * Returns the line strip draw mode
  21020. */
  21021. static readonly LineStripDrawMode: number;
  21022. /**
  21023. * Returns the triangle strip draw mode
  21024. */
  21025. static readonly TriangleStripDrawMode: number;
  21026. /**
  21027. * Returns the triangle fan draw mode
  21028. */
  21029. static readonly TriangleFanDrawMode: number;
  21030. /**
  21031. * Stores the clock-wise side orientation
  21032. */
  21033. static readonly ClockWiseSideOrientation: number;
  21034. /**
  21035. * Stores the counter clock-wise side orientation
  21036. */
  21037. static readonly CounterClockWiseSideOrientation: number;
  21038. /**
  21039. * The dirty texture flag value
  21040. */
  21041. static readonly TextureDirtyFlag: number;
  21042. /**
  21043. * The dirty light flag value
  21044. */
  21045. static readonly LightDirtyFlag: number;
  21046. /**
  21047. * The dirty fresnel flag value
  21048. */
  21049. static readonly FresnelDirtyFlag: number;
  21050. /**
  21051. * The dirty attribute flag value
  21052. */
  21053. static readonly AttributesDirtyFlag: number;
  21054. /**
  21055. * The dirty misc flag value
  21056. */
  21057. static readonly MiscDirtyFlag: number;
  21058. /**
  21059. * The all dirty flag value
  21060. */
  21061. static readonly AllDirtyFlag: number;
  21062. /**
  21063. * The ID of the material
  21064. */
  21065. id: string;
  21066. /**
  21067. * Gets or sets the unique id of the material
  21068. */
  21069. uniqueId: number;
  21070. /**
  21071. * The name of the material
  21072. */
  21073. name: string;
  21074. /**
  21075. * Gets or sets user defined metadata
  21076. */
  21077. metadata: any;
  21078. /**
  21079. * For internal use only. Please do not use.
  21080. */
  21081. reservedDataStore: any;
  21082. /**
  21083. * Specifies if the ready state should be checked on each call
  21084. */
  21085. checkReadyOnEveryCall: boolean;
  21086. /**
  21087. * Specifies if the ready state should be checked once
  21088. */
  21089. checkReadyOnlyOnce: boolean;
  21090. /**
  21091. * The state of the material
  21092. */
  21093. state: string;
  21094. /**
  21095. * The alpha value of the material
  21096. */
  21097. protected _alpha: number;
  21098. /**
  21099. * List of inspectable custom properties (used by the Inspector)
  21100. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21101. */
  21102. inspectableCustomProperties: IInspectable[];
  21103. /**
  21104. * Sets the alpha value of the material
  21105. */
  21106. /**
  21107. * Gets the alpha value of the material
  21108. */
  21109. alpha: number;
  21110. /**
  21111. * Specifies if back face culling is enabled
  21112. */
  21113. protected _backFaceCulling: boolean;
  21114. /**
  21115. * Sets the back-face culling state
  21116. */
  21117. /**
  21118. * Gets the back-face culling state
  21119. */
  21120. backFaceCulling: boolean;
  21121. /**
  21122. * Stores the value for side orientation
  21123. */
  21124. sideOrientation: number;
  21125. /**
  21126. * Callback triggered when the material is compiled
  21127. */
  21128. onCompiled: Nullable<(effect: Effect) => void>;
  21129. /**
  21130. * Callback triggered when an error occurs
  21131. */
  21132. onError: Nullable<(effect: Effect, errors: string) => void>;
  21133. /**
  21134. * Callback triggered to get the render target textures
  21135. */
  21136. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21137. /**
  21138. * Gets a boolean indicating that current material needs to register RTT
  21139. */
  21140. readonly hasRenderTargetTextures: boolean;
  21141. /**
  21142. * Specifies if the material should be serialized
  21143. */
  21144. doNotSerialize: boolean;
  21145. /**
  21146. * @hidden
  21147. */
  21148. _storeEffectOnSubMeshes: boolean;
  21149. /**
  21150. * Stores the animations for the material
  21151. */
  21152. animations: Nullable<Array<Animation>>;
  21153. /**
  21154. * An event triggered when the material is disposed
  21155. */
  21156. onDisposeObservable: Observable<Material>;
  21157. /**
  21158. * An observer which watches for dispose events
  21159. */
  21160. private _onDisposeObserver;
  21161. private _onUnBindObservable;
  21162. /**
  21163. * Called during a dispose event
  21164. */
  21165. onDispose: () => void;
  21166. private _onBindObservable;
  21167. /**
  21168. * An event triggered when the material is bound
  21169. */
  21170. readonly onBindObservable: Observable<AbstractMesh>;
  21171. /**
  21172. * An observer which watches for bind events
  21173. */
  21174. private _onBindObserver;
  21175. /**
  21176. * Called during a bind event
  21177. */
  21178. onBind: (Mesh: AbstractMesh) => void;
  21179. /**
  21180. * An event triggered when the material is unbound
  21181. */
  21182. readonly onUnBindObservable: Observable<Material>;
  21183. /**
  21184. * Stores the value of the alpha mode
  21185. */
  21186. private _alphaMode;
  21187. /**
  21188. * Sets the value of the alpha mode.
  21189. *
  21190. * | Value | Type | Description |
  21191. * | --- | --- | --- |
  21192. * | 0 | ALPHA_DISABLE | |
  21193. * | 1 | ALPHA_ADD | |
  21194. * | 2 | ALPHA_COMBINE | |
  21195. * | 3 | ALPHA_SUBTRACT | |
  21196. * | 4 | ALPHA_MULTIPLY | |
  21197. * | 5 | ALPHA_MAXIMIZED | |
  21198. * | 6 | ALPHA_ONEONE | |
  21199. * | 7 | ALPHA_PREMULTIPLIED | |
  21200. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21201. * | 9 | ALPHA_INTERPOLATE | |
  21202. * | 10 | ALPHA_SCREENMODE | |
  21203. *
  21204. */
  21205. /**
  21206. * Gets the value of the alpha mode
  21207. */
  21208. alphaMode: number;
  21209. /**
  21210. * Stores the state of the need depth pre-pass value
  21211. */
  21212. private _needDepthPrePass;
  21213. /**
  21214. * Sets the need depth pre-pass value
  21215. */
  21216. /**
  21217. * Gets the depth pre-pass value
  21218. */
  21219. needDepthPrePass: boolean;
  21220. /**
  21221. * Specifies if depth writing should be disabled
  21222. */
  21223. disableDepthWrite: boolean;
  21224. /**
  21225. * Specifies if depth writing should be forced
  21226. */
  21227. forceDepthWrite: boolean;
  21228. /**
  21229. * Specifies the depth function that should be used. 0 means the default engine function
  21230. */
  21231. depthFunction: number;
  21232. /**
  21233. * Specifies if there should be a separate pass for culling
  21234. */
  21235. separateCullingPass: boolean;
  21236. /**
  21237. * Stores the state specifing if fog should be enabled
  21238. */
  21239. private _fogEnabled;
  21240. /**
  21241. * Sets the state for enabling fog
  21242. */
  21243. /**
  21244. * Gets the value of the fog enabled state
  21245. */
  21246. fogEnabled: boolean;
  21247. /**
  21248. * Stores the size of points
  21249. */
  21250. pointSize: number;
  21251. /**
  21252. * Stores the z offset value
  21253. */
  21254. zOffset: number;
  21255. /**
  21256. * Gets a value specifying if wireframe mode is enabled
  21257. */
  21258. /**
  21259. * Sets the state of wireframe mode
  21260. */
  21261. wireframe: boolean;
  21262. /**
  21263. * Gets the value specifying if point clouds are enabled
  21264. */
  21265. /**
  21266. * Sets the state of point cloud mode
  21267. */
  21268. pointsCloud: boolean;
  21269. /**
  21270. * Gets the material fill mode
  21271. */
  21272. /**
  21273. * Sets the material fill mode
  21274. */
  21275. fillMode: number;
  21276. /**
  21277. * @hidden
  21278. * Stores the effects for the material
  21279. */
  21280. _effect: Nullable<Effect>;
  21281. /**
  21282. * @hidden
  21283. * Specifies if the material was previously ready
  21284. */
  21285. _wasPreviouslyReady: boolean;
  21286. /**
  21287. * Specifies if uniform buffers should be used
  21288. */
  21289. private _useUBO;
  21290. /**
  21291. * Stores a reference to the scene
  21292. */
  21293. private _scene;
  21294. /**
  21295. * Stores the fill mode state
  21296. */
  21297. private _fillMode;
  21298. /**
  21299. * Specifies if the depth write state should be cached
  21300. */
  21301. private _cachedDepthWriteState;
  21302. /**
  21303. * Specifies if the depth function state should be cached
  21304. */
  21305. private _cachedDepthFunctionState;
  21306. /**
  21307. * Stores the uniform buffer
  21308. */
  21309. protected _uniformBuffer: UniformBuffer;
  21310. /** @hidden */
  21311. _indexInSceneMaterialArray: number;
  21312. /** @hidden */
  21313. meshMap: Nullable<{
  21314. [id: string]: AbstractMesh | undefined;
  21315. }>;
  21316. /**
  21317. * Creates a material instance
  21318. * @param name defines the name of the material
  21319. * @param scene defines the scene to reference
  21320. * @param doNotAdd specifies if the material should be added to the scene
  21321. */
  21322. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21323. /**
  21324. * Returns a string representation of the current material
  21325. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21326. * @returns a string with material information
  21327. */
  21328. toString(fullDetails?: boolean): string;
  21329. /**
  21330. * Gets the class name of the material
  21331. * @returns a string with the class name of the material
  21332. */
  21333. getClassName(): string;
  21334. /**
  21335. * Specifies if updates for the material been locked
  21336. */
  21337. readonly isFrozen: boolean;
  21338. /**
  21339. * Locks updates for the material
  21340. */
  21341. freeze(): void;
  21342. /**
  21343. * Unlocks updates for the material
  21344. */
  21345. unfreeze(): void;
  21346. /**
  21347. * Specifies if the material is ready to be used
  21348. * @param mesh defines the mesh to check
  21349. * @param useInstances specifies if instances should be used
  21350. * @returns a boolean indicating if the material is ready to be used
  21351. */
  21352. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21353. /**
  21354. * Specifies that the submesh is ready to be used
  21355. * @param mesh defines the mesh to check
  21356. * @param subMesh defines which submesh to check
  21357. * @param useInstances specifies that instances should be used
  21358. * @returns a boolean indicating that the submesh is ready or not
  21359. */
  21360. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21361. /**
  21362. * Returns the material effect
  21363. * @returns the effect associated with the material
  21364. */
  21365. getEffect(): Nullable<Effect>;
  21366. /**
  21367. * Returns the current scene
  21368. * @returns a Scene
  21369. */
  21370. getScene(): Scene;
  21371. /**
  21372. * Specifies if the material will require alpha blending
  21373. * @returns a boolean specifying if alpha blending is needed
  21374. */
  21375. needAlphaBlending(): boolean;
  21376. /**
  21377. * Specifies if the mesh will require alpha blending
  21378. * @param mesh defines the mesh to check
  21379. * @returns a boolean specifying if alpha blending is needed for the mesh
  21380. */
  21381. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21382. /**
  21383. * Specifies if this material should be rendered in alpha test mode
  21384. * @returns a boolean specifying if an alpha test is needed.
  21385. */
  21386. needAlphaTesting(): boolean;
  21387. /**
  21388. * Gets the texture used for the alpha test
  21389. * @returns the texture to use for alpha testing
  21390. */
  21391. getAlphaTestTexture(): Nullable<BaseTexture>;
  21392. /**
  21393. * Marks the material to indicate that it needs to be re-calculated
  21394. */
  21395. markDirty(): void;
  21396. /** @hidden */
  21397. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21398. /**
  21399. * Binds the material to the mesh
  21400. * @param world defines the world transformation matrix
  21401. * @param mesh defines the mesh to bind the material to
  21402. */
  21403. bind(world: Matrix, mesh?: Mesh): void;
  21404. /**
  21405. * Binds the submesh to the material
  21406. * @param world defines the world transformation matrix
  21407. * @param mesh defines the mesh containing the submesh
  21408. * @param subMesh defines the submesh to bind the material to
  21409. */
  21410. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21411. /**
  21412. * Binds the world matrix to the material
  21413. * @param world defines the world transformation matrix
  21414. */
  21415. bindOnlyWorldMatrix(world: Matrix): void;
  21416. /**
  21417. * Binds the scene's uniform buffer to the effect.
  21418. * @param effect defines the effect to bind to the scene uniform buffer
  21419. * @param sceneUbo defines the uniform buffer storing scene data
  21420. */
  21421. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21422. /**
  21423. * Binds the view matrix to the effect
  21424. * @param effect defines the effect to bind the view matrix to
  21425. */
  21426. bindView(effect: Effect): void;
  21427. /**
  21428. * Binds the view projection matrix to the effect
  21429. * @param effect defines the effect to bind the view projection matrix to
  21430. */
  21431. bindViewProjection(effect: Effect): void;
  21432. /**
  21433. * Specifies if material alpha testing should be turned on for the mesh
  21434. * @param mesh defines the mesh to check
  21435. */
  21436. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21437. /**
  21438. * Processes to execute after binding the material to a mesh
  21439. * @param mesh defines the rendered mesh
  21440. */
  21441. protected _afterBind(mesh?: Mesh): void;
  21442. /**
  21443. * Unbinds the material from the mesh
  21444. */
  21445. unbind(): void;
  21446. /**
  21447. * Gets the active textures from the material
  21448. * @returns an array of textures
  21449. */
  21450. getActiveTextures(): BaseTexture[];
  21451. /**
  21452. * Specifies if the material uses a texture
  21453. * @param texture defines the texture to check against the material
  21454. * @returns a boolean specifying if the material uses the texture
  21455. */
  21456. hasTexture(texture: BaseTexture): boolean;
  21457. /**
  21458. * Makes a duplicate of the material, and gives it a new name
  21459. * @param name defines the new name for the duplicated material
  21460. * @returns the cloned material
  21461. */
  21462. clone(name: string): Nullable<Material>;
  21463. /**
  21464. * Gets the meshes bound to the material
  21465. * @returns an array of meshes bound to the material
  21466. */
  21467. getBindedMeshes(): AbstractMesh[];
  21468. /**
  21469. * Force shader compilation
  21470. * @param mesh defines the mesh associated with this material
  21471. * @param onCompiled defines a function to execute once the material is compiled
  21472. * @param options defines the options to configure the compilation
  21473. * @param onError defines a function to execute if the material fails compiling
  21474. */
  21475. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21476. /**
  21477. * Force shader compilation
  21478. * @param mesh defines the mesh that will use this material
  21479. * @param options defines additional options for compiling the shaders
  21480. * @returns a promise that resolves when the compilation completes
  21481. */
  21482. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21483. private static readonly _AllDirtyCallBack;
  21484. private static readonly _ImageProcessingDirtyCallBack;
  21485. private static readonly _TextureDirtyCallBack;
  21486. private static readonly _FresnelDirtyCallBack;
  21487. private static readonly _MiscDirtyCallBack;
  21488. private static readonly _LightsDirtyCallBack;
  21489. private static readonly _AttributeDirtyCallBack;
  21490. private static _FresnelAndMiscDirtyCallBack;
  21491. private static _TextureAndMiscDirtyCallBack;
  21492. private static readonly _DirtyCallbackArray;
  21493. private static readonly _RunDirtyCallBacks;
  21494. /**
  21495. * Marks a define in the material to indicate that it needs to be re-computed
  21496. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21497. */
  21498. markAsDirty(flag: number): void;
  21499. /**
  21500. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21501. * @param func defines a function which checks material defines against the submeshes
  21502. */
  21503. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21504. /**
  21505. * Indicates that we need to re-calculated for all submeshes
  21506. */
  21507. protected _markAllSubMeshesAsAllDirty(): void;
  21508. /**
  21509. * Indicates that image processing needs to be re-calculated for all submeshes
  21510. */
  21511. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21512. /**
  21513. * Indicates that textures need to be re-calculated for all submeshes
  21514. */
  21515. protected _markAllSubMeshesAsTexturesDirty(): void;
  21516. /**
  21517. * Indicates that fresnel needs to be re-calculated for all submeshes
  21518. */
  21519. protected _markAllSubMeshesAsFresnelDirty(): void;
  21520. /**
  21521. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21522. */
  21523. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21524. /**
  21525. * Indicates that lights need to be re-calculated for all submeshes
  21526. */
  21527. protected _markAllSubMeshesAsLightsDirty(): void;
  21528. /**
  21529. * Indicates that attributes need to be re-calculated for all submeshes
  21530. */
  21531. protected _markAllSubMeshesAsAttributesDirty(): void;
  21532. /**
  21533. * Indicates that misc needs to be re-calculated for all submeshes
  21534. */
  21535. protected _markAllSubMeshesAsMiscDirty(): void;
  21536. /**
  21537. * Indicates that textures and misc need to be re-calculated for all submeshes
  21538. */
  21539. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21540. /**
  21541. * Disposes the material
  21542. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21543. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21544. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21545. */
  21546. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21547. /** @hidden */
  21548. private releaseVertexArrayObject;
  21549. /**
  21550. * Serializes this material
  21551. * @returns the serialized material object
  21552. */
  21553. serialize(): any;
  21554. /**
  21555. * Creates a material from parsed material data
  21556. * @param parsedMaterial defines parsed material data
  21557. * @param scene defines the hosting scene
  21558. * @param rootUrl defines the root URL to use to load textures
  21559. * @returns a new material
  21560. */
  21561. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21562. }
  21563. }
  21564. declare module "babylonjs/Materials/multiMaterial" {
  21565. import { Nullable } from "babylonjs/types";
  21566. import { Scene } from "babylonjs/scene";
  21567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21568. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21569. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21570. import { Material } from "babylonjs/Materials/material";
  21571. /**
  21572. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21573. * separate meshes. This can be use to improve performances.
  21574. * @see http://doc.babylonjs.com/how_to/multi_materials
  21575. */
  21576. export class MultiMaterial extends Material {
  21577. private _subMaterials;
  21578. /**
  21579. * Gets or Sets the list of Materials used within the multi material.
  21580. * They need to be ordered according to the submeshes order in the associated mesh
  21581. */
  21582. subMaterials: Nullable<Material>[];
  21583. /**
  21584. * Function used to align with Node.getChildren()
  21585. * @returns the list of Materials used within the multi material
  21586. */
  21587. getChildren(): Nullable<Material>[];
  21588. /**
  21589. * Instantiates a new Multi Material
  21590. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21591. * separate meshes. This can be use to improve performances.
  21592. * @see http://doc.babylonjs.com/how_to/multi_materials
  21593. * @param name Define the name in the scene
  21594. * @param scene Define the scene the material belongs to
  21595. */
  21596. constructor(name: string, scene: Scene);
  21597. private _hookArray;
  21598. /**
  21599. * Get one of the submaterial by its index in the submaterials array
  21600. * @param index The index to look the sub material at
  21601. * @returns The Material if the index has been defined
  21602. */
  21603. getSubMaterial(index: number): Nullable<Material>;
  21604. /**
  21605. * Get the list of active textures for the whole sub materials list.
  21606. * @returns All the textures that will be used during the rendering
  21607. */
  21608. getActiveTextures(): BaseTexture[];
  21609. /**
  21610. * Gets the current class name of the material e.g. "MultiMaterial"
  21611. * Mainly use in serialization.
  21612. * @returns the class name
  21613. */
  21614. getClassName(): string;
  21615. /**
  21616. * Checks if the material is ready to render the requested sub mesh
  21617. * @param mesh Define the mesh the submesh belongs to
  21618. * @param subMesh Define the sub mesh to look readyness for
  21619. * @param useInstances Define whether or not the material is used with instances
  21620. * @returns true if ready, otherwise false
  21621. */
  21622. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21623. /**
  21624. * Clones the current material and its related sub materials
  21625. * @param name Define the name of the newly cloned material
  21626. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21627. * @returns the cloned material
  21628. */
  21629. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21630. /**
  21631. * Serializes the materials into a JSON representation.
  21632. * @returns the JSON representation
  21633. */
  21634. serialize(): any;
  21635. /**
  21636. * Dispose the material and release its associated resources
  21637. * @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)
  21638. * @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)
  21639. * @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)
  21640. */
  21641. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21642. /**
  21643. * Creates a MultiMaterial from parsed MultiMaterial data.
  21644. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21645. * @param scene defines the hosting scene
  21646. * @returns a new MultiMaterial
  21647. */
  21648. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21649. }
  21650. }
  21651. declare module "babylonjs/Meshes/subMesh" {
  21652. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21653. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21654. import { Engine } from "babylonjs/Engines/engine";
  21655. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21656. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21657. import { Effect } from "babylonjs/Materials/effect";
  21658. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21659. import { Plane } from "babylonjs/Maths/math.plane";
  21660. import { Collider } from "babylonjs/Collisions/collider";
  21661. import { Material } from "babylonjs/Materials/material";
  21662. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21664. import { Mesh } from "babylonjs/Meshes/mesh";
  21665. import { Ray } from "babylonjs/Culling/ray";
  21666. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21667. /**
  21668. * Base class for submeshes
  21669. */
  21670. export class BaseSubMesh {
  21671. /** @hidden */
  21672. _materialDefines: Nullable<MaterialDefines>;
  21673. /** @hidden */
  21674. _materialEffect: Nullable<Effect>;
  21675. /**
  21676. * Gets associated effect
  21677. */
  21678. readonly effect: Nullable<Effect>;
  21679. /**
  21680. * Sets associated effect (effect used to render this submesh)
  21681. * @param effect defines the effect to associate with
  21682. * @param defines defines the set of defines used to compile this effect
  21683. */
  21684. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21685. }
  21686. /**
  21687. * Defines a subdivision inside a mesh
  21688. */
  21689. export class SubMesh extends BaseSubMesh implements ICullable {
  21690. /** the material index to use */
  21691. materialIndex: number;
  21692. /** vertex index start */
  21693. verticesStart: number;
  21694. /** vertices count */
  21695. verticesCount: number;
  21696. /** index start */
  21697. indexStart: number;
  21698. /** indices count */
  21699. indexCount: number;
  21700. /** @hidden */
  21701. _linesIndexCount: number;
  21702. private _mesh;
  21703. private _renderingMesh;
  21704. private _boundingInfo;
  21705. private _linesIndexBuffer;
  21706. /** @hidden */
  21707. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21708. /** @hidden */
  21709. _trianglePlanes: Plane[];
  21710. /** @hidden */
  21711. _lastColliderTransformMatrix: Nullable<Matrix>;
  21712. /** @hidden */
  21713. _renderId: number;
  21714. /** @hidden */
  21715. _alphaIndex: number;
  21716. /** @hidden */
  21717. _distanceToCamera: number;
  21718. /** @hidden */
  21719. _id: number;
  21720. private _currentMaterial;
  21721. /**
  21722. * Add a new submesh to a mesh
  21723. * @param materialIndex defines the material index to use
  21724. * @param verticesStart defines vertex index start
  21725. * @param verticesCount defines vertices count
  21726. * @param indexStart defines index start
  21727. * @param indexCount defines indices count
  21728. * @param mesh defines the parent mesh
  21729. * @param renderingMesh defines an optional rendering mesh
  21730. * @param createBoundingBox defines if bounding box should be created for this submesh
  21731. * @returns the new submesh
  21732. */
  21733. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21734. /**
  21735. * Creates a new submesh
  21736. * @param materialIndex defines the material index to use
  21737. * @param verticesStart defines vertex index start
  21738. * @param verticesCount defines vertices count
  21739. * @param indexStart defines index start
  21740. * @param indexCount defines indices count
  21741. * @param mesh defines the parent mesh
  21742. * @param renderingMesh defines an optional rendering mesh
  21743. * @param createBoundingBox defines if bounding box should be created for this submesh
  21744. */
  21745. constructor(
  21746. /** the material index to use */
  21747. materialIndex: number,
  21748. /** vertex index start */
  21749. verticesStart: number,
  21750. /** vertices count */
  21751. verticesCount: number,
  21752. /** index start */
  21753. indexStart: number,
  21754. /** indices count */
  21755. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21756. /**
  21757. * Returns true if this submesh covers the entire parent mesh
  21758. * @ignorenaming
  21759. */
  21760. readonly IsGlobal: boolean;
  21761. /**
  21762. * Returns the submesh BoudingInfo object
  21763. * @returns current bounding info (or mesh's one if the submesh is global)
  21764. */
  21765. getBoundingInfo(): BoundingInfo;
  21766. /**
  21767. * Sets the submesh BoundingInfo
  21768. * @param boundingInfo defines the new bounding info to use
  21769. * @returns the SubMesh
  21770. */
  21771. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21772. /**
  21773. * Returns the mesh of the current submesh
  21774. * @return the parent mesh
  21775. */
  21776. getMesh(): AbstractMesh;
  21777. /**
  21778. * Returns the rendering mesh of the submesh
  21779. * @returns the rendering mesh (could be different from parent mesh)
  21780. */
  21781. getRenderingMesh(): Mesh;
  21782. /**
  21783. * Returns the submesh material
  21784. * @returns null or the current material
  21785. */
  21786. getMaterial(): Nullable<Material>;
  21787. /**
  21788. * Sets a new updated BoundingInfo object to the submesh
  21789. * @param data defines an optional position array to use to determine the bounding info
  21790. * @returns the SubMesh
  21791. */
  21792. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21793. /** @hidden */
  21794. _checkCollision(collider: Collider): boolean;
  21795. /**
  21796. * Updates the submesh BoundingInfo
  21797. * @param world defines the world matrix to use to update the bounding info
  21798. * @returns the submesh
  21799. */
  21800. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21801. /**
  21802. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21803. * @param frustumPlanes defines the frustum planes
  21804. * @returns true if the submesh is intersecting with the frustum
  21805. */
  21806. isInFrustum(frustumPlanes: Plane[]): boolean;
  21807. /**
  21808. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21809. * @param frustumPlanes defines the frustum planes
  21810. * @returns true if the submesh is inside the frustum
  21811. */
  21812. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21813. /**
  21814. * Renders the submesh
  21815. * @param enableAlphaMode defines if alpha needs to be used
  21816. * @returns the submesh
  21817. */
  21818. render(enableAlphaMode: boolean): SubMesh;
  21819. /**
  21820. * @hidden
  21821. */
  21822. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21823. /**
  21824. * Checks if the submesh intersects with a ray
  21825. * @param ray defines the ray to test
  21826. * @returns true is the passed ray intersects the submesh bounding box
  21827. */
  21828. canIntersects(ray: Ray): boolean;
  21829. /**
  21830. * Intersects current submesh with a ray
  21831. * @param ray defines the ray to test
  21832. * @param positions defines mesh's positions array
  21833. * @param indices defines mesh's indices array
  21834. * @param fastCheck defines if only bounding info should be used
  21835. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21836. * @returns intersection info or null if no intersection
  21837. */
  21838. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21839. /** @hidden */
  21840. private _intersectLines;
  21841. /** @hidden */
  21842. private _intersectUnIndexedLines;
  21843. /** @hidden */
  21844. private _intersectTriangles;
  21845. /** @hidden */
  21846. private _intersectUnIndexedTriangles;
  21847. /** @hidden */
  21848. _rebuild(): void;
  21849. /**
  21850. * Creates a new submesh from the passed mesh
  21851. * @param newMesh defines the new hosting mesh
  21852. * @param newRenderingMesh defines an optional rendering mesh
  21853. * @returns the new submesh
  21854. */
  21855. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21856. /**
  21857. * Release associated resources
  21858. */
  21859. dispose(): void;
  21860. /**
  21861. * Gets the class name
  21862. * @returns the string "SubMesh".
  21863. */
  21864. getClassName(): string;
  21865. /**
  21866. * Creates a new submesh from indices data
  21867. * @param materialIndex the index of the main mesh material
  21868. * @param startIndex the index where to start the copy in the mesh indices array
  21869. * @param indexCount the number of indices to copy then from the startIndex
  21870. * @param mesh the main mesh to create the submesh from
  21871. * @param renderingMesh the optional rendering mesh
  21872. * @returns a new submesh
  21873. */
  21874. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21875. }
  21876. }
  21877. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21878. /**
  21879. * Class used to represent data loading progression
  21880. */
  21881. export class SceneLoaderFlags {
  21882. private static _ForceFullSceneLoadingForIncremental;
  21883. private static _ShowLoadingScreen;
  21884. private static _CleanBoneMatrixWeights;
  21885. private static _loggingLevel;
  21886. /**
  21887. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21888. */
  21889. static ForceFullSceneLoadingForIncremental: boolean;
  21890. /**
  21891. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21892. */
  21893. static ShowLoadingScreen: boolean;
  21894. /**
  21895. * Defines the current logging level (while loading the scene)
  21896. * @ignorenaming
  21897. */
  21898. static loggingLevel: number;
  21899. /**
  21900. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21901. */
  21902. static CleanBoneMatrixWeights: boolean;
  21903. }
  21904. }
  21905. declare module "babylonjs/Meshes/geometry" {
  21906. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21907. import { Scene } from "babylonjs/scene";
  21908. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21909. import { Engine } from "babylonjs/Engines/engine";
  21910. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21911. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21912. import { Effect } from "babylonjs/Materials/effect";
  21913. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21914. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21915. import { Mesh } from "babylonjs/Meshes/mesh";
  21916. /**
  21917. * Class used to store geometry data (vertex buffers + index buffer)
  21918. */
  21919. export class Geometry implements IGetSetVerticesData {
  21920. /**
  21921. * Gets or sets the ID of the geometry
  21922. */
  21923. id: string;
  21924. /**
  21925. * Gets or sets the unique ID of the geometry
  21926. */
  21927. uniqueId: number;
  21928. /**
  21929. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21930. */
  21931. delayLoadState: number;
  21932. /**
  21933. * Gets the file containing the data to load when running in delay load state
  21934. */
  21935. delayLoadingFile: Nullable<string>;
  21936. /**
  21937. * Callback called when the geometry is updated
  21938. */
  21939. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21940. private _scene;
  21941. private _engine;
  21942. private _meshes;
  21943. private _totalVertices;
  21944. /** @hidden */
  21945. _indices: IndicesArray;
  21946. /** @hidden */
  21947. _vertexBuffers: {
  21948. [key: string]: VertexBuffer;
  21949. };
  21950. private _isDisposed;
  21951. private _extend;
  21952. private _boundingBias;
  21953. /** @hidden */
  21954. _delayInfo: Array<string>;
  21955. private _indexBuffer;
  21956. private _indexBufferIsUpdatable;
  21957. /** @hidden */
  21958. _boundingInfo: Nullable<BoundingInfo>;
  21959. /** @hidden */
  21960. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21961. /** @hidden */
  21962. _softwareSkinningFrameId: number;
  21963. private _vertexArrayObjects;
  21964. private _updatable;
  21965. /** @hidden */
  21966. _positions: Nullable<Vector3[]>;
  21967. /**
  21968. * 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
  21969. */
  21970. /**
  21971. * 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
  21972. */
  21973. boundingBias: Vector2;
  21974. /**
  21975. * Static function used to attach a new empty geometry to a mesh
  21976. * @param mesh defines the mesh to attach the geometry to
  21977. * @returns the new Geometry
  21978. */
  21979. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21980. /**
  21981. * Creates a new geometry
  21982. * @param id defines the unique ID
  21983. * @param scene defines the hosting scene
  21984. * @param vertexData defines the VertexData used to get geometry data
  21985. * @param updatable defines if geometry must be updatable (false by default)
  21986. * @param mesh defines the mesh that will be associated with the geometry
  21987. */
  21988. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21989. /**
  21990. * Gets the current extend of the geometry
  21991. */
  21992. readonly extend: {
  21993. minimum: Vector3;
  21994. maximum: Vector3;
  21995. };
  21996. /**
  21997. * Gets the hosting scene
  21998. * @returns the hosting Scene
  21999. */
  22000. getScene(): Scene;
  22001. /**
  22002. * Gets the hosting engine
  22003. * @returns the hosting Engine
  22004. */
  22005. getEngine(): Engine;
  22006. /**
  22007. * Defines if the geometry is ready to use
  22008. * @returns true if the geometry is ready to be used
  22009. */
  22010. isReady(): boolean;
  22011. /**
  22012. * Gets a value indicating that the geometry should not be serialized
  22013. */
  22014. readonly doNotSerialize: boolean;
  22015. /** @hidden */
  22016. _rebuild(): void;
  22017. /**
  22018. * Affects all geometry data in one call
  22019. * @param vertexData defines the geometry data
  22020. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22021. */
  22022. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22023. /**
  22024. * Set specific vertex data
  22025. * @param kind defines the data kind (Position, normal, etc...)
  22026. * @param data defines the vertex data to use
  22027. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22028. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22029. */
  22030. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22031. /**
  22032. * Removes a specific vertex data
  22033. * @param kind defines the data kind (Position, normal, etc...)
  22034. */
  22035. removeVerticesData(kind: string): void;
  22036. /**
  22037. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22038. * @param buffer defines the vertex buffer to use
  22039. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22040. */
  22041. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22042. /**
  22043. * Update a specific vertex buffer
  22044. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22045. * It will do nothing if the buffer is not updatable
  22046. * @param kind defines the data kind (Position, normal, etc...)
  22047. * @param data defines the data to use
  22048. * @param offset defines the offset in the target buffer where to store the data
  22049. * @param useBytes set to true if the offset is in bytes
  22050. */
  22051. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22052. /**
  22053. * Update a specific vertex buffer
  22054. * This function will create a new buffer if the current one is not updatable
  22055. * @param kind defines the data kind (Position, normal, etc...)
  22056. * @param data defines the data to use
  22057. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22058. */
  22059. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22060. private _updateBoundingInfo;
  22061. /** @hidden */
  22062. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22063. /**
  22064. * Gets total number of vertices
  22065. * @returns the total number of vertices
  22066. */
  22067. getTotalVertices(): number;
  22068. /**
  22069. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22070. * @param kind defines the data kind (Position, normal, etc...)
  22071. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22072. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22073. * @returns a float array containing vertex data
  22074. */
  22075. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22076. /**
  22077. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22078. * @param kind defines the data kind (Position, normal, etc...)
  22079. * @returns true if the vertex buffer with the specified kind is updatable
  22080. */
  22081. isVertexBufferUpdatable(kind: string): boolean;
  22082. /**
  22083. * Gets a specific vertex buffer
  22084. * @param kind defines the data kind (Position, normal, etc...)
  22085. * @returns a VertexBuffer
  22086. */
  22087. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22088. /**
  22089. * Returns all vertex buffers
  22090. * @return an object holding all vertex buffers indexed by kind
  22091. */
  22092. getVertexBuffers(): Nullable<{
  22093. [key: string]: VertexBuffer;
  22094. }>;
  22095. /**
  22096. * Gets a boolean indicating if specific vertex buffer is present
  22097. * @param kind defines the data kind (Position, normal, etc...)
  22098. * @returns true if data is present
  22099. */
  22100. isVerticesDataPresent(kind: string): boolean;
  22101. /**
  22102. * Gets a list of all attached data kinds (Position, normal, etc...)
  22103. * @returns a list of string containing all kinds
  22104. */
  22105. getVerticesDataKinds(): string[];
  22106. /**
  22107. * Update index buffer
  22108. * @param indices defines the indices to store in the index buffer
  22109. * @param offset defines the offset in the target buffer where to store the data
  22110. * @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)
  22111. */
  22112. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22113. /**
  22114. * Creates a new index buffer
  22115. * @param indices defines the indices to store in the index buffer
  22116. * @param totalVertices defines the total number of vertices (could be null)
  22117. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22118. */
  22119. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22120. /**
  22121. * Return the total number of indices
  22122. * @returns the total number of indices
  22123. */
  22124. getTotalIndices(): number;
  22125. /**
  22126. * Gets the index buffer array
  22127. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22128. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22129. * @returns the index buffer array
  22130. */
  22131. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22132. /**
  22133. * Gets the index buffer
  22134. * @return the index buffer
  22135. */
  22136. getIndexBuffer(): Nullable<DataBuffer>;
  22137. /** @hidden */
  22138. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22139. /**
  22140. * Release the associated resources for a specific mesh
  22141. * @param mesh defines the source mesh
  22142. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22143. */
  22144. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22145. /**
  22146. * Apply current geometry to a given mesh
  22147. * @param mesh defines the mesh to apply geometry to
  22148. */
  22149. applyToMesh(mesh: Mesh): void;
  22150. private _updateExtend;
  22151. private _applyToMesh;
  22152. private notifyUpdate;
  22153. /**
  22154. * Load the geometry if it was flagged as delay loaded
  22155. * @param scene defines the hosting scene
  22156. * @param onLoaded defines a callback called when the geometry is loaded
  22157. */
  22158. load(scene: Scene, onLoaded?: () => void): void;
  22159. private _queueLoad;
  22160. /**
  22161. * Invert the geometry to move from a right handed system to a left handed one.
  22162. */
  22163. toLeftHanded(): void;
  22164. /** @hidden */
  22165. _resetPointsArrayCache(): void;
  22166. /** @hidden */
  22167. _generatePointsArray(): boolean;
  22168. /**
  22169. * Gets a value indicating if the geometry is disposed
  22170. * @returns true if the geometry was disposed
  22171. */
  22172. isDisposed(): boolean;
  22173. private _disposeVertexArrayObjects;
  22174. /**
  22175. * Free all associated resources
  22176. */
  22177. dispose(): void;
  22178. /**
  22179. * Clone the current geometry into a new geometry
  22180. * @param id defines the unique ID of the new geometry
  22181. * @returns a new geometry object
  22182. */
  22183. copy(id: string): Geometry;
  22184. /**
  22185. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22186. * @return a JSON representation of the current geometry data (without the vertices data)
  22187. */
  22188. serialize(): any;
  22189. private toNumberArray;
  22190. /**
  22191. * Serialize all vertices data into a JSON oject
  22192. * @returns a JSON representation of the current geometry data
  22193. */
  22194. serializeVerticeData(): any;
  22195. /**
  22196. * Extracts a clone of a mesh geometry
  22197. * @param mesh defines the source mesh
  22198. * @param id defines the unique ID of the new geometry object
  22199. * @returns the new geometry object
  22200. */
  22201. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22202. /**
  22203. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22204. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22205. * Be aware Math.random() could cause collisions, but:
  22206. * "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"
  22207. * @returns a string containing a new GUID
  22208. */
  22209. static RandomId(): string;
  22210. /** @hidden */
  22211. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22212. private static _CleanMatricesWeights;
  22213. /**
  22214. * Create a new geometry from persisted data (Using .babylon file format)
  22215. * @param parsedVertexData defines the persisted data
  22216. * @param scene defines the hosting scene
  22217. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22218. * @returns the new geometry object
  22219. */
  22220. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22221. }
  22222. }
  22223. declare module "babylonjs/Meshes/mesh.vertexData" {
  22224. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22225. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22226. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22227. import { Geometry } from "babylonjs/Meshes/geometry";
  22228. import { Mesh } from "babylonjs/Meshes/mesh";
  22229. /**
  22230. * Define an interface for all classes that will get and set the data on vertices
  22231. */
  22232. export interface IGetSetVerticesData {
  22233. /**
  22234. * Gets a boolean indicating if specific vertex data is present
  22235. * @param kind defines the vertex data kind to use
  22236. * @returns true is data kind is present
  22237. */
  22238. isVerticesDataPresent(kind: string): boolean;
  22239. /**
  22240. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22241. * @param kind defines the data kind (Position, normal, etc...)
  22242. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22243. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22244. * @returns a float array containing vertex data
  22245. */
  22246. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22247. /**
  22248. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22249. * @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.
  22250. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22251. * @returns the indices array or an empty array if the mesh has no geometry
  22252. */
  22253. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22254. /**
  22255. * Set specific vertex data
  22256. * @param kind defines the data kind (Position, normal, etc...)
  22257. * @param data defines the vertex data to use
  22258. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22259. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22260. */
  22261. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22262. /**
  22263. * Update a specific associated vertex buffer
  22264. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22265. * - VertexBuffer.PositionKind
  22266. * - VertexBuffer.UVKind
  22267. * - VertexBuffer.UV2Kind
  22268. * - VertexBuffer.UV3Kind
  22269. * - VertexBuffer.UV4Kind
  22270. * - VertexBuffer.UV5Kind
  22271. * - VertexBuffer.UV6Kind
  22272. * - VertexBuffer.ColorKind
  22273. * - VertexBuffer.MatricesIndicesKind
  22274. * - VertexBuffer.MatricesIndicesExtraKind
  22275. * - VertexBuffer.MatricesWeightsKind
  22276. * - VertexBuffer.MatricesWeightsExtraKind
  22277. * @param data defines the data source
  22278. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22279. * @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)
  22280. */
  22281. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22282. /**
  22283. * Creates a new index buffer
  22284. * @param indices defines the indices to store in the index buffer
  22285. * @param totalVertices defines the total number of vertices (could be null)
  22286. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22287. */
  22288. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22289. }
  22290. /**
  22291. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22292. */
  22293. export class VertexData {
  22294. /**
  22295. * Mesh side orientation : usually the external or front surface
  22296. */
  22297. static readonly FRONTSIDE: number;
  22298. /**
  22299. * Mesh side orientation : usually the internal or back surface
  22300. */
  22301. static readonly BACKSIDE: number;
  22302. /**
  22303. * Mesh side orientation : both internal and external or front and back surfaces
  22304. */
  22305. static readonly DOUBLESIDE: number;
  22306. /**
  22307. * Mesh side orientation : by default, `FRONTSIDE`
  22308. */
  22309. static readonly DEFAULTSIDE: number;
  22310. /**
  22311. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22312. */
  22313. positions: Nullable<FloatArray>;
  22314. /**
  22315. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22316. */
  22317. normals: Nullable<FloatArray>;
  22318. /**
  22319. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22320. */
  22321. tangents: Nullable<FloatArray>;
  22322. /**
  22323. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22324. */
  22325. uvs: Nullable<FloatArray>;
  22326. /**
  22327. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22328. */
  22329. uvs2: Nullable<FloatArray>;
  22330. /**
  22331. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22332. */
  22333. uvs3: Nullable<FloatArray>;
  22334. /**
  22335. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22336. */
  22337. uvs4: Nullable<FloatArray>;
  22338. /**
  22339. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22340. */
  22341. uvs5: Nullable<FloatArray>;
  22342. /**
  22343. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22344. */
  22345. uvs6: Nullable<FloatArray>;
  22346. /**
  22347. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22348. */
  22349. colors: Nullable<FloatArray>;
  22350. /**
  22351. * 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).
  22352. */
  22353. matricesIndices: Nullable<FloatArray>;
  22354. /**
  22355. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22356. */
  22357. matricesWeights: Nullable<FloatArray>;
  22358. /**
  22359. * An array extending the number of possible indices
  22360. */
  22361. matricesIndicesExtra: Nullable<FloatArray>;
  22362. /**
  22363. * An array extending the number of possible weights when the number of indices is extended
  22364. */
  22365. matricesWeightsExtra: Nullable<FloatArray>;
  22366. /**
  22367. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22368. */
  22369. indices: Nullable<IndicesArray>;
  22370. /**
  22371. * Uses the passed data array to set the set the values for the specified kind of data
  22372. * @param data a linear array of floating numbers
  22373. * @param kind the type of data that is being set, eg positions, colors etc
  22374. */
  22375. set(data: FloatArray, kind: string): void;
  22376. /**
  22377. * Associates the vertexData to the passed Mesh.
  22378. * Sets it as updatable or not (default `false`)
  22379. * @param mesh the mesh the vertexData is applied to
  22380. * @param updatable when used and having the value true allows new data to update the vertexData
  22381. * @returns the VertexData
  22382. */
  22383. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22384. /**
  22385. * Associates the vertexData to the passed Geometry.
  22386. * Sets it as updatable or not (default `false`)
  22387. * @param geometry the geometry the vertexData is applied to
  22388. * @param updatable when used and having the value true allows new data to update the vertexData
  22389. * @returns VertexData
  22390. */
  22391. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22392. /**
  22393. * Updates the associated mesh
  22394. * @param mesh the mesh to be updated
  22395. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22396. * @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
  22397. * @returns VertexData
  22398. */
  22399. updateMesh(mesh: Mesh): VertexData;
  22400. /**
  22401. * Updates the associated geometry
  22402. * @param geometry the geometry to be updated
  22403. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22404. * @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
  22405. * @returns VertexData.
  22406. */
  22407. updateGeometry(geometry: Geometry): VertexData;
  22408. private _applyTo;
  22409. private _update;
  22410. /**
  22411. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22412. * @param matrix the transforming matrix
  22413. * @returns the VertexData
  22414. */
  22415. transform(matrix: Matrix): VertexData;
  22416. /**
  22417. * Merges the passed VertexData into the current one
  22418. * @param other the VertexData to be merged into the current one
  22419. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22420. * @returns the modified VertexData
  22421. */
  22422. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22423. private _mergeElement;
  22424. private _validate;
  22425. /**
  22426. * Serializes the VertexData
  22427. * @returns a serialized object
  22428. */
  22429. serialize(): any;
  22430. /**
  22431. * Extracts the vertexData from a mesh
  22432. * @param mesh the mesh from which to extract the VertexData
  22433. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22434. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22435. * @returns the object VertexData associated to the passed mesh
  22436. */
  22437. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22438. /**
  22439. * Extracts the vertexData from the geometry
  22440. * @param geometry the geometry from which to extract the VertexData
  22441. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22442. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22443. * @returns the object VertexData associated to the passed mesh
  22444. */
  22445. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22446. private static _ExtractFrom;
  22447. /**
  22448. * Creates the VertexData for a Ribbon
  22449. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22450. * * pathArray array of paths, each of which an array of successive Vector3
  22451. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22452. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22453. * * 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
  22454. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22455. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22456. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22457. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22458. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22459. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22460. * @returns the VertexData of the ribbon
  22461. */
  22462. static CreateRibbon(options: {
  22463. pathArray: Vector3[][];
  22464. closeArray?: boolean;
  22465. closePath?: boolean;
  22466. offset?: number;
  22467. sideOrientation?: number;
  22468. frontUVs?: Vector4;
  22469. backUVs?: Vector4;
  22470. invertUV?: boolean;
  22471. uvs?: Vector2[];
  22472. colors?: Color4[];
  22473. }): VertexData;
  22474. /**
  22475. * Creates the VertexData for a box
  22476. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22477. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22478. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22479. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22480. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22481. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22482. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22483. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22484. * * 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)
  22485. * * 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)
  22486. * @returns the VertexData of the box
  22487. */
  22488. static CreateBox(options: {
  22489. size?: number;
  22490. width?: number;
  22491. height?: number;
  22492. depth?: number;
  22493. faceUV?: Vector4[];
  22494. faceColors?: Color4[];
  22495. sideOrientation?: number;
  22496. frontUVs?: Vector4;
  22497. backUVs?: Vector4;
  22498. }): VertexData;
  22499. /**
  22500. * Creates the VertexData for a tiled box
  22501. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22502. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22503. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22504. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22505. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22506. * @returns the VertexData of the box
  22507. */
  22508. static CreateTiledBox(options: {
  22509. pattern?: number;
  22510. width?: number;
  22511. height?: number;
  22512. depth?: number;
  22513. tileSize?: number;
  22514. tileWidth?: number;
  22515. tileHeight?: number;
  22516. alignHorizontal?: number;
  22517. alignVertical?: number;
  22518. faceUV?: Vector4[];
  22519. faceColors?: Color4[];
  22520. sideOrientation?: number;
  22521. }): VertexData;
  22522. /**
  22523. * Creates the VertexData for a tiled plane
  22524. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22525. * * pattern a limited pattern arrangement depending on the number
  22526. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22527. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22528. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22529. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22530. * * 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)
  22531. * * 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)
  22532. * @returns the VertexData of the tiled plane
  22533. */
  22534. static CreateTiledPlane(options: {
  22535. pattern?: number;
  22536. tileSize?: number;
  22537. tileWidth?: number;
  22538. tileHeight?: number;
  22539. size?: number;
  22540. width?: number;
  22541. height?: number;
  22542. alignHorizontal?: number;
  22543. alignVertical?: number;
  22544. sideOrientation?: number;
  22545. frontUVs?: Vector4;
  22546. backUVs?: Vector4;
  22547. }): VertexData;
  22548. /**
  22549. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22550. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22551. * * segments sets the number of horizontal strips optional, default 32
  22552. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22553. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22554. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22555. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22556. * * 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
  22557. * * 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
  22558. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22559. * * 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)
  22560. * * 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)
  22561. * @returns the VertexData of the ellipsoid
  22562. */
  22563. static CreateSphere(options: {
  22564. segments?: number;
  22565. diameter?: number;
  22566. diameterX?: number;
  22567. diameterY?: number;
  22568. diameterZ?: number;
  22569. arc?: number;
  22570. slice?: number;
  22571. sideOrientation?: number;
  22572. frontUVs?: Vector4;
  22573. backUVs?: Vector4;
  22574. }): VertexData;
  22575. /**
  22576. * Creates the VertexData for a cylinder, cone or prism
  22577. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22578. * * height sets the height (y direction) of the cylinder, optional, default 2
  22579. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22580. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22581. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22582. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22583. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22584. * * 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
  22585. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22586. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22587. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22588. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22589. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22590. * * 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)
  22591. * * 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)
  22592. * @returns the VertexData of the cylinder, cone or prism
  22593. */
  22594. static CreateCylinder(options: {
  22595. height?: number;
  22596. diameterTop?: number;
  22597. diameterBottom?: number;
  22598. diameter?: number;
  22599. tessellation?: number;
  22600. subdivisions?: number;
  22601. arc?: number;
  22602. faceColors?: Color4[];
  22603. faceUV?: Vector4[];
  22604. hasRings?: boolean;
  22605. enclose?: boolean;
  22606. sideOrientation?: number;
  22607. frontUVs?: Vector4;
  22608. backUVs?: Vector4;
  22609. }): VertexData;
  22610. /**
  22611. * Creates the VertexData for a torus
  22612. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22613. * * diameter the diameter of the torus, optional default 1
  22614. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22615. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22616. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22617. * * 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)
  22618. * * 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)
  22619. * @returns the VertexData of the torus
  22620. */
  22621. static CreateTorus(options: {
  22622. diameter?: number;
  22623. thickness?: number;
  22624. tessellation?: number;
  22625. sideOrientation?: number;
  22626. frontUVs?: Vector4;
  22627. backUVs?: Vector4;
  22628. }): VertexData;
  22629. /**
  22630. * Creates the VertexData of the LineSystem
  22631. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22632. * - lines an array of lines, each line being an array of successive Vector3
  22633. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22634. * @returns the VertexData of the LineSystem
  22635. */
  22636. static CreateLineSystem(options: {
  22637. lines: Vector3[][];
  22638. colors?: Nullable<Color4[][]>;
  22639. }): VertexData;
  22640. /**
  22641. * Create the VertexData for a DashedLines
  22642. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22643. * - points an array successive Vector3
  22644. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22645. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22646. * - dashNb the intended total number of dashes, optional, default 200
  22647. * @returns the VertexData for the DashedLines
  22648. */
  22649. static CreateDashedLines(options: {
  22650. points: Vector3[];
  22651. dashSize?: number;
  22652. gapSize?: number;
  22653. dashNb?: number;
  22654. }): VertexData;
  22655. /**
  22656. * Creates the VertexData for a Ground
  22657. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22658. * - width the width (x direction) of the ground, optional, default 1
  22659. * - height the height (z direction) of the ground, optional, default 1
  22660. * - subdivisions the number of subdivisions per side, optional, default 1
  22661. * @returns the VertexData of the Ground
  22662. */
  22663. static CreateGround(options: {
  22664. width?: number;
  22665. height?: number;
  22666. subdivisions?: number;
  22667. subdivisionsX?: number;
  22668. subdivisionsY?: number;
  22669. }): VertexData;
  22670. /**
  22671. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22672. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22673. * * xmin the ground minimum X coordinate, optional, default -1
  22674. * * zmin the ground minimum Z coordinate, optional, default -1
  22675. * * xmax the ground maximum X coordinate, optional, default 1
  22676. * * zmax the ground maximum Z coordinate, optional, default 1
  22677. * * 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}
  22678. * * 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}
  22679. * @returns the VertexData of the TiledGround
  22680. */
  22681. static CreateTiledGround(options: {
  22682. xmin: number;
  22683. zmin: number;
  22684. xmax: number;
  22685. zmax: number;
  22686. subdivisions?: {
  22687. w: number;
  22688. h: number;
  22689. };
  22690. precision?: {
  22691. w: number;
  22692. h: number;
  22693. };
  22694. }): VertexData;
  22695. /**
  22696. * Creates the VertexData of the Ground designed from a heightmap
  22697. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22698. * * width the width (x direction) of the ground
  22699. * * height the height (z direction) of the ground
  22700. * * subdivisions the number of subdivisions per side
  22701. * * minHeight the minimum altitude on the ground, optional, default 0
  22702. * * maxHeight the maximum altitude on the ground, optional default 1
  22703. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22704. * * buffer the array holding the image color data
  22705. * * bufferWidth the width of image
  22706. * * bufferHeight the height of image
  22707. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22708. * @returns the VertexData of the Ground designed from a heightmap
  22709. */
  22710. static CreateGroundFromHeightMap(options: {
  22711. width: number;
  22712. height: number;
  22713. subdivisions: number;
  22714. minHeight: number;
  22715. maxHeight: number;
  22716. colorFilter: Color3;
  22717. buffer: Uint8Array;
  22718. bufferWidth: number;
  22719. bufferHeight: number;
  22720. alphaFilter: number;
  22721. }): VertexData;
  22722. /**
  22723. * Creates the VertexData for a Plane
  22724. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22725. * * size sets the width and height of the plane to the value of size, optional default 1
  22726. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22727. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22728. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22729. * * 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)
  22730. * * 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)
  22731. * @returns the VertexData of the box
  22732. */
  22733. static CreatePlane(options: {
  22734. size?: number;
  22735. width?: number;
  22736. height?: number;
  22737. sideOrientation?: number;
  22738. frontUVs?: Vector4;
  22739. backUVs?: Vector4;
  22740. }): VertexData;
  22741. /**
  22742. * Creates the VertexData of the Disc or regular Polygon
  22743. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22744. * * radius the radius of the disc, optional default 0.5
  22745. * * tessellation the number of polygon sides, optional, default 64
  22746. * * 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
  22747. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22748. * * 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)
  22749. * * 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)
  22750. * @returns the VertexData of the box
  22751. */
  22752. static CreateDisc(options: {
  22753. radius?: number;
  22754. tessellation?: number;
  22755. arc?: number;
  22756. sideOrientation?: number;
  22757. frontUVs?: Vector4;
  22758. backUVs?: Vector4;
  22759. }): VertexData;
  22760. /**
  22761. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22762. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22763. * @param polygon a mesh built from polygonTriangulation.build()
  22764. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22765. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22766. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22767. * @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)
  22768. * @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)
  22769. * @returns the VertexData of the Polygon
  22770. */
  22771. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22772. /**
  22773. * Creates the VertexData of the IcoSphere
  22774. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22775. * * radius the radius of the IcoSphere, optional default 1
  22776. * * radiusX allows stretching in the x direction, optional, default radius
  22777. * * radiusY allows stretching in the y direction, optional, default radius
  22778. * * radiusZ allows stretching in the z direction, optional, default radius
  22779. * * flat when true creates a flat shaded mesh, optional, default true
  22780. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22781. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22782. * * 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)
  22783. * * 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)
  22784. * @returns the VertexData of the IcoSphere
  22785. */
  22786. static CreateIcoSphere(options: {
  22787. radius?: number;
  22788. radiusX?: number;
  22789. radiusY?: number;
  22790. radiusZ?: number;
  22791. flat?: boolean;
  22792. subdivisions?: number;
  22793. sideOrientation?: number;
  22794. frontUVs?: Vector4;
  22795. backUVs?: Vector4;
  22796. }): VertexData;
  22797. /**
  22798. * Creates the VertexData for a Polyhedron
  22799. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22800. * * type provided types are:
  22801. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22802. * * 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)
  22803. * * size the size of the IcoSphere, optional default 1
  22804. * * sizeX allows stretching in the x direction, optional, default size
  22805. * * sizeY allows stretching in the y direction, optional, default size
  22806. * * sizeZ allows stretching in the z direction, optional, default size
  22807. * * 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
  22808. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22809. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22810. * * flat when true creates a flat shaded mesh, optional, default true
  22811. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22812. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22813. * * 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)
  22814. * * 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)
  22815. * @returns the VertexData of the Polyhedron
  22816. */
  22817. static CreatePolyhedron(options: {
  22818. type?: number;
  22819. size?: number;
  22820. sizeX?: number;
  22821. sizeY?: number;
  22822. sizeZ?: number;
  22823. custom?: any;
  22824. faceUV?: Vector4[];
  22825. faceColors?: Color4[];
  22826. flat?: boolean;
  22827. sideOrientation?: number;
  22828. frontUVs?: Vector4;
  22829. backUVs?: Vector4;
  22830. }): VertexData;
  22831. /**
  22832. * Creates the VertexData for a TorusKnot
  22833. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22834. * * radius the radius of the torus knot, optional, default 2
  22835. * * tube the thickness of the tube, optional, default 0.5
  22836. * * radialSegments the number of sides on each tube segments, optional, default 32
  22837. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22838. * * p the number of windings around the z axis, optional, default 2
  22839. * * q the number of windings around the x axis, optional, default 3
  22840. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22841. * * 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)
  22842. * * 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)
  22843. * @returns the VertexData of the Torus Knot
  22844. */
  22845. static CreateTorusKnot(options: {
  22846. radius?: number;
  22847. tube?: number;
  22848. radialSegments?: number;
  22849. tubularSegments?: number;
  22850. p?: number;
  22851. q?: number;
  22852. sideOrientation?: number;
  22853. frontUVs?: Vector4;
  22854. backUVs?: Vector4;
  22855. }): VertexData;
  22856. /**
  22857. * Compute normals for given positions and indices
  22858. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22859. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22860. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22861. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22862. * * facetNormals : optional array of facet normals (vector3)
  22863. * * facetPositions : optional array of facet positions (vector3)
  22864. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22865. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22866. * * bInfo : optional bounding info, required for facetPartitioning computation
  22867. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22868. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22869. * * useRightHandedSystem: optional boolean to for right handed system computation
  22870. * * depthSort : optional boolean to enable the facet depth sort computation
  22871. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22872. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22873. */
  22874. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22875. facetNormals?: any;
  22876. facetPositions?: any;
  22877. facetPartitioning?: any;
  22878. ratio?: number;
  22879. bInfo?: any;
  22880. bbSize?: Vector3;
  22881. subDiv?: any;
  22882. useRightHandedSystem?: boolean;
  22883. depthSort?: boolean;
  22884. distanceTo?: Vector3;
  22885. depthSortedFacets?: any;
  22886. }): void;
  22887. /** @hidden */
  22888. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22889. /**
  22890. * Applies VertexData created from the imported parameters to the geometry
  22891. * @param parsedVertexData the parsed data from an imported file
  22892. * @param geometry the geometry to apply the VertexData to
  22893. */
  22894. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22895. }
  22896. }
  22897. declare module "babylonjs/Morph/morphTarget" {
  22898. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22899. import { Observable } from "babylonjs/Misc/observable";
  22900. import { Nullable, FloatArray } from "babylonjs/types";
  22901. import { Scene } from "babylonjs/scene";
  22902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22903. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22904. /**
  22905. * Defines a target to use with MorphTargetManager
  22906. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22907. */
  22908. export class MorphTarget implements IAnimatable {
  22909. /** defines the name of the target */
  22910. name: string;
  22911. /**
  22912. * Gets or sets the list of animations
  22913. */
  22914. animations: import("babylonjs/Animations/animation").Animation[];
  22915. private _scene;
  22916. private _positions;
  22917. private _normals;
  22918. private _tangents;
  22919. private _uvs;
  22920. private _influence;
  22921. private _uniqueId;
  22922. /**
  22923. * Observable raised when the influence changes
  22924. */
  22925. onInfluenceChanged: Observable<boolean>;
  22926. /** @hidden */
  22927. _onDataLayoutChanged: Observable<void>;
  22928. /**
  22929. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22930. */
  22931. influence: number;
  22932. /**
  22933. * Gets or sets the id of the morph Target
  22934. */
  22935. id: string;
  22936. private _animationPropertiesOverride;
  22937. /**
  22938. * Gets or sets the animation properties override
  22939. */
  22940. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22941. /**
  22942. * Creates a new MorphTarget
  22943. * @param name defines the name of the target
  22944. * @param influence defines the influence to use
  22945. * @param scene defines the scene the morphtarget belongs to
  22946. */
  22947. constructor(
  22948. /** defines the name of the target */
  22949. name: string, influence?: number, scene?: Nullable<Scene>);
  22950. /**
  22951. * Gets the unique ID of this manager
  22952. */
  22953. readonly uniqueId: number;
  22954. /**
  22955. * Gets a boolean defining if the target contains position data
  22956. */
  22957. readonly hasPositions: boolean;
  22958. /**
  22959. * Gets a boolean defining if the target contains normal data
  22960. */
  22961. readonly hasNormals: boolean;
  22962. /**
  22963. * Gets a boolean defining if the target contains tangent data
  22964. */
  22965. readonly hasTangents: boolean;
  22966. /**
  22967. * Gets a boolean defining if the target contains texture coordinates data
  22968. */
  22969. readonly hasUVs: boolean;
  22970. /**
  22971. * Affects position data to this target
  22972. * @param data defines the position data to use
  22973. */
  22974. setPositions(data: Nullable<FloatArray>): void;
  22975. /**
  22976. * Gets the position data stored in this target
  22977. * @returns a FloatArray containing the position data (or null if not present)
  22978. */
  22979. getPositions(): Nullable<FloatArray>;
  22980. /**
  22981. * Affects normal data to this target
  22982. * @param data defines the normal data to use
  22983. */
  22984. setNormals(data: Nullable<FloatArray>): void;
  22985. /**
  22986. * Gets the normal data stored in this target
  22987. * @returns a FloatArray containing the normal data (or null if not present)
  22988. */
  22989. getNormals(): Nullable<FloatArray>;
  22990. /**
  22991. * Affects tangent data to this target
  22992. * @param data defines the tangent data to use
  22993. */
  22994. setTangents(data: Nullable<FloatArray>): void;
  22995. /**
  22996. * Gets the tangent data stored in this target
  22997. * @returns a FloatArray containing the tangent data (or null if not present)
  22998. */
  22999. getTangents(): Nullable<FloatArray>;
  23000. /**
  23001. * Affects texture coordinates data to this target
  23002. * @param data defines the texture coordinates data to use
  23003. */
  23004. setUVs(data: Nullable<FloatArray>): void;
  23005. /**
  23006. * Gets the texture coordinates data stored in this target
  23007. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23008. */
  23009. getUVs(): Nullable<FloatArray>;
  23010. /**
  23011. * Clone the current target
  23012. * @returns a new MorphTarget
  23013. */
  23014. clone(): MorphTarget;
  23015. /**
  23016. * Serializes the current target into a Serialization object
  23017. * @returns the serialized object
  23018. */
  23019. serialize(): any;
  23020. /**
  23021. * Returns the string "MorphTarget"
  23022. * @returns "MorphTarget"
  23023. */
  23024. getClassName(): string;
  23025. /**
  23026. * Creates a new target from serialized data
  23027. * @param serializationObject defines the serialized data to use
  23028. * @returns a new MorphTarget
  23029. */
  23030. static Parse(serializationObject: any): MorphTarget;
  23031. /**
  23032. * Creates a MorphTarget from mesh data
  23033. * @param mesh defines the source mesh
  23034. * @param name defines the name to use for the new target
  23035. * @param influence defines the influence to attach to the target
  23036. * @returns a new MorphTarget
  23037. */
  23038. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23039. }
  23040. }
  23041. declare module "babylonjs/Morph/morphTargetManager" {
  23042. import { Nullable } from "babylonjs/types";
  23043. import { Scene } from "babylonjs/scene";
  23044. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23045. /**
  23046. * This class is used to deform meshes using morphing between different targets
  23047. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23048. */
  23049. export class MorphTargetManager {
  23050. private _targets;
  23051. private _targetInfluenceChangedObservers;
  23052. private _targetDataLayoutChangedObservers;
  23053. private _activeTargets;
  23054. private _scene;
  23055. private _influences;
  23056. private _supportsNormals;
  23057. private _supportsTangents;
  23058. private _supportsUVs;
  23059. private _vertexCount;
  23060. private _uniqueId;
  23061. private _tempInfluences;
  23062. /**
  23063. * Gets or sets a boolean indicating if normals must be morphed
  23064. */
  23065. enableNormalMorphing: boolean;
  23066. /**
  23067. * Gets or sets a boolean indicating if tangents must be morphed
  23068. */
  23069. enableTangentMorphing: boolean;
  23070. /**
  23071. * Gets or sets a boolean indicating if UV must be morphed
  23072. */
  23073. enableUVMorphing: boolean;
  23074. /**
  23075. * Creates a new MorphTargetManager
  23076. * @param scene defines the current scene
  23077. */
  23078. constructor(scene?: Nullable<Scene>);
  23079. /**
  23080. * Gets the unique ID of this manager
  23081. */
  23082. readonly uniqueId: number;
  23083. /**
  23084. * Gets the number of vertices handled by this manager
  23085. */
  23086. readonly vertexCount: number;
  23087. /**
  23088. * Gets a boolean indicating if this manager supports morphing of normals
  23089. */
  23090. readonly supportsNormals: boolean;
  23091. /**
  23092. * Gets a boolean indicating if this manager supports morphing of tangents
  23093. */
  23094. readonly supportsTangents: boolean;
  23095. /**
  23096. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23097. */
  23098. readonly supportsUVs: boolean;
  23099. /**
  23100. * Gets the number of targets stored in this manager
  23101. */
  23102. readonly numTargets: number;
  23103. /**
  23104. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23105. */
  23106. readonly numInfluencers: number;
  23107. /**
  23108. * Gets the list of influences (one per target)
  23109. */
  23110. readonly influences: Float32Array;
  23111. /**
  23112. * Gets the active target at specified index. An active target is a target with an influence > 0
  23113. * @param index defines the index to check
  23114. * @returns the requested target
  23115. */
  23116. getActiveTarget(index: number): MorphTarget;
  23117. /**
  23118. * Gets the target at specified index
  23119. * @param index defines the index to check
  23120. * @returns the requested target
  23121. */
  23122. getTarget(index: number): MorphTarget;
  23123. /**
  23124. * Add a new target to this manager
  23125. * @param target defines the target to add
  23126. */
  23127. addTarget(target: MorphTarget): void;
  23128. /**
  23129. * Removes a target from the manager
  23130. * @param target defines the target to remove
  23131. */
  23132. removeTarget(target: MorphTarget): void;
  23133. /**
  23134. * Clone the current manager
  23135. * @returns a new MorphTargetManager
  23136. */
  23137. clone(): MorphTargetManager;
  23138. /**
  23139. * Serializes the current manager into a Serialization object
  23140. * @returns the serialized object
  23141. */
  23142. serialize(): any;
  23143. private _syncActiveTargets;
  23144. /**
  23145. * Syncrhonize the targets with all the meshes using this morph target manager
  23146. */
  23147. synchronize(): void;
  23148. /**
  23149. * Creates a new MorphTargetManager from serialized data
  23150. * @param serializationObject defines the serialized data
  23151. * @param scene defines the hosting scene
  23152. * @returns the new MorphTargetManager
  23153. */
  23154. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23155. }
  23156. }
  23157. declare module "babylonjs/Meshes/meshLODLevel" {
  23158. import { Mesh } from "babylonjs/Meshes/mesh";
  23159. import { Nullable } from "babylonjs/types";
  23160. /**
  23161. * Class used to represent a specific level of detail of a mesh
  23162. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23163. */
  23164. export class MeshLODLevel {
  23165. /** Defines the distance where this level should start being displayed */
  23166. distance: number;
  23167. /** Defines the mesh to use to render this level */
  23168. mesh: Nullable<Mesh>;
  23169. /**
  23170. * Creates a new LOD level
  23171. * @param distance defines the distance where this level should star being displayed
  23172. * @param mesh defines the mesh to use to render this level
  23173. */
  23174. constructor(
  23175. /** Defines the distance where this level should start being displayed */
  23176. distance: number,
  23177. /** Defines the mesh to use to render this level */
  23178. mesh: Nullable<Mesh>);
  23179. }
  23180. }
  23181. declare module "babylonjs/Meshes/groundMesh" {
  23182. import { Scene } from "babylonjs/scene";
  23183. import { Vector3 } from "babylonjs/Maths/math.vector";
  23184. import { Mesh } from "babylonjs/Meshes/mesh";
  23185. /**
  23186. * Mesh representing the gorund
  23187. */
  23188. export class GroundMesh extends Mesh {
  23189. /** If octree should be generated */
  23190. generateOctree: boolean;
  23191. private _heightQuads;
  23192. /** @hidden */
  23193. _subdivisionsX: number;
  23194. /** @hidden */
  23195. _subdivisionsY: number;
  23196. /** @hidden */
  23197. _width: number;
  23198. /** @hidden */
  23199. _height: number;
  23200. /** @hidden */
  23201. _minX: number;
  23202. /** @hidden */
  23203. _maxX: number;
  23204. /** @hidden */
  23205. _minZ: number;
  23206. /** @hidden */
  23207. _maxZ: number;
  23208. constructor(name: string, scene: Scene);
  23209. /**
  23210. * "GroundMesh"
  23211. * @returns "GroundMesh"
  23212. */
  23213. getClassName(): string;
  23214. /**
  23215. * The minimum of x and y subdivisions
  23216. */
  23217. readonly subdivisions: number;
  23218. /**
  23219. * X subdivisions
  23220. */
  23221. readonly subdivisionsX: number;
  23222. /**
  23223. * Y subdivisions
  23224. */
  23225. readonly subdivisionsY: number;
  23226. /**
  23227. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23228. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23229. * @param chunksCount the number of subdivisions for x and y
  23230. * @param octreeBlocksSize (Default: 32)
  23231. */
  23232. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23233. /**
  23234. * Returns a height (y) value in the Worl system :
  23235. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23236. * @param x x coordinate
  23237. * @param z z coordinate
  23238. * @returns the ground y position if (x, z) are outside the ground surface.
  23239. */
  23240. getHeightAtCoordinates(x: number, z: number): number;
  23241. /**
  23242. * Returns a normalized vector (Vector3) orthogonal to the ground
  23243. * at the ground coordinates (x, z) expressed in the World system.
  23244. * @param x x coordinate
  23245. * @param z z coordinate
  23246. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23247. */
  23248. getNormalAtCoordinates(x: number, z: number): Vector3;
  23249. /**
  23250. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23251. * at the ground coordinates (x, z) expressed in the World system.
  23252. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23253. * @param x x coordinate
  23254. * @param z z coordinate
  23255. * @param ref vector to store the result
  23256. * @returns the GroundMesh.
  23257. */
  23258. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23259. /**
  23260. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23261. * if the ground has been updated.
  23262. * This can be used in the render loop.
  23263. * @returns the GroundMesh.
  23264. */
  23265. updateCoordinateHeights(): GroundMesh;
  23266. private _getFacetAt;
  23267. private _initHeightQuads;
  23268. private _computeHeightQuads;
  23269. /**
  23270. * Serializes this ground mesh
  23271. * @param serializationObject object to write serialization to
  23272. */
  23273. serialize(serializationObject: any): void;
  23274. /**
  23275. * Parses a serialized ground mesh
  23276. * @param parsedMesh the serialized mesh
  23277. * @param scene the scene to create the ground mesh in
  23278. * @returns the created ground mesh
  23279. */
  23280. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23281. }
  23282. }
  23283. declare module "babylonjs/Physics/physicsJoint" {
  23284. import { Vector3 } from "babylonjs/Maths/math.vector";
  23285. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23286. /**
  23287. * Interface for Physics-Joint data
  23288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23289. */
  23290. export interface PhysicsJointData {
  23291. /**
  23292. * The main pivot of the joint
  23293. */
  23294. mainPivot?: Vector3;
  23295. /**
  23296. * The connected pivot of the joint
  23297. */
  23298. connectedPivot?: Vector3;
  23299. /**
  23300. * The main axis of the joint
  23301. */
  23302. mainAxis?: Vector3;
  23303. /**
  23304. * The connected axis of the joint
  23305. */
  23306. connectedAxis?: Vector3;
  23307. /**
  23308. * The collision of the joint
  23309. */
  23310. collision?: boolean;
  23311. /**
  23312. * Native Oimo/Cannon/Energy data
  23313. */
  23314. nativeParams?: any;
  23315. }
  23316. /**
  23317. * This is a holder class for the physics joint created by the physics plugin
  23318. * It holds a set of functions to control the underlying joint
  23319. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23320. */
  23321. export class PhysicsJoint {
  23322. /**
  23323. * The type of the physics joint
  23324. */
  23325. type: number;
  23326. /**
  23327. * The data for the physics joint
  23328. */
  23329. jointData: PhysicsJointData;
  23330. private _physicsJoint;
  23331. protected _physicsPlugin: IPhysicsEnginePlugin;
  23332. /**
  23333. * Initializes the physics joint
  23334. * @param type The type of the physics joint
  23335. * @param jointData The data for the physics joint
  23336. */
  23337. constructor(
  23338. /**
  23339. * The type of the physics joint
  23340. */
  23341. type: number,
  23342. /**
  23343. * The data for the physics joint
  23344. */
  23345. jointData: PhysicsJointData);
  23346. /**
  23347. * Gets the physics joint
  23348. */
  23349. /**
  23350. * Sets the physics joint
  23351. */
  23352. physicsJoint: any;
  23353. /**
  23354. * Sets the physics plugin
  23355. */
  23356. physicsPlugin: IPhysicsEnginePlugin;
  23357. /**
  23358. * Execute a function that is physics-plugin specific.
  23359. * @param {Function} func the function that will be executed.
  23360. * It accepts two parameters: the physics world and the physics joint
  23361. */
  23362. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23363. /**
  23364. * Distance-Joint type
  23365. */
  23366. static DistanceJoint: number;
  23367. /**
  23368. * Hinge-Joint type
  23369. */
  23370. static HingeJoint: number;
  23371. /**
  23372. * Ball-and-Socket joint type
  23373. */
  23374. static BallAndSocketJoint: number;
  23375. /**
  23376. * Wheel-Joint type
  23377. */
  23378. static WheelJoint: number;
  23379. /**
  23380. * Slider-Joint type
  23381. */
  23382. static SliderJoint: number;
  23383. /**
  23384. * Prismatic-Joint type
  23385. */
  23386. static PrismaticJoint: number;
  23387. /**
  23388. * Universal-Joint type
  23389. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23390. */
  23391. static UniversalJoint: number;
  23392. /**
  23393. * Hinge-Joint 2 type
  23394. */
  23395. static Hinge2Joint: number;
  23396. /**
  23397. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23398. */
  23399. static PointToPointJoint: number;
  23400. /**
  23401. * Spring-Joint type
  23402. */
  23403. static SpringJoint: number;
  23404. /**
  23405. * Lock-Joint type
  23406. */
  23407. static LockJoint: number;
  23408. }
  23409. /**
  23410. * A class representing a physics distance joint
  23411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23412. */
  23413. export class DistanceJoint extends PhysicsJoint {
  23414. /**
  23415. *
  23416. * @param jointData The data for the Distance-Joint
  23417. */
  23418. constructor(jointData: DistanceJointData);
  23419. /**
  23420. * Update the predefined distance.
  23421. * @param maxDistance The maximum preferred distance
  23422. * @param minDistance The minimum preferred distance
  23423. */
  23424. updateDistance(maxDistance: number, minDistance?: number): void;
  23425. }
  23426. /**
  23427. * Represents a Motor-Enabled Joint
  23428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23429. */
  23430. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23431. /**
  23432. * Initializes the Motor-Enabled Joint
  23433. * @param type The type of the joint
  23434. * @param jointData The physica joint data for the joint
  23435. */
  23436. constructor(type: number, jointData: PhysicsJointData);
  23437. /**
  23438. * Set the motor values.
  23439. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23440. * @param force the force to apply
  23441. * @param maxForce max force for this motor.
  23442. */
  23443. setMotor(force?: number, maxForce?: number): void;
  23444. /**
  23445. * Set the motor's limits.
  23446. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23447. * @param upperLimit The upper limit of the motor
  23448. * @param lowerLimit The lower limit of the motor
  23449. */
  23450. setLimit(upperLimit: number, lowerLimit?: number): void;
  23451. }
  23452. /**
  23453. * This class represents a single physics Hinge-Joint
  23454. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23455. */
  23456. export class HingeJoint extends MotorEnabledJoint {
  23457. /**
  23458. * Initializes the Hinge-Joint
  23459. * @param jointData The joint data for the Hinge-Joint
  23460. */
  23461. constructor(jointData: PhysicsJointData);
  23462. /**
  23463. * Set the motor values.
  23464. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23465. * @param {number} force the force to apply
  23466. * @param {number} maxForce max force for this motor.
  23467. */
  23468. setMotor(force?: number, maxForce?: number): void;
  23469. /**
  23470. * Set the motor's limits.
  23471. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23472. * @param upperLimit The upper limit of the motor
  23473. * @param lowerLimit The lower limit of the motor
  23474. */
  23475. setLimit(upperLimit: number, lowerLimit?: number): void;
  23476. }
  23477. /**
  23478. * This class represents a dual hinge physics joint (same as wheel joint)
  23479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23480. */
  23481. export class Hinge2Joint extends MotorEnabledJoint {
  23482. /**
  23483. * Initializes the Hinge2-Joint
  23484. * @param jointData The joint data for the Hinge2-Joint
  23485. */
  23486. constructor(jointData: PhysicsJointData);
  23487. /**
  23488. * Set the motor values.
  23489. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23490. * @param {number} targetSpeed the speed the motor is to reach
  23491. * @param {number} maxForce max force for this motor.
  23492. * @param {motorIndex} the motor's index, 0 or 1.
  23493. */
  23494. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23495. /**
  23496. * Set the motor limits.
  23497. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23498. * @param {number} upperLimit the upper limit
  23499. * @param {number} lowerLimit lower limit
  23500. * @param {motorIndex} the motor's index, 0 or 1.
  23501. */
  23502. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23503. }
  23504. /**
  23505. * Interface for a motor enabled joint
  23506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23507. */
  23508. export interface IMotorEnabledJoint {
  23509. /**
  23510. * Physics joint
  23511. */
  23512. physicsJoint: any;
  23513. /**
  23514. * Sets the motor of the motor-enabled joint
  23515. * @param force The force of the motor
  23516. * @param maxForce The maximum force of the motor
  23517. * @param motorIndex The index of the motor
  23518. */
  23519. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23520. /**
  23521. * Sets the limit of the motor
  23522. * @param upperLimit The upper limit of the motor
  23523. * @param lowerLimit The lower limit of the motor
  23524. * @param motorIndex The index of the motor
  23525. */
  23526. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23527. }
  23528. /**
  23529. * Joint data for a Distance-Joint
  23530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23531. */
  23532. export interface DistanceJointData extends PhysicsJointData {
  23533. /**
  23534. * Max distance the 2 joint objects can be apart
  23535. */
  23536. maxDistance: number;
  23537. }
  23538. /**
  23539. * Joint data from a spring joint
  23540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23541. */
  23542. export interface SpringJointData extends PhysicsJointData {
  23543. /**
  23544. * Length of the spring
  23545. */
  23546. length: number;
  23547. /**
  23548. * Stiffness of the spring
  23549. */
  23550. stiffness: number;
  23551. /**
  23552. * Damping of the spring
  23553. */
  23554. damping: number;
  23555. /** this callback will be called when applying the force to the impostors. */
  23556. forceApplicationCallback: () => void;
  23557. }
  23558. }
  23559. declare module "babylonjs/Physics/physicsRaycastResult" {
  23560. import { Vector3 } from "babylonjs/Maths/math.vector";
  23561. /**
  23562. * Holds the data for the raycast result
  23563. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23564. */
  23565. export class PhysicsRaycastResult {
  23566. private _hasHit;
  23567. private _hitDistance;
  23568. private _hitNormalWorld;
  23569. private _hitPointWorld;
  23570. private _rayFromWorld;
  23571. private _rayToWorld;
  23572. /**
  23573. * Gets if there was a hit
  23574. */
  23575. readonly hasHit: boolean;
  23576. /**
  23577. * Gets the distance from the hit
  23578. */
  23579. readonly hitDistance: number;
  23580. /**
  23581. * Gets the hit normal/direction in the world
  23582. */
  23583. readonly hitNormalWorld: Vector3;
  23584. /**
  23585. * Gets the hit point in the world
  23586. */
  23587. readonly hitPointWorld: Vector3;
  23588. /**
  23589. * Gets the ray "start point" of the ray in the world
  23590. */
  23591. readonly rayFromWorld: Vector3;
  23592. /**
  23593. * Gets the ray "end point" of the ray in the world
  23594. */
  23595. readonly rayToWorld: Vector3;
  23596. /**
  23597. * Sets the hit data (normal & point in world space)
  23598. * @param hitNormalWorld defines the normal in world space
  23599. * @param hitPointWorld defines the point in world space
  23600. */
  23601. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23602. /**
  23603. * Sets the distance from the start point to the hit point
  23604. * @param distance
  23605. */
  23606. setHitDistance(distance: number): void;
  23607. /**
  23608. * Calculates the distance manually
  23609. */
  23610. calculateHitDistance(): void;
  23611. /**
  23612. * Resets all the values to default
  23613. * @param from The from point on world space
  23614. * @param to The to point on world space
  23615. */
  23616. reset(from?: Vector3, to?: Vector3): void;
  23617. }
  23618. /**
  23619. * Interface for the size containing width and height
  23620. */
  23621. interface IXYZ {
  23622. /**
  23623. * X
  23624. */
  23625. x: number;
  23626. /**
  23627. * Y
  23628. */
  23629. y: number;
  23630. /**
  23631. * Z
  23632. */
  23633. z: number;
  23634. }
  23635. }
  23636. declare module "babylonjs/Physics/IPhysicsEngine" {
  23637. import { Nullable } from "babylonjs/types";
  23638. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23640. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23641. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23642. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23643. /**
  23644. * Interface used to describe a physics joint
  23645. */
  23646. export interface PhysicsImpostorJoint {
  23647. /** Defines the main impostor to which the joint is linked */
  23648. mainImpostor: PhysicsImpostor;
  23649. /** Defines the impostor that is connected to the main impostor using this joint */
  23650. connectedImpostor: PhysicsImpostor;
  23651. /** Defines the joint itself */
  23652. joint: PhysicsJoint;
  23653. }
  23654. /** @hidden */
  23655. export interface IPhysicsEnginePlugin {
  23656. world: any;
  23657. name: string;
  23658. setGravity(gravity: Vector3): void;
  23659. setTimeStep(timeStep: number): void;
  23660. getTimeStep(): number;
  23661. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23662. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23663. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23664. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23665. removePhysicsBody(impostor: PhysicsImpostor): void;
  23666. generateJoint(joint: PhysicsImpostorJoint): void;
  23667. removeJoint(joint: PhysicsImpostorJoint): void;
  23668. isSupported(): boolean;
  23669. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23670. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23671. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23672. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23673. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23674. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23675. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23676. getBodyMass(impostor: PhysicsImpostor): number;
  23677. getBodyFriction(impostor: PhysicsImpostor): number;
  23678. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23679. getBodyRestitution(impostor: PhysicsImpostor): number;
  23680. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23681. getBodyPressure?(impostor: PhysicsImpostor): number;
  23682. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23683. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23684. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23685. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23686. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23687. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23688. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23689. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23690. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23691. sleepBody(impostor: PhysicsImpostor): void;
  23692. wakeUpBody(impostor: PhysicsImpostor): void;
  23693. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23694. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23695. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23696. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23697. getRadius(impostor: PhysicsImpostor): number;
  23698. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23699. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23700. dispose(): void;
  23701. }
  23702. /**
  23703. * Interface used to define a physics engine
  23704. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23705. */
  23706. export interface IPhysicsEngine {
  23707. /**
  23708. * Gets the gravity vector used by the simulation
  23709. */
  23710. gravity: Vector3;
  23711. /**
  23712. * Sets the gravity vector used by the simulation
  23713. * @param gravity defines the gravity vector to use
  23714. */
  23715. setGravity(gravity: Vector3): void;
  23716. /**
  23717. * Set the time step of the physics engine.
  23718. * Default is 1/60.
  23719. * To slow it down, enter 1/600 for example.
  23720. * To speed it up, 1/30
  23721. * @param newTimeStep the new timestep to apply to this world.
  23722. */
  23723. setTimeStep(newTimeStep: number): void;
  23724. /**
  23725. * Get the time step of the physics engine.
  23726. * @returns the current time step
  23727. */
  23728. getTimeStep(): number;
  23729. /**
  23730. * Release all resources
  23731. */
  23732. dispose(): void;
  23733. /**
  23734. * Gets the name of the current physics plugin
  23735. * @returns the name of the plugin
  23736. */
  23737. getPhysicsPluginName(): string;
  23738. /**
  23739. * Adding a new impostor for the impostor tracking.
  23740. * This will be done by the impostor itself.
  23741. * @param impostor the impostor to add
  23742. */
  23743. addImpostor(impostor: PhysicsImpostor): void;
  23744. /**
  23745. * Remove an impostor from the engine.
  23746. * This impostor and its mesh will not longer be updated by the physics engine.
  23747. * @param impostor the impostor to remove
  23748. */
  23749. removeImpostor(impostor: PhysicsImpostor): void;
  23750. /**
  23751. * Add a joint to the physics engine
  23752. * @param mainImpostor defines the main impostor to which the joint is added.
  23753. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23754. * @param joint defines the joint that will connect both impostors.
  23755. */
  23756. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23757. /**
  23758. * Removes a joint from the simulation
  23759. * @param mainImpostor defines the impostor used with the joint
  23760. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23761. * @param joint defines the joint to remove
  23762. */
  23763. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23764. /**
  23765. * Gets the current plugin used to run the simulation
  23766. * @returns current plugin
  23767. */
  23768. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23769. /**
  23770. * Gets the list of physic impostors
  23771. * @returns an array of PhysicsImpostor
  23772. */
  23773. getImpostors(): Array<PhysicsImpostor>;
  23774. /**
  23775. * Gets the impostor for a physics enabled object
  23776. * @param object defines the object impersonated by the impostor
  23777. * @returns the PhysicsImpostor or null if not found
  23778. */
  23779. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23780. /**
  23781. * Gets the impostor for a physics body object
  23782. * @param body defines physics body used by the impostor
  23783. * @returns the PhysicsImpostor or null if not found
  23784. */
  23785. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23786. /**
  23787. * Does a raycast in the physics world
  23788. * @param from when should the ray start?
  23789. * @param to when should the ray end?
  23790. * @returns PhysicsRaycastResult
  23791. */
  23792. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23793. /**
  23794. * Called by the scene. No need to call it.
  23795. * @param delta defines the timespam between frames
  23796. */
  23797. _step(delta: number): void;
  23798. }
  23799. }
  23800. declare module "babylonjs/Physics/physicsImpostor" {
  23801. import { Nullable, IndicesArray } from "babylonjs/types";
  23802. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23803. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23805. import { Scene } from "babylonjs/scene";
  23806. import { Bone } from "babylonjs/Bones/bone";
  23807. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23808. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23809. import { Space } from "babylonjs/Maths/math.axis";
  23810. /**
  23811. * The interface for the physics imposter parameters
  23812. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23813. */
  23814. export interface PhysicsImpostorParameters {
  23815. /**
  23816. * The mass of the physics imposter
  23817. */
  23818. mass: number;
  23819. /**
  23820. * The friction of the physics imposter
  23821. */
  23822. friction?: number;
  23823. /**
  23824. * The coefficient of restitution of the physics imposter
  23825. */
  23826. restitution?: number;
  23827. /**
  23828. * The native options of the physics imposter
  23829. */
  23830. nativeOptions?: any;
  23831. /**
  23832. * Specifies if the parent should be ignored
  23833. */
  23834. ignoreParent?: boolean;
  23835. /**
  23836. * Specifies if bi-directional transformations should be disabled
  23837. */
  23838. disableBidirectionalTransformation?: boolean;
  23839. /**
  23840. * The pressure inside the physics imposter, soft object only
  23841. */
  23842. pressure?: number;
  23843. /**
  23844. * The stiffness the physics imposter, soft object only
  23845. */
  23846. stiffness?: number;
  23847. /**
  23848. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23849. */
  23850. velocityIterations?: number;
  23851. /**
  23852. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23853. */
  23854. positionIterations?: number;
  23855. /**
  23856. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23857. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23858. * Add to fix multiple points
  23859. */
  23860. fixedPoints?: number;
  23861. /**
  23862. * The collision margin around a soft object
  23863. */
  23864. margin?: number;
  23865. /**
  23866. * The collision margin around a soft object
  23867. */
  23868. damping?: number;
  23869. /**
  23870. * The path for a rope based on an extrusion
  23871. */
  23872. path?: any;
  23873. /**
  23874. * The shape of an extrusion used for a rope based on an extrusion
  23875. */
  23876. shape?: any;
  23877. }
  23878. /**
  23879. * Interface for a physics-enabled object
  23880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23881. */
  23882. export interface IPhysicsEnabledObject {
  23883. /**
  23884. * The position of the physics-enabled object
  23885. */
  23886. position: Vector3;
  23887. /**
  23888. * The rotation of the physics-enabled object
  23889. */
  23890. rotationQuaternion: Nullable<Quaternion>;
  23891. /**
  23892. * The scale of the physics-enabled object
  23893. */
  23894. scaling: Vector3;
  23895. /**
  23896. * The rotation of the physics-enabled object
  23897. */
  23898. rotation?: Vector3;
  23899. /**
  23900. * The parent of the physics-enabled object
  23901. */
  23902. parent?: any;
  23903. /**
  23904. * The bounding info of the physics-enabled object
  23905. * @returns The bounding info of the physics-enabled object
  23906. */
  23907. getBoundingInfo(): BoundingInfo;
  23908. /**
  23909. * Computes the world matrix
  23910. * @param force Specifies if the world matrix should be computed by force
  23911. * @returns A world matrix
  23912. */
  23913. computeWorldMatrix(force: boolean): Matrix;
  23914. /**
  23915. * Gets the world matrix
  23916. * @returns A world matrix
  23917. */
  23918. getWorldMatrix?(): Matrix;
  23919. /**
  23920. * Gets the child meshes
  23921. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23922. * @returns An array of abstract meshes
  23923. */
  23924. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23925. /**
  23926. * Gets the vertex data
  23927. * @param kind The type of vertex data
  23928. * @returns A nullable array of numbers, or a float32 array
  23929. */
  23930. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23931. /**
  23932. * Gets the indices from the mesh
  23933. * @returns A nullable array of index arrays
  23934. */
  23935. getIndices?(): Nullable<IndicesArray>;
  23936. /**
  23937. * Gets the scene from the mesh
  23938. * @returns the indices array or null
  23939. */
  23940. getScene?(): Scene;
  23941. /**
  23942. * Gets the absolute position from the mesh
  23943. * @returns the absolute position
  23944. */
  23945. getAbsolutePosition(): Vector3;
  23946. /**
  23947. * Gets the absolute pivot point from the mesh
  23948. * @returns the absolute pivot point
  23949. */
  23950. getAbsolutePivotPoint(): Vector3;
  23951. /**
  23952. * Rotates the mesh
  23953. * @param axis The axis of rotation
  23954. * @param amount The amount of rotation
  23955. * @param space The space of the rotation
  23956. * @returns The rotation transform node
  23957. */
  23958. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23959. /**
  23960. * Translates the mesh
  23961. * @param axis The axis of translation
  23962. * @param distance The distance of translation
  23963. * @param space The space of the translation
  23964. * @returns The transform node
  23965. */
  23966. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23967. /**
  23968. * Sets the absolute position of the mesh
  23969. * @param absolutePosition The absolute position of the mesh
  23970. * @returns The transform node
  23971. */
  23972. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23973. /**
  23974. * Gets the class name of the mesh
  23975. * @returns The class name
  23976. */
  23977. getClassName(): string;
  23978. }
  23979. /**
  23980. * Represents a physics imposter
  23981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23982. */
  23983. export class PhysicsImpostor {
  23984. /**
  23985. * The physics-enabled object used as the physics imposter
  23986. */
  23987. object: IPhysicsEnabledObject;
  23988. /**
  23989. * The type of the physics imposter
  23990. */
  23991. type: number;
  23992. private _options;
  23993. private _scene?;
  23994. /**
  23995. * The default object size of the imposter
  23996. */
  23997. static DEFAULT_OBJECT_SIZE: Vector3;
  23998. /**
  23999. * The identity quaternion of the imposter
  24000. */
  24001. static IDENTITY_QUATERNION: Quaternion;
  24002. /** @hidden */
  24003. _pluginData: any;
  24004. private _physicsEngine;
  24005. private _physicsBody;
  24006. private _bodyUpdateRequired;
  24007. private _onBeforePhysicsStepCallbacks;
  24008. private _onAfterPhysicsStepCallbacks;
  24009. /** @hidden */
  24010. _onPhysicsCollideCallbacks: Array<{
  24011. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24012. otherImpostors: Array<PhysicsImpostor>;
  24013. }>;
  24014. private _deltaPosition;
  24015. private _deltaRotation;
  24016. private _deltaRotationConjugated;
  24017. /** @hidden */
  24018. _isFromLine: boolean;
  24019. private _parent;
  24020. private _isDisposed;
  24021. private static _tmpVecs;
  24022. private static _tmpQuat;
  24023. /**
  24024. * Specifies if the physics imposter is disposed
  24025. */
  24026. readonly isDisposed: boolean;
  24027. /**
  24028. * Gets the mass of the physics imposter
  24029. */
  24030. mass: number;
  24031. /**
  24032. * Gets the coefficient of friction
  24033. */
  24034. /**
  24035. * Sets the coefficient of friction
  24036. */
  24037. friction: number;
  24038. /**
  24039. * Gets the coefficient of restitution
  24040. */
  24041. /**
  24042. * Sets the coefficient of restitution
  24043. */
  24044. restitution: number;
  24045. /**
  24046. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24047. */
  24048. /**
  24049. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24050. */
  24051. pressure: number;
  24052. /**
  24053. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24054. */
  24055. /**
  24056. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24057. */
  24058. stiffness: number;
  24059. /**
  24060. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24061. */
  24062. /**
  24063. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24064. */
  24065. velocityIterations: number;
  24066. /**
  24067. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24068. */
  24069. /**
  24070. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24071. */
  24072. positionIterations: number;
  24073. /**
  24074. * The unique id of the physics imposter
  24075. * set by the physics engine when adding this impostor to the array
  24076. */
  24077. uniqueId: number;
  24078. /**
  24079. * @hidden
  24080. */
  24081. soft: boolean;
  24082. /**
  24083. * @hidden
  24084. */
  24085. segments: number;
  24086. private _joints;
  24087. /**
  24088. * Initializes the physics imposter
  24089. * @param object The physics-enabled object used as the physics imposter
  24090. * @param type The type of the physics imposter
  24091. * @param _options The options for the physics imposter
  24092. * @param _scene The Babylon scene
  24093. */
  24094. constructor(
  24095. /**
  24096. * The physics-enabled object used as the physics imposter
  24097. */
  24098. object: IPhysicsEnabledObject,
  24099. /**
  24100. * The type of the physics imposter
  24101. */
  24102. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24103. /**
  24104. * This function will completly initialize this impostor.
  24105. * It will create a new body - but only if this mesh has no parent.
  24106. * If it has, this impostor will not be used other than to define the impostor
  24107. * of the child mesh.
  24108. * @hidden
  24109. */
  24110. _init(): void;
  24111. private _getPhysicsParent;
  24112. /**
  24113. * Should a new body be generated.
  24114. * @returns boolean specifying if body initialization is required
  24115. */
  24116. isBodyInitRequired(): boolean;
  24117. /**
  24118. * Sets the updated scaling
  24119. * @param updated Specifies if the scaling is updated
  24120. */
  24121. setScalingUpdated(): void;
  24122. /**
  24123. * Force a regeneration of this or the parent's impostor's body.
  24124. * Use under cautious - This will remove all joints already implemented.
  24125. */
  24126. forceUpdate(): void;
  24127. /**
  24128. * Gets the body that holds this impostor. Either its own, or its parent.
  24129. */
  24130. /**
  24131. * Set the physics body. Used mainly by the physics engine/plugin
  24132. */
  24133. physicsBody: any;
  24134. /**
  24135. * Get the parent of the physics imposter
  24136. * @returns Physics imposter or null
  24137. */
  24138. /**
  24139. * Sets the parent of the physics imposter
  24140. */
  24141. parent: Nullable<PhysicsImpostor>;
  24142. /**
  24143. * Resets the update flags
  24144. */
  24145. resetUpdateFlags(): void;
  24146. /**
  24147. * Gets the object extend size
  24148. * @returns the object extend size
  24149. */
  24150. getObjectExtendSize(): Vector3;
  24151. /**
  24152. * Gets the object center
  24153. * @returns The object center
  24154. */
  24155. getObjectCenter(): Vector3;
  24156. /**
  24157. * Get a specific parametes from the options parameter
  24158. * @param paramName The object parameter name
  24159. * @returns The object parameter
  24160. */
  24161. getParam(paramName: string): any;
  24162. /**
  24163. * Sets a specific parameter in the options given to the physics plugin
  24164. * @param paramName The parameter name
  24165. * @param value The value of the parameter
  24166. */
  24167. setParam(paramName: string, value: number): void;
  24168. /**
  24169. * Specifically change the body's mass option. Won't recreate the physics body object
  24170. * @param mass The mass of the physics imposter
  24171. */
  24172. setMass(mass: number): void;
  24173. /**
  24174. * Gets the linear velocity
  24175. * @returns linear velocity or null
  24176. */
  24177. getLinearVelocity(): Nullable<Vector3>;
  24178. /**
  24179. * Sets the linear velocity
  24180. * @param velocity linear velocity or null
  24181. */
  24182. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24183. /**
  24184. * Gets the angular velocity
  24185. * @returns angular velocity or null
  24186. */
  24187. getAngularVelocity(): Nullable<Vector3>;
  24188. /**
  24189. * Sets the angular velocity
  24190. * @param velocity The velocity or null
  24191. */
  24192. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24193. /**
  24194. * Execute a function with the physics plugin native code
  24195. * Provide a function the will have two variables - the world object and the physics body object
  24196. * @param func The function to execute with the physics plugin native code
  24197. */
  24198. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24199. /**
  24200. * Register a function that will be executed before the physics world is stepping forward
  24201. * @param func The function to execute before the physics world is stepped forward
  24202. */
  24203. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24204. /**
  24205. * Unregister a function that will be executed before the physics world is stepping forward
  24206. * @param func The function to execute before the physics world is stepped forward
  24207. */
  24208. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24209. /**
  24210. * Register a function that will be executed after the physics step
  24211. * @param func The function to execute after physics step
  24212. */
  24213. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24214. /**
  24215. * Unregisters a function that will be executed after the physics step
  24216. * @param func The function to execute after physics step
  24217. */
  24218. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24219. /**
  24220. * register a function that will be executed when this impostor collides against a different body
  24221. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24222. * @param func Callback that is executed on collision
  24223. */
  24224. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24225. /**
  24226. * Unregisters the physics imposter on contact
  24227. * @param collideAgainst The physics object to collide against
  24228. * @param func Callback to execute on collision
  24229. */
  24230. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24231. private _tmpQuat;
  24232. private _tmpQuat2;
  24233. /**
  24234. * Get the parent rotation
  24235. * @returns The parent rotation
  24236. */
  24237. getParentsRotation(): Quaternion;
  24238. /**
  24239. * this function is executed by the physics engine.
  24240. */
  24241. beforeStep: () => void;
  24242. /**
  24243. * this function is executed by the physics engine
  24244. */
  24245. afterStep: () => void;
  24246. /**
  24247. * Legacy collision detection event support
  24248. */
  24249. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24250. /**
  24251. * event and body object due to cannon's event-based architecture.
  24252. */
  24253. onCollide: (e: {
  24254. body: any;
  24255. }) => void;
  24256. /**
  24257. * Apply a force
  24258. * @param force The force to apply
  24259. * @param contactPoint The contact point for the force
  24260. * @returns The physics imposter
  24261. */
  24262. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24263. /**
  24264. * Apply an impulse
  24265. * @param force The impulse force
  24266. * @param contactPoint The contact point for the impulse force
  24267. * @returns The physics imposter
  24268. */
  24269. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24270. /**
  24271. * A help function to create a joint
  24272. * @param otherImpostor A physics imposter used to create a joint
  24273. * @param jointType The type of joint
  24274. * @param jointData The data for the joint
  24275. * @returns The physics imposter
  24276. */
  24277. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24278. /**
  24279. * Add a joint to this impostor with a different impostor
  24280. * @param otherImpostor A physics imposter used to add a joint
  24281. * @param joint The joint to add
  24282. * @returns The physics imposter
  24283. */
  24284. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24285. /**
  24286. * Add an anchor to a cloth impostor
  24287. * @param otherImpostor rigid impostor to anchor to
  24288. * @param width ratio across width from 0 to 1
  24289. * @param height ratio up height from 0 to 1
  24290. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24291. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24292. * @returns impostor the soft imposter
  24293. */
  24294. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24295. /**
  24296. * Add a hook to a rope impostor
  24297. * @param otherImpostor rigid impostor to anchor to
  24298. * @param length ratio across rope from 0 to 1
  24299. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24300. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24301. * @returns impostor the rope imposter
  24302. */
  24303. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24304. /**
  24305. * Will keep this body still, in a sleep mode.
  24306. * @returns the physics imposter
  24307. */
  24308. sleep(): PhysicsImpostor;
  24309. /**
  24310. * Wake the body up.
  24311. * @returns The physics imposter
  24312. */
  24313. wakeUp(): PhysicsImpostor;
  24314. /**
  24315. * Clones the physics imposter
  24316. * @param newObject The physics imposter clones to this physics-enabled object
  24317. * @returns A nullable physics imposter
  24318. */
  24319. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24320. /**
  24321. * Disposes the physics imposter
  24322. */
  24323. dispose(): void;
  24324. /**
  24325. * Sets the delta position
  24326. * @param position The delta position amount
  24327. */
  24328. setDeltaPosition(position: Vector3): void;
  24329. /**
  24330. * Sets the delta rotation
  24331. * @param rotation The delta rotation amount
  24332. */
  24333. setDeltaRotation(rotation: Quaternion): void;
  24334. /**
  24335. * Gets the box size of the physics imposter and stores the result in the input parameter
  24336. * @param result Stores the box size
  24337. * @returns The physics imposter
  24338. */
  24339. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24340. /**
  24341. * Gets the radius of the physics imposter
  24342. * @returns Radius of the physics imposter
  24343. */
  24344. getRadius(): number;
  24345. /**
  24346. * Sync a bone with this impostor
  24347. * @param bone The bone to sync to the impostor.
  24348. * @param boneMesh The mesh that the bone is influencing.
  24349. * @param jointPivot The pivot of the joint / bone in local space.
  24350. * @param distToJoint Optional distance from the impostor to the joint.
  24351. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24352. */
  24353. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24354. /**
  24355. * Sync impostor to a bone
  24356. * @param bone The bone that the impostor will be synced to.
  24357. * @param boneMesh The mesh that the bone is influencing.
  24358. * @param jointPivot The pivot of the joint / bone in local space.
  24359. * @param distToJoint Optional distance from the impostor to the joint.
  24360. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24361. * @param boneAxis Optional vector3 axis the bone is aligned with
  24362. */
  24363. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24364. /**
  24365. * No-Imposter type
  24366. */
  24367. static NoImpostor: number;
  24368. /**
  24369. * Sphere-Imposter type
  24370. */
  24371. static SphereImpostor: number;
  24372. /**
  24373. * Box-Imposter type
  24374. */
  24375. static BoxImpostor: number;
  24376. /**
  24377. * Plane-Imposter type
  24378. */
  24379. static PlaneImpostor: number;
  24380. /**
  24381. * Mesh-imposter type
  24382. */
  24383. static MeshImpostor: number;
  24384. /**
  24385. * Capsule-Impostor type (Ammo.js plugin only)
  24386. */
  24387. static CapsuleImpostor: number;
  24388. /**
  24389. * Cylinder-Imposter type
  24390. */
  24391. static CylinderImpostor: number;
  24392. /**
  24393. * Particle-Imposter type
  24394. */
  24395. static ParticleImpostor: number;
  24396. /**
  24397. * Heightmap-Imposter type
  24398. */
  24399. static HeightmapImpostor: number;
  24400. /**
  24401. * ConvexHull-Impostor type (Ammo.js plugin only)
  24402. */
  24403. static ConvexHullImpostor: number;
  24404. /**
  24405. * Rope-Imposter type
  24406. */
  24407. static RopeImpostor: number;
  24408. /**
  24409. * Cloth-Imposter type
  24410. */
  24411. static ClothImpostor: number;
  24412. /**
  24413. * Softbody-Imposter type
  24414. */
  24415. static SoftbodyImpostor: number;
  24416. }
  24417. }
  24418. declare module "babylonjs/Meshes/mesh" {
  24419. import { Observable } from "babylonjs/Misc/observable";
  24420. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24421. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24422. import { Camera } from "babylonjs/Cameras/camera";
  24423. import { Scene } from "babylonjs/scene";
  24424. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24425. import { Color4 } from "babylonjs/Maths/math.color";
  24426. import { Engine } from "babylonjs/Engines/engine";
  24427. import { Node } from "babylonjs/node";
  24428. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24429. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24430. import { Buffer } from "babylonjs/Meshes/buffer";
  24431. import { Geometry } from "babylonjs/Meshes/geometry";
  24432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24433. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24434. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24435. import { Effect } from "babylonjs/Materials/effect";
  24436. import { Material } from "babylonjs/Materials/material";
  24437. import { Skeleton } from "babylonjs/Bones/skeleton";
  24438. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24439. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24440. import { Path3D } from "babylonjs/Maths/math.path";
  24441. import { Plane } from "babylonjs/Maths/math.plane";
  24442. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24443. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24444. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24445. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24446. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24447. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24448. /**
  24449. * @hidden
  24450. **/
  24451. export class _CreationDataStorage {
  24452. closePath?: boolean;
  24453. closeArray?: boolean;
  24454. idx: number[];
  24455. dashSize: number;
  24456. gapSize: number;
  24457. path3D: Path3D;
  24458. pathArray: Vector3[][];
  24459. arc: number;
  24460. radius: number;
  24461. cap: number;
  24462. tessellation: number;
  24463. }
  24464. /**
  24465. * @hidden
  24466. **/
  24467. class _InstanceDataStorage {
  24468. visibleInstances: any;
  24469. batchCache: _InstancesBatch;
  24470. instancesBufferSize: number;
  24471. instancesBuffer: Nullable<Buffer>;
  24472. instancesData: Float32Array;
  24473. overridenInstanceCount: number;
  24474. isFrozen: boolean;
  24475. previousBatch: Nullable<_InstancesBatch>;
  24476. hardwareInstancedRendering: boolean;
  24477. sideOrientation: number;
  24478. manualUpdate: boolean;
  24479. }
  24480. /**
  24481. * @hidden
  24482. **/
  24483. export class _InstancesBatch {
  24484. mustReturn: boolean;
  24485. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24486. renderSelf: boolean[];
  24487. hardwareInstancedRendering: boolean[];
  24488. }
  24489. /**
  24490. * Class used to represent renderable models
  24491. */
  24492. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24493. /**
  24494. * Mesh side orientation : usually the external or front surface
  24495. */
  24496. static readonly FRONTSIDE: number;
  24497. /**
  24498. * Mesh side orientation : usually the internal or back surface
  24499. */
  24500. static readonly BACKSIDE: number;
  24501. /**
  24502. * Mesh side orientation : both internal and external or front and back surfaces
  24503. */
  24504. static readonly DOUBLESIDE: number;
  24505. /**
  24506. * Mesh side orientation : by default, `FRONTSIDE`
  24507. */
  24508. static readonly DEFAULTSIDE: number;
  24509. /**
  24510. * Mesh cap setting : no cap
  24511. */
  24512. static readonly NO_CAP: number;
  24513. /**
  24514. * Mesh cap setting : one cap at the beginning of the mesh
  24515. */
  24516. static readonly CAP_START: number;
  24517. /**
  24518. * Mesh cap setting : one cap at the end of the mesh
  24519. */
  24520. static readonly CAP_END: number;
  24521. /**
  24522. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24523. */
  24524. static readonly CAP_ALL: number;
  24525. /**
  24526. * Mesh pattern setting : no flip or rotate
  24527. */
  24528. static readonly NO_FLIP: number;
  24529. /**
  24530. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24531. */
  24532. static readonly FLIP_TILE: number;
  24533. /**
  24534. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24535. */
  24536. static readonly ROTATE_TILE: number;
  24537. /**
  24538. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24539. */
  24540. static readonly FLIP_ROW: number;
  24541. /**
  24542. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24543. */
  24544. static readonly ROTATE_ROW: number;
  24545. /**
  24546. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24547. */
  24548. static readonly FLIP_N_ROTATE_TILE: number;
  24549. /**
  24550. * Mesh pattern setting : rotate pattern and rotate
  24551. */
  24552. static readonly FLIP_N_ROTATE_ROW: number;
  24553. /**
  24554. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24555. */
  24556. static readonly CENTER: number;
  24557. /**
  24558. * Mesh tile positioning : part tiles on left
  24559. */
  24560. static readonly LEFT: number;
  24561. /**
  24562. * Mesh tile positioning : part tiles on right
  24563. */
  24564. static readonly RIGHT: number;
  24565. /**
  24566. * Mesh tile positioning : part tiles on top
  24567. */
  24568. static readonly TOP: number;
  24569. /**
  24570. * Mesh tile positioning : part tiles on bottom
  24571. */
  24572. static readonly BOTTOM: number;
  24573. /**
  24574. * Gets the default side orientation.
  24575. * @param orientation the orientation to value to attempt to get
  24576. * @returns the default orientation
  24577. * @hidden
  24578. */
  24579. static _GetDefaultSideOrientation(orientation?: number): number;
  24580. private _internalMeshDataInfo;
  24581. /**
  24582. * An event triggered before rendering the mesh
  24583. */
  24584. readonly onBeforeRenderObservable: Observable<Mesh>;
  24585. /**
  24586. * An event triggered before binding the mesh
  24587. */
  24588. readonly onBeforeBindObservable: Observable<Mesh>;
  24589. /**
  24590. * An event triggered after rendering the mesh
  24591. */
  24592. readonly onAfterRenderObservable: Observable<Mesh>;
  24593. /**
  24594. * An event triggered before drawing the mesh
  24595. */
  24596. readonly onBeforeDrawObservable: Observable<Mesh>;
  24597. private _onBeforeDrawObserver;
  24598. /**
  24599. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24600. */
  24601. onBeforeDraw: () => void;
  24602. readonly hasInstances: boolean;
  24603. /**
  24604. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24605. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24606. */
  24607. delayLoadState: number;
  24608. /**
  24609. * Gets the list of instances created from this mesh
  24610. * it is not supposed to be modified manually.
  24611. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24612. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24613. */
  24614. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24615. /**
  24616. * Gets the file containing delay loading data for this mesh
  24617. */
  24618. delayLoadingFile: string;
  24619. /** @hidden */
  24620. _binaryInfo: any;
  24621. /**
  24622. * User defined function used to change how LOD level selection is done
  24623. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24624. */
  24625. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24626. /**
  24627. * Gets or sets the morph target manager
  24628. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24629. */
  24630. morphTargetManager: Nullable<MorphTargetManager>;
  24631. /** @hidden */
  24632. _creationDataStorage: Nullable<_CreationDataStorage>;
  24633. /** @hidden */
  24634. _geometry: Nullable<Geometry>;
  24635. /** @hidden */
  24636. _delayInfo: Array<string>;
  24637. /** @hidden */
  24638. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24639. /** @hidden */
  24640. _instanceDataStorage: _InstanceDataStorage;
  24641. private _effectiveMaterial;
  24642. /** @hidden */
  24643. _shouldGenerateFlatShading: boolean;
  24644. /** @hidden */
  24645. _originalBuilderSideOrientation: number;
  24646. /**
  24647. * Use this property to change the original side orientation defined at construction time
  24648. */
  24649. overrideMaterialSideOrientation: Nullable<number>;
  24650. /**
  24651. * Gets the source mesh (the one used to clone this one from)
  24652. */
  24653. readonly source: Nullable<Mesh>;
  24654. /**
  24655. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24656. */
  24657. isUnIndexed: boolean;
  24658. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24659. readonly worldMatrixInstancedBuffer: Float32Array;
  24660. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24661. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  24662. /**
  24663. * @constructor
  24664. * @param name The value used by scene.getMeshByName() to do a lookup.
  24665. * @param scene The scene to add this mesh to.
  24666. * @param parent The parent of this mesh, if it has one
  24667. * @param source An optional Mesh from which geometry is shared, cloned.
  24668. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24669. * When false, achieved by calling a clone(), also passing False.
  24670. * This will make creation of children, recursive.
  24671. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24672. */
  24673. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24674. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24675. doNotInstantiate: boolean;
  24676. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24677. /**
  24678. * Gets the class name
  24679. * @returns the string "Mesh".
  24680. */
  24681. getClassName(): string;
  24682. /** @hidden */
  24683. readonly _isMesh: boolean;
  24684. /**
  24685. * Returns a description of this mesh
  24686. * @param fullDetails define if full details about this mesh must be used
  24687. * @returns a descriptive string representing this mesh
  24688. */
  24689. toString(fullDetails?: boolean): string;
  24690. /** @hidden */
  24691. _unBindEffect(): void;
  24692. /**
  24693. * Gets a boolean indicating if this mesh has LOD
  24694. */
  24695. readonly hasLODLevels: boolean;
  24696. /**
  24697. * Gets the list of MeshLODLevel associated with the current mesh
  24698. * @returns an array of MeshLODLevel
  24699. */
  24700. getLODLevels(): MeshLODLevel[];
  24701. private _sortLODLevels;
  24702. /**
  24703. * Add a mesh as LOD level triggered at the given distance.
  24704. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24705. * @param distance The distance from the center of the object to show this level
  24706. * @param mesh The mesh to be added as LOD level (can be null)
  24707. * @return This mesh (for chaining)
  24708. */
  24709. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24710. /**
  24711. * Returns the LOD level mesh at the passed distance or null if not found.
  24712. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24713. * @param distance The distance from the center of the object to show this level
  24714. * @returns a Mesh or `null`
  24715. */
  24716. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24717. /**
  24718. * Remove a mesh from the LOD array
  24719. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24720. * @param mesh defines the mesh to be removed
  24721. * @return This mesh (for chaining)
  24722. */
  24723. removeLODLevel(mesh: Mesh): Mesh;
  24724. /**
  24725. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24726. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24727. * @param camera defines the camera to use to compute distance
  24728. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24729. * @return This mesh (for chaining)
  24730. */
  24731. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24732. /**
  24733. * Gets the mesh internal Geometry object
  24734. */
  24735. readonly geometry: Nullable<Geometry>;
  24736. /**
  24737. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24738. * @returns the total number of vertices
  24739. */
  24740. getTotalVertices(): number;
  24741. /**
  24742. * Returns the content of an associated vertex buffer
  24743. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24744. * - VertexBuffer.PositionKind
  24745. * - VertexBuffer.UVKind
  24746. * - VertexBuffer.UV2Kind
  24747. * - VertexBuffer.UV3Kind
  24748. * - VertexBuffer.UV4Kind
  24749. * - VertexBuffer.UV5Kind
  24750. * - VertexBuffer.UV6Kind
  24751. * - VertexBuffer.ColorKind
  24752. * - VertexBuffer.MatricesIndicesKind
  24753. * - VertexBuffer.MatricesIndicesExtraKind
  24754. * - VertexBuffer.MatricesWeightsKind
  24755. * - VertexBuffer.MatricesWeightsExtraKind
  24756. * @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
  24757. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24758. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24759. */
  24760. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24761. /**
  24762. * Returns the mesh VertexBuffer object from the requested `kind`
  24763. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24764. * - VertexBuffer.PositionKind
  24765. * - VertexBuffer.NormalKind
  24766. * - VertexBuffer.UVKind
  24767. * - VertexBuffer.UV2Kind
  24768. * - VertexBuffer.UV3Kind
  24769. * - VertexBuffer.UV4Kind
  24770. * - VertexBuffer.UV5Kind
  24771. * - VertexBuffer.UV6Kind
  24772. * - VertexBuffer.ColorKind
  24773. * - VertexBuffer.MatricesIndicesKind
  24774. * - VertexBuffer.MatricesIndicesExtraKind
  24775. * - VertexBuffer.MatricesWeightsKind
  24776. * - VertexBuffer.MatricesWeightsExtraKind
  24777. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24778. */
  24779. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24780. /**
  24781. * Tests if a specific vertex buffer is associated with this mesh
  24782. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24783. * - VertexBuffer.PositionKind
  24784. * - VertexBuffer.NormalKind
  24785. * - VertexBuffer.UVKind
  24786. * - VertexBuffer.UV2Kind
  24787. * - VertexBuffer.UV3Kind
  24788. * - VertexBuffer.UV4Kind
  24789. * - VertexBuffer.UV5Kind
  24790. * - VertexBuffer.UV6Kind
  24791. * - VertexBuffer.ColorKind
  24792. * - VertexBuffer.MatricesIndicesKind
  24793. * - VertexBuffer.MatricesIndicesExtraKind
  24794. * - VertexBuffer.MatricesWeightsKind
  24795. * - VertexBuffer.MatricesWeightsExtraKind
  24796. * @returns a boolean
  24797. */
  24798. isVerticesDataPresent(kind: string): boolean;
  24799. /**
  24800. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24801. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24802. * - VertexBuffer.PositionKind
  24803. * - VertexBuffer.UVKind
  24804. * - VertexBuffer.UV2Kind
  24805. * - VertexBuffer.UV3Kind
  24806. * - VertexBuffer.UV4Kind
  24807. * - VertexBuffer.UV5Kind
  24808. * - VertexBuffer.UV6Kind
  24809. * - VertexBuffer.ColorKind
  24810. * - VertexBuffer.MatricesIndicesKind
  24811. * - VertexBuffer.MatricesIndicesExtraKind
  24812. * - VertexBuffer.MatricesWeightsKind
  24813. * - VertexBuffer.MatricesWeightsExtraKind
  24814. * @returns a boolean
  24815. */
  24816. isVertexBufferUpdatable(kind: string): boolean;
  24817. /**
  24818. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24819. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24820. * - VertexBuffer.PositionKind
  24821. * - VertexBuffer.NormalKind
  24822. * - VertexBuffer.UVKind
  24823. * - VertexBuffer.UV2Kind
  24824. * - VertexBuffer.UV3Kind
  24825. * - VertexBuffer.UV4Kind
  24826. * - VertexBuffer.UV5Kind
  24827. * - VertexBuffer.UV6Kind
  24828. * - VertexBuffer.ColorKind
  24829. * - VertexBuffer.MatricesIndicesKind
  24830. * - VertexBuffer.MatricesIndicesExtraKind
  24831. * - VertexBuffer.MatricesWeightsKind
  24832. * - VertexBuffer.MatricesWeightsExtraKind
  24833. * @returns an array of strings
  24834. */
  24835. getVerticesDataKinds(): string[];
  24836. /**
  24837. * Returns a positive integer : the total number of indices in this mesh geometry.
  24838. * @returns the numner of indices or zero if the mesh has no geometry.
  24839. */
  24840. getTotalIndices(): number;
  24841. /**
  24842. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24843. * @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.
  24844. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24845. * @returns the indices array or an empty array if the mesh has no geometry
  24846. */
  24847. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24848. readonly isBlocked: boolean;
  24849. /**
  24850. * Determine if the current mesh is ready to be rendered
  24851. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24852. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24853. * @returns true if all associated assets are ready (material, textures, shaders)
  24854. */
  24855. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24856. /**
  24857. * 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.
  24858. */
  24859. readonly areNormalsFrozen: boolean;
  24860. /**
  24861. * 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.
  24862. * @returns the current mesh
  24863. */
  24864. freezeNormals(): Mesh;
  24865. /**
  24866. * 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
  24867. * @returns the current mesh
  24868. */
  24869. unfreezeNormals(): Mesh;
  24870. /**
  24871. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24872. */
  24873. overridenInstanceCount: number;
  24874. /** @hidden */
  24875. _preActivate(): Mesh;
  24876. /** @hidden */
  24877. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24878. /** @hidden */
  24879. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24880. /**
  24881. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24882. * This means the mesh underlying bounding box and sphere are recomputed.
  24883. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24884. * @returns the current mesh
  24885. */
  24886. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24887. /** @hidden */
  24888. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24889. /**
  24890. * This function will subdivide the mesh into multiple submeshes
  24891. * @param count defines the expected number of submeshes
  24892. */
  24893. subdivide(count: number): void;
  24894. /**
  24895. * Copy a FloatArray into a specific associated vertex buffer
  24896. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24897. * - VertexBuffer.PositionKind
  24898. * - VertexBuffer.UVKind
  24899. * - VertexBuffer.UV2Kind
  24900. * - VertexBuffer.UV3Kind
  24901. * - VertexBuffer.UV4Kind
  24902. * - VertexBuffer.UV5Kind
  24903. * - VertexBuffer.UV6Kind
  24904. * - VertexBuffer.ColorKind
  24905. * - VertexBuffer.MatricesIndicesKind
  24906. * - VertexBuffer.MatricesIndicesExtraKind
  24907. * - VertexBuffer.MatricesWeightsKind
  24908. * - VertexBuffer.MatricesWeightsExtraKind
  24909. * @param data defines the data source
  24910. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24911. * @param stride defines the data stride size (can be null)
  24912. * @returns the current mesh
  24913. */
  24914. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24915. /**
  24916. * Delete a vertex buffer associated with this mesh
  24917. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24918. * - VertexBuffer.PositionKind
  24919. * - VertexBuffer.UVKind
  24920. * - VertexBuffer.UV2Kind
  24921. * - VertexBuffer.UV3Kind
  24922. * - VertexBuffer.UV4Kind
  24923. * - VertexBuffer.UV5Kind
  24924. * - VertexBuffer.UV6Kind
  24925. * - VertexBuffer.ColorKind
  24926. * - VertexBuffer.MatricesIndicesKind
  24927. * - VertexBuffer.MatricesIndicesExtraKind
  24928. * - VertexBuffer.MatricesWeightsKind
  24929. * - VertexBuffer.MatricesWeightsExtraKind
  24930. */
  24931. removeVerticesData(kind: string): void;
  24932. /**
  24933. * Flags an associated vertex buffer as updatable
  24934. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24935. * - VertexBuffer.PositionKind
  24936. * - VertexBuffer.UVKind
  24937. * - VertexBuffer.UV2Kind
  24938. * - VertexBuffer.UV3Kind
  24939. * - VertexBuffer.UV4Kind
  24940. * - VertexBuffer.UV5Kind
  24941. * - VertexBuffer.UV6Kind
  24942. * - VertexBuffer.ColorKind
  24943. * - VertexBuffer.MatricesIndicesKind
  24944. * - VertexBuffer.MatricesIndicesExtraKind
  24945. * - VertexBuffer.MatricesWeightsKind
  24946. * - VertexBuffer.MatricesWeightsExtraKind
  24947. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24948. */
  24949. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24950. /**
  24951. * Sets the mesh global Vertex Buffer
  24952. * @param buffer defines the buffer to use
  24953. * @returns the current mesh
  24954. */
  24955. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24956. /**
  24957. * Update a specific associated vertex buffer
  24958. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24959. * - VertexBuffer.PositionKind
  24960. * - VertexBuffer.UVKind
  24961. * - VertexBuffer.UV2Kind
  24962. * - VertexBuffer.UV3Kind
  24963. * - VertexBuffer.UV4Kind
  24964. * - VertexBuffer.UV5Kind
  24965. * - VertexBuffer.UV6Kind
  24966. * - VertexBuffer.ColorKind
  24967. * - VertexBuffer.MatricesIndicesKind
  24968. * - VertexBuffer.MatricesIndicesExtraKind
  24969. * - VertexBuffer.MatricesWeightsKind
  24970. * - VertexBuffer.MatricesWeightsExtraKind
  24971. * @param data defines the data source
  24972. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24973. * @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)
  24974. * @returns the current mesh
  24975. */
  24976. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24977. /**
  24978. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24979. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24980. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24981. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24982. * @returns the current mesh
  24983. */
  24984. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24985. /**
  24986. * Creates a un-shared specific occurence of the geometry for the mesh.
  24987. * @returns the current mesh
  24988. */
  24989. makeGeometryUnique(): Mesh;
  24990. /**
  24991. * Set the index buffer of this mesh
  24992. * @param indices defines the source data
  24993. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24994. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24995. * @returns the current mesh
  24996. */
  24997. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24998. /**
  24999. * Update the current index buffer
  25000. * @param indices defines the source data
  25001. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25002. * @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)
  25003. * @returns the current mesh
  25004. */
  25005. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25006. /**
  25007. * Invert the geometry to move from a right handed system to a left handed one.
  25008. * @returns the current mesh
  25009. */
  25010. toLeftHanded(): Mesh;
  25011. /** @hidden */
  25012. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25013. /** @hidden */
  25014. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25015. /**
  25016. * Registers for this mesh a javascript function called just before the rendering process
  25017. * @param func defines the function to call before rendering this mesh
  25018. * @returns the current mesh
  25019. */
  25020. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25021. /**
  25022. * Disposes a previously registered javascript function called before the rendering
  25023. * @param func defines the function to remove
  25024. * @returns the current mesh
  25025. */
  25026. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25027. /**
  25028. * Registers for this mesh a javascript function called just after the rendering is complete
  25029. * @param func defines the function to call after rendering this mesh
  25030. * @returns the current mesh
  25031. */
  25032. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25033. /**
  25034. * Disposes a previously registered javascript function called after the rendering.
  25035. * @param func defines the function to remove
  25036. * @returns the current mesh
  25037. */
  25038. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25039. /** @hidden */
  25040. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25041. /** @hidden */
  25042. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25043. /** @hidden */
  25044. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25045. /** @hidden */
  25046. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25047. /** @hidden */
  25048. _rebuild(): void;
  25049. /** @hidden */
  25050. _freeze(): void;
  25051. /** @hidden */
  25052. _unFreeze(): void;
  25053. /**
  25054. * 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
  25055. * @param subMesh defines the subMesh to render
  25056. * @param enableAlphaMode defines if alpha mode can be changed
  25057. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25058. * @returns the current mesh
  25059. */
  25060. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25061. private _onBeforeDraw;
  25062. /**
  25063. * Renormalize the mesh and patch it up if there are no weights
  25064. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25065. * However in the case of zero weights then we set just a single influence to 1.
  25066. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25067. */
  25068. cleanMatrixWeights(): void;
  25069. private normalizeSkinFourWeights;
  25070. private normalizeSkinWeightsAndExtra;
  25071. /**
  25072. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25073. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25074. * the user know there was an issue with importing the mesh
  25075. * @returns a validation object with skinned, valid and report string
  25076. */
  25077. validateSkinning(): {
  25078. skinned: boolean;
  25079. valid: boolean;
  25080. report: string;
  25081. };
  25082. /** @hidden */
  25083. _checkDelayState(): Mesh;
  25084. private _queueLoad;
  25085. /**
  25086. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25087. * A mesh is in the frustum if its bounding box intersects the frustum
  25088. * @param frustumPlanes defines the frustum to test
  25089. * @returns true if the mesh is in the frustum planes
  25090. */
  25091. isInFrustum(frustumPlanes: Plane[]): boolean;
  25092. /**
  25093. * Sets the mesh material by the material or multiMaterial `id` property
  25094. * @param id is a string identifying the material or the multiMaterial
  25095. * @returns the current mesh
  25096. */
  25097. setMaterialByID(id: string): Mesh;
  25098. /**
  25099. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25100. * @returns an array of IAnimatable
  25101. */
  25102. getAnimatables(): IAnimatable[];
  25103. /**
  25104. * Modifies the mesh geometry according to the passed transformation matrix.
  25105. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25106. * The mesh normals are modified using the same transformation.
  25107. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25108. * @param transform defines the transform matrix to use
  25109. * @see http://doc.babylonjs.com/resources/baking_transformations
  25110. * @returns the current mesh
  25111. */
  25112. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25113. /**
  25114. * Modifies the mesh geometry according to its own current World Matrix.
  25115. * The mesh World Matrix is then reset.
  25116. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25117. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25118. * @see http://doc.babylonjs.com/resources/baking_transformations
  25119. * @returns the current mesh
  25120. */
  25121. bakeCurrentTransformIntoVertices(): Mesh;
  25122. /** @hidden */
  25123. readonly _positions: Nullable<Vector3[]>;
  25124. /** @hidden */
  25125. _resetPointsArrayCache(): Mesh;
  25126. /** @hidden */
  25127. _generatePointsArray(): boolean;
  25128. /**
  25129. * Returns a new Mesh object generated from the current mesh properties.
  25130. * This method must not get confused with createInstance()
  25131. * @param name is a string, the name given to the new mesh
  25132. * @param newParent can be any Node object (default `null`)
  25133. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25134. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25135. * @returns a new mesh
  25136. */
  25137. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25138. /**
  25139. * Releases resources associated with this mesh.
  25140. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25141. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25142. */
  25143. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25144. /** @hidden */
  25145. _disposeInstanceSpecificData(): void;
  25146. /**
  25147. * Modifies the mesh geometry according to a displacement map.
  25148. * 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.
  25149. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25150. * @param url is a string, the URL from the image file is to be downloaded.
  25151. * @param minHeight is the lower limit of the displacement.
  25152. * @param maxHeight is the upper limit of the displacement.
  25153. * @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.
  25154. * @param uvOffset is an optional vector2 used to offset UV.
  25155. * @param uvScale is an optional vector2 used to scale UV.
  25156. * @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.
  25157. * @returns the Mesh.
  25158. */
  25159. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25160. /**
  25161. * Modifies the mesh geometry according to a displacementMap buffer.
  25162. * 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.
  25163. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25164. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25165. * @param heightMapWidth is the width of the buffer image.
  25166. * @param heightMapHeight is the height of the buffer image.
  25167. * @param minHeight is the lower limit of the displacement.
  25168. * @param maxHeight is the upper limit of the displacement.
  25169. * @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.
  25170. * @param uvOffset is an optional vector2 used to offset UV.
  25171. * @param uvScale is an optional vector2 used to scale UV.
  25172. * @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.
  25173. * @returns the Mesh.
  25174. */
  25175. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25176. /**
  25177. * Modify the mesh to get a flat shading rendering.
  25178. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25179. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25180. * @returns current mesh
  25181. */
  25182. convertToFlatShadedMesh(): Mesh;
  25183. /**
  25184. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25185. * In other words, more vertices, no more indices and a single bigger VBO.
  25186. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25187. * @returns current mesh
  25188. */
  25189. convertToUnIndexedMesh(): Mesh;
  25190. /**
  25191. * Inverses facet orientations.
  25192. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25193. * @param flipNormals will also inverts the normals
  25194. * @returns current mesh
  25195. */
  25196. flipFaces(flipNormals?: boolean): Mesh;
  25197. /**
  25198. * Increase the number of facets and hence vertices in a mesh
  25199. * Vertex normals are interpolated from existing vertex normals
  25200. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25201. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25202. */
  25203. increaseVertices(numberPerEdge: number): void;
  25204. /**
  25205. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25206. * This will undo any application of covertToFlatShadedMesh
  25207. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25208. */
  25209. forceSharedVertices(): void;
  25210. /** @hidden */
  25211. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25212. /** @hidden */
  25213. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25214. /**
  25215. * Creates a new InstancedMesh object from the mesh model.
  25216. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25217. * @param name defines the name of the new instance
  25218. * @returns a new InstancedMesh
  25219. */
  25220. createInstance(name: string): InstancedMesh;
  25221. /**
  25222. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25223. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25224. * @returns the current mesh
  25225. */
  25226. synchronizeInstances(): Mesh;
  25227. /**
  25228. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25229. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25230. * This should be used together with the simplification to avoid disappearing triangles.
  25231. * @param successCallback an optional success callback to be called after the optimization finished.
  25232. * @returns the current mesh
  25233. */
  25234. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25235. /**
  25236. * Serialize current mesh
  25237. * @param serializationObject defines the object which will receive the serialization data
  25238. */
  25239. serialize(serializationObject: any): void;
  25240. /** @hidden */
  25241. _syncGeometryWithMorphTargetManager(): void;
  25242. /** @hidden */
  25243. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25244. /**
  25245. * Returns a new Mesh object parsed from the source provided.
  25246. * @param parsedMesh is the source
  25247. * @param scene defines the hosting scene
  25248. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25249. * @returns a new Mesh
  25250. */
  25251. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25252. /**
  25253. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25254. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25255. * @param name defines the name of the mesh to create
  25256. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25257. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25258. * @param closePath creates a seam between the first and the last points of each path of the path array
  25259. * @param offset is taken in account only if the `pathArray` is containing a single path
  25260. * @param scene defines the hosting scene
  25261. * @param updatable defines if the mesh must be flagged as updatable
  25262. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25263. * @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)
  25264. * @returns a new Mesh
  25265. */
  25266. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25267. /**
  25268. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25269. * @param name defines the name of the mesh to create
  25270. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25271. * @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
  25272. * @param scene defines the hosting scene
  25273. * @param updatable defines if the mesh must be flagged as updatable
  25274. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25275. * @returns a new Mesh
  25276. */
  25277. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25278. /**
  25279. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25280. * @param name defines the name of the mesh to create
  25281. * @param size sets the size (float) of each box side (default 1)
  25282. * @param scene defines the hosting scene
  25283. * @param updatable defines if the mesh must be flagged as updatable
  25284. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25285. * @returns a new Mesh
  25286. */
  25287. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25288. /**
  25289. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25290. * @param name defines the name of the mesh to create
  25291. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25292. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25293. * @param scene defines the hosting scene
  25294. * @param updatable defines if the mesh must be flagged as updatable
  25295. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25296. * @returns a new Mesh
  25297. */
  25298. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25299. /**
  25300. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25301. * @param name defines the name of the mesh to create
  25302. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25303. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25304. * @param scene defines the hosting scene
  25305. * @returns a new Mesh
  25306. */
  25307. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25308. /**
  25309. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25310. * @param name defines the name of the mesh to create
  25311. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25312. * @param diameterTop set the top cap diameter (floats, default 1)
  25313. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25314. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25315. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25316. * @param scene defines the hosting scene
  25317. * @param updatable defines if the mesh must be flagged as updatable
  25318. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25319. * @returns a new Mesh
  25320. */
  25321. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25322. /**
  25323. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25324. * @param name defines the name of the mesh to create
  25325. * @param diameter sets the diameter size (float) of the torus (default 1)
  25326. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25327. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25328. * @param scene defines the hosting scene
  25329. * @param updatable defines if the mesh must be flagged as updatable
  25330. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25331. * @returns a new Mesh
  25332. */
  25333. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25334. /**
  25335. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25336. * @param name defines the name of the mesh to create
  25337. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25338. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25339. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25340. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25341. * @param p the number of windings on X axis (positive integers, default 2)
  25342. * @param q the number of windings on Y axis (positive integers, default 3)
  25343. * @param scene defines the hosting scene
  25344. * @param updatable defines if the mesh must be flagged as updatable
  25345. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25346. * @returns a new Mesh
  25347. */
  25348. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25349. /**
  25350. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25351. * @param name defines the name of the mesh to create
  25352. * @param points is an array successive Vector3
  25353. * @param scene defines the hosting scene
  25354. * @param updatable defines if the mesh must be flagged as updatable
  25355. * @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).
  25356. * @returns a new Mesh
  25357. */
  25358. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25359. /**
  25360. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25361. * @param name defines the name of the mesh to create
  25362. * @param points is an array successive Vector3
  25363. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25364. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25365. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25366. * @param scene defines the hosting scene
  25367. * @param updatable defines if the mesh must be flagged as updatable
  25368. * @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)
  25369. * @returns a new Mesh
  25370. */
  25371. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25372. /**
  25373. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25374. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25375. * 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.
  25376. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25377. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25378. * Remember you can only change the shape positions, not their number when updating a polygon.
  25379. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25380. * @param name defines the name of the mesh to create
  25381. * @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
  25382. * @param scene defines the hosting scene
  25383. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25384. * @param updatable defines if the mesh must be flagged as updatable
  25385. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25386. * @param earcutInjection can be used to inject your own earcut reference
  25387. * @returns a new Mesh
  25388. */
  25389. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25390. /**
  25391. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25392. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25393. * @param name defines the name of the mesh to create
  25394. * @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
  25395. * @param depth defines the height of extrusion
  25396. * @param scene defines the hosting scene
  25397. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25398. * @param updatable defines if the mesh must be flagged as updatable
  25399. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25400. * @param earcutInjection can be used to inject your own earcut reference
  25401. * @returns a new Mesh
  25402. */
  25403. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25404. /**
  25405. * Creates an extruded shape mesh.
  25406. * 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
  25407. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25408. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25409. * @param name defines the name of the mesh to create
  25410. * @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
  25411. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25412. * @param scale is the value to scale the shape
  25413. * @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
  25414. * @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
  25415. * @param scene defines the hosting scene
  25416. * @param updatable defines if the mesh must be flagged as updatable
  25417. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25418. * @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)
  25419. * @returns a new Mesh
  25420. */
  25421. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25422. /**
  25423. * Creates an custom extruded shape mesh.
  25424. * The custom extrusion is a parametric shape.
  25425. * It has no predefined shape. Its final shape will depend on the input parameters.
  25426. * Please consider using the same method from the MeshBuilder class instead
  25427. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25428. * @param name defines the name of the mesh to create
  25429. * @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
  25430. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25431. * @param scaleFunction is a custom Javascript function called on each path point
  25432. * @param rotationFunction is a custom Javascript function called on each path point
  25433. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25434. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25435. * @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
  25436. * @param scene defines the hosting scene
  25437. * @param updatable defines if the mesh must be flagged as updatable
  25438. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25439. * @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)
  25440. * @returns a new Mesh
  25441. */
  25442. 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;
  25443. /**
  25444. * Creates lathe mesh.
  25445. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25446. * Please consider using the same method from the MeshBuilder class instead
  25447. * @param name defines the name of the mesh to create
  25448. * @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
  25449. * @param radius is the radius value of the lathe
  25450. * @param tessellation is the side number of the lathe.
  25451. * @param scene defines the hosting scene
  25452. * @param updatable defines if the mesh must be flagged as updatable
  25453. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25454. * @returns a new Mesh
  25455. */
  25456. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25457. /**
  25458. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25459. * @param name defines the name of the mesh to create
  25460. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25461. * @param scene defines the hosting scene
  25462. * @param updatable defines if the mesh must be flagged as updatable
  25463. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25464. * @returns a new Mesh
  25465. */
  25466. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25467. /**
  25468. * Creates a ground mesh.
  25469. * Please consider using the same method from the MeshBuilder class instead
  25470. * @param name defines the name of the mesh to create
  25471. * @param width set the width of the ground
  25472. * @param height set the height of the ground
  25473. * @param subdivisions sets the number of subdivisions per side
  25474. * @param scene defines the hosting scene
  25475. * @param updatable defines if the mesh must be flagged as updatable
  25476. * @returns a new Mesh
  25477. */
  25478. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25479. /**
  25480. * Creates a tiled ground mesh.
  25481. * Please consider using the same method from the MeshBuilder class instead
  25482. * @param name defines the name of the mesh to create
  25483. * @param xmin set the ground minimum X coordinate
  25484. * @param zmin set the ground minimum Y coordinate
  25485. * @param xmax set the ground maximum X coordinate
  25486. * @param zmax set the ground maximum Z coordinate
  25487. * @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
  25488. * @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
  25489. * @param scene defines the hosting scene
  25490. * @param updatable defines if the mesh must be flagged as updatable
  25491. * @returns a new Mesh
  25492. */
  25493. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25494. w: number;
  25495. h: number;
  25496. }, precision: {
  25497. w: number;
  25498. h: number;
  25499. }, scene: Scene, updatable?: boolean): Mesh;
  25500. /**
  25501. * Creates a ground mesh from a height map.
  25502. * Please consider using the same method from the MeshBuilder class instead
  25503. * @see http://doc.babylonjs.com/babylon101/height_map
  25504. * @param name defines the name of the mesh to create
  25505. * @param url sets the URL of the height map image resource
  25506. * @param width set the ground width size
  25507. * @param height set the ground height size
  25508. * @param subdivisions sets the number of subdivision per side
  25509. * @param minHeight is the minimum altitude on the ground
  25510. * @param maxHeight is the maximum altitude on the ground
  25511. * @param scene defines the hosting scene
  25512. * @param updatable defines if the mesh must be flagged as updatable
  25513. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25514. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25515. * @returns a new Mesh
  25516. */
  25517. 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;
  25518. /**
  25519. * Creates a tube mesh.
  25520. * The tube is a parametric shape.
  25521. * It has no predefined shape. Its final shape will depend on the input parameters.
  25522. * Please consider using the same method from the MeshBuilder class instead
  25523. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25524. * @param name defines the name of the mesh to create
  25525. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25526. * @param radius sets the tube radius size
  25527. * @param tessellation is the number of sides on the tubular surface
  25528. * @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
  25529. * @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
  25530. * @param scene defines the hosting scene
  25531. * @param updatable defines if the mesh must be flagged as updatable
  25532. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25533. * @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)
  25534. * @returns a new Mesh
  25535. */
  25536. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25537. (i: number, distance: number): number;
  25538. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25539. /**
  25540. * Creates a polyhedron mesh.
  25541. * Please consider using the same method from the MeshBuilder class instead.
  25542. * * 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
  25543. * * The parameter `size` (positive float, default 1) sets the polygon size
  25544. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25545. * * 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`
  25546. * * 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
  25547. * * 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)`)
  25548. * * 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
  25549. * * 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
  25550. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25551. * * If you create a double-sided mesh, you can choose what parts of 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
  25552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25553. * @param name defines the name of the mesh to create
  25554. * @param options defines the options used to create the mesh
  25555. * @param scene defines the hosting scene
  25556. * @returns a new Mesh
  25557. */
  25558. static CreatePolyhedron(name: string, options: {
  25559. type?: number;
  25560. size?: number;
  25561. sizeX?: number;
  25562. sizeY?: number;
  25563. sizeZ?: number;
  25564. custom?: any;
  25565. faceUV?: Vector4[];
  25566. faceColors?: Color4[];
  25567. updatable?: boolean;
  25568. sideOrientation?: number;
  25569. }, scene: Scene): Mesh;
  25570. /**
  25571. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25572. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25573. * * 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`)
  25574. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25575. * * 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
  25576. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25577. * * If you create a double-sided mesh, you can choose what parts of 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
  25578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25579. * @param name defines the name of the mesh
  25580. * @param options defines the options used to create the mesh
  25581. * @param scene defines the hosting scene
  25582. * @returns a new Mesh
  25583. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25584. */
  25585. static CreateIcoSphere(name: string, options: {
  25586. radius?: number;
  25587. flat?: boolean;
  25588. subdivisions?: number;
  25589. sideOrientation?: number;
  25590. updatable?: boolean;
  25591. }, scene: Scene): Mesh;
  25592. /**
  25593. * Creates a decal mesh.
  25594. * Please consider using the same method from the MeshBuilder class instead.
  25595. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25596. * @param name defines the name of the mesh
  25597. * @param sourceMesh defines the mesh receiving the decal
  25598. * @param position sets the position of the decal in world coordinates
  25599. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25600. * @param size sets the decal scaling
  25601. * @param angle sets the angle to rotate the decal
  25602. * @returns a new Mesh
  25603. */
  25604. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25605. /**
  25606. * Prepare internal position array for software CPU skinning
  25607. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25608. */
  25609. setPositionsForCPUSkinning(): Float32Array;
  25610. /**
  25611. * Prepare internal normal array for software CPU skinning
  25612. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25613. */
  25614. setNormalsForCPUSkinning(): Float32Array;
  25615. /**
  25616. * Updates the vertex buffer by applying transformation from the bones
  25617. * @param skeleton defines the skeleton to apply to current mesh
  25618. * @returns the current mesh
  25619. */
  25620. applySkeleton(skeleton: Skeleton): Mesh;
  25621. /**
  25622. * 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
  25623. * @param meshes defines the list of meshes to scan
  25624. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25625. */
  25626. static MinMax(meshes: AbstractMesh[]): {
  25627. min: Vector3;
  25628. max: Vector3;
  25629. };
  25630. /**
  25631. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25632. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25633. * @returns a vector3
  25634. */
  25635. static Center(meshesOrMinMaxVector: {
  25636. min: Vector3;
  25637. max: Vector3;
  25638. } | AbstractMesh[]): Vector3;
  25639. /**
  25640. * Merge the array of meshes into a single mesh for performance reasons.
  25641. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25642. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25643. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25644. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25645. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25646. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25647. * @returns a new mesh
  25648. */
  25649. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25650. /** @hidden */
  25651. addInstance(instance: InstancedMesh): void;
  25652. /** @hidden */
  25653. removeInstance(instance: InstancedMesh): void;
  25654. }
  25655. }
  25656. declare module "babylonjs/Cameras/camera" {
  25657. import { SmartArray } from "babylonjs/Misc/smartArray";
  25658. import { Observable } from "babylonjs/Misc/observable";
  25659. import { Nullable } from "babylonjs/types";
  25660. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25661. import { Scene } from "babylonjs/scene";
  25662. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25663. import { Node } from "babylonjs/node";
  25664. import { Mesh } from "babylonjs/Meshes/mesh";
  25665. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25666. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25667. import { Viewport } from "babylonjs/Maths/math.viewport";
  25668. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25669. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25670. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25671. import { Ray } from "babylonjs/Culling/ray";
  25672. /**
  25673. * This is the base class of all the camera used in the application.
  25674. * @see http://doc.babylonjs.com/features/cameras
  25675. */
  25676. export class Camera extends Node {
  25677. /** @hidden */
  25678. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25679. /**
  25680. * This is the default projection mode used by the cameras.
  25681. * It helps recreating a feeling of perspective and better appreciate depth.
  25682. * This is the best way to simulate real life cameras.
  25683. */
  25684. static readonly PERSPECTIVE_CAMERA: number;
  25685. /**
  25686. * This helps creating camera with an orthographic mode.
  25687. * 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.
  25688. */
  25689. static readonly ORTHOGRAPHIC_CAMERA: number;
  25690. /**
  25691. * This is the default FOV mode for perspective cameras.
  25692. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25693. */
  25694. static readonly FOVMODE_VERTICAL_FIXED: number;
  25695. /**
  25696. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25697. */
  25698. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25699. /**
  25700. * This specifies ther is no need for a camera rig.
  25701. * Basically only one eye is rendered corresponding to the camera.
  25702. */
  25703. static readonly RIG_MODE_NONE: number;
  25704. /**
  25705. * Simulates a camera Rig with one blue eye and one red eye.
  25706. * This can be use with 3d blue and red glasses.
  25707. */
  25708. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25709. /**
  25710. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25711. */
  25712. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25713. /**
  25714. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25715. */
  25716. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25717. /**
  25718. * Defines that both eyes of the camera will be rendered over under each other.
  25719. */
  25720. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25721. /**
  25722. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25723. */
  25724. static readonly RIG_MODE_VR: number;
  25725. /**
  25726. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25727. */
  25728. static readonly RIG_MODE_WEBVR: number;
  25729. /**
  25730. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25731. */
  25732. static readonly RIG_MODE_CUSTOM: number;
  25733. /**
  25734. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25735. */
  25736. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25737. /**
  25738. * Define the input manager associated with the camera.
  25739. */
  25740. inputs: CameraInputsManager<Camera>;
  25741. /** @hidden */
  25742. _position: Vector3;
  25743. /**
  25744. * Define the current local position of the camera in the scene
  25745. */
  25746. position: Vector3;
  25747. /**
  25748. * The vector the camera should consider as up.
  25749. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25750. */
  25751. upVector: Vector3;
  25752. /**
  25753. * Define the current limit on the left side for an orthographic camera
  25754. * In scene unit
  25755. */
  25756. orthoLeft: Nullable<number>;
  25757. /**
  25758. * Define the current limit on the right side for an orthographic camera
  25759. * In scene unit
  25760. */
  25761. orthoRight: Nullable<number>;
  25762. /**
  25763. * Define the current limit on the bottom side for an orthographic camera
  25764. * In scene unit
  25765. */
  25766. orthoBottom: Nullable<number>;
  25767. /**
  25768. * Define the current limit on the top side for an orthographic camera
  25769. * In scene unit
  25770. */
  25771. orthoTop: Nullable<number>;
  25772. /**
  25773. * Field Of View is set in Radians. (default is 0.8)
  25774. */
  25775. fov: number;
  25776. /**
  25777. * Define the minimum distance the camera can see from.
  25778. * This is important to note that the depth buffer are not infinite and the closer it starts
  25779. * the more your scene might encounter depth fighting issue.
  25780. */
  25781. minZ: number;
  25782. /**
  25783. * Define the maximum distance the camera can see to.
  25784. * This is important to note that the depth buffer are not infinite and the further it end
  25785. * the more your scene might encounter depth fighting issue.
  25786. */
  25787. maxZ: number;
  25788. /**
  25789. * Define the default inertia of the camera.
  25790. * This helps giving a smooth feeling to the camera movement.
  25791. */
  25792. inertia: number;
  25793. /**
  25794. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25795. */
  25796. mode: number;
  25797. /**
  25798. * Define wether the camera is intermediate.
  25799. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25800. */
  25801. isIntermediate: boolean;
  25802. /**
  25803. * Define the viewport of the camera.
  25804. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25805. */
  25806. viewport: Viewport;
  25807. /**
  25808. * Restricts the camera to viewing objects with the same layerMask.
  25809. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25810. */
  25811. layerMask: number;
  25812. /**
  25813. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25814. */
  25815. fovMode: number;
  25816. /**
  25817. * Rig mode of the camera.
  25818. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25819. * This is normally controlled byt the camera themselves as internal use.
  25820. */
  25821. cameraRigMode: number;
  25822. /**
  25823. * Defines the distance between both "eyes" in case of a RIG
  25824. */
  25825. interaxialDistance: number;
  25826. /**
  25827. * Defines if stereoscopic rendering is done side by side or over under.
  25828. */
  25829. isStereoscopicSideBySide: boolean;
  25830. /**
  25831. * 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
  25832. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25833. * else in the scene. (Eg. security camera)
  25834. *
  25835. * 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)
  25836. */
  25837. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25838. /**
  25839. * When set, the camera will render to this render target instead of the default canvas
  25840. *
  25841. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25842. */
  25843. outputRenderTarget: Nullable<RenderTargetTexture>;
  25844. /**
  25845. * Observable triggered when the camera view matrix has changed.
  25846. */
  25847. onViewMatrixChangedObservable: Observable<Camera>;
  25848. /**
  25849. * Observable triggered when the camera Projection matrix has changed.
  25850. */
  25851. onProjectionMatrixChangedObservable: Observable<Camera>;
  25852. /**
  25853. * Observable triggered when the inputs have been processed.
  25854. */
  25855. onAfterCheckInputsObservable: Observable<Camera>;
  25856. /**
  25857. * Observable triggered when reset has been called and applied to the camera.
  25858. */
  25859. onRestoreStateObservable: Observable<Camera>;
  25860. /** @hidden */
  25861. _cameraRigParams: any;
  25862. /** @hidden */
  25863. _rigCameras: Camera[];
  25864. /** @hidden */
  25865. _rigPostProcess: Nullable<PostProcess>;
  25866. protected _webvrViewMatrix: Matrix;
  25867. /** @hidden */
  25868. _skipRendering: boolean;
  25869. /** @hidden */
  25870. _projectionMatrix: Matrix;
  25871. /** @hidden */
  25872. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25873. /** @hidden */
  25874. _activeMeshes: SmartArray<AbstractMesh>;
  25875. protected _globalPosition: Vector3;
  25876. /** @hidden */
  25877. _computedViewMatrix: Matrix;
  25878. private _doNotComputeProjectionMatrix;
  25879. private _transformMatrix;
  25880. private _frustumPlanes;
  25881. private _refreshFrustumPlanes;
  25882. private _storedFov;
  25883. private _stateStored;
  25884. /**
  25885. * Instantiates a new camera object.
  25886. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25887. * @see http://doc.babylonjs.com/features/cameras
  25888. * @param name Defines the name of the camera in the scene
  25889. * @param position Defines the position of the camera
  25890. * @param scene Defines the scene the camera belongs too
  25891. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25892. */
  25893. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25894. /**
  25895. * Store current camera state (fov, position, etc..)
  25896. * @returns the camera
  25897. */
  25898. storeState(): Camera;
  25899. /**
  25900. * Restores the camera state values if it has been stored. You must call storeState() first
  25901. */
  25902. protected _restoreStateValues(): boolean;
  25903. /**
  25904. * Restored camera state. You must call storeState() first.
  25905. * @returns true if restored and false otherwise
  25906. */
  25907. restoreState(): boolean;
  25908. /**
  25909. * Gets the class name of the camera.
  25910. * @returns the class name
  25911. */
  25912. getClassName(): string;
  25913. /** @hidden */
  25914. readonly _isCamera: boolean;
  25915. /**
  25916. * Gets a string representation of the camera useful for debug purpose.
  25917. * @param fullDetails Defines that a more verboe level of logging is required
  25918. * @returns the string representation
  25919. */
  25920. toString(fullDetails?: boolean): string;
  25921. /**
  25922. * Gets the current world space position of the camera.
  25923. */
  25924. readonly globalPosition: Vector3;
  25925. /**
  25926. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25927. * @returns the active meshe list
  25928. */
  25929. getActiveMeshes(): SmartArray<AbstractMesh>;
  25930. /**
  25931. * Check wether a mesh is part of the current active mesh list of the camera
  25932. * @param mesh Defines the mesh to check
  25933. * @returns true if active, false otherwise
  25934. */
  25935. isActiveMesh(mesh: Mesh): boolean;
  25936. /**
  25937. * Is this camera ready to be used/rendered
  25938. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25939. * @return true if the camera is ready
  25940. */
  25941. isReady(completeCheck?: boolean): boolean;
  25942. /** @hidden */
  25943. _initCache(): void;
  25944. /** @hidden */
  25945. _updateCache(ignoreParentClass?: boolean): void;
  25946. /** @hidden */
  25947. _isSynchronized(): boolean;
  25948. /** @hidden */
  25949. _isSynchronizedViewMatrix(): boolean;
  25950. /** @hidden */
  25951. _isSynchronizedProjectionMatrix(): boolean;
  25952. /**
  25953. * Attach the input controls to a specific dom element to get the input from.
  25954. * @param element Defines the element the controls should be listened from
  25955. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25956. */
  25957. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25958. /**
  25959. * Detach the current controls from the specified dom element.
  25960. * @param element Defines the element to stop listening the inputs from
  25961. */
  25962. detachControl(element: HTMLElement): void;
  25963. /**
  25964. * Update the camera state according to the different inputs gathered during the frame.
  25965. */
  25966. update(): void;
  25967. /** @hidden */
  25968. _checkInputs(): void;
  25969. /** @hidden */
  25970. readonly rigCameras: Camera[];
  25971. /**
  25972. * Gets the post process used by the rig cameras
  25973. */
  25974. readonly rigPostProcess: Nullable<PostProcess>;
  25975. /**
  25976. * Internal, gets the first post proces.
  25977. * @returns the first post process to be run on this camera.
  25978. */
  25979. _getFirstPostProcess(): Nullable<PostProcess>;
  25980. private _cascadePostProcessesToRigCams;
  25981. /**
  25982. * Attach a post process to the camera.
  25983. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25984. * @param postProcess The post process to attach to the camera
  25985. * @param insertAt The position of the post process in case several of them are in use in the scene
  25986. * @returns the position the post process has been inserted at
  25987. */
  25988. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25989. /**
  25990. * Detach a post process to the camera.
  25991. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25992. * @param postProcess The post process to detach from the camera
  25993. */
  25994. detachPostProcess(postProcess: PostProcess): void;
  25995. /**
  25996. * Gets the current world matrix of the camera
  25997. */
  25998. getWorldMatrix(): Matrix;
  25999. /** @hidden */
  26000. _getViewMatrix(): Matrix;
  26001. /**
  26002. * Gets the current view matrix of the camera.
  26003. * @param force forces the camera to recompute the matrix without looking at the cached state
  26004. * @returns the view matrix
  26005. */
  26006. getViewMatrix(force?: boolean): Matrix;
  26007. /**
  26008. * Freeze the projection matrix.
  26009. * It will prevent the cache check of the camera projection compute and can speed up perf
  26010. * if no parameter of the camera are meant to change
  26011. * @param projection Defines manually a projection if necessary
  26012. */
  26013. freezeProjectionMatrix(projection?: Matrix): void;
  26014. /**
  26015. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26016. */
  26017. unfreezeProjectionMatrix(): void;
  26018. /**
  26019. * Gets the current projection matrix of the camera.
  26020. * @param force forces the camera to recompute the matrix without looking at the cached state
  26021. * @returns the projection matrix
  26022. */
  26023. getProjectionMatrix(force?: boolean): Matrix;
  26024. /**
  26025. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26026. * @returns a Matrix
  26027. */
  26028. getTransformationMatrix(): Matrix;
  26029. private _updateFrustumPlanes;
  26030. /**
  26031. * Checks if a cullable object (mesh...) is in the camera frustum
  26032. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26033. * @param target The object to check
  26034. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26035. * @returns true if the object is in frustum otherwise false
  26036. */
  26037. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26038. /**
  26039. * Checks if a cullable object (mesh...) is in the camera frustum
  26040. * Unlike isInFrustum this cheks the full bounding box
  26041. * @param target The object to check
  26042. * @returns true if the object is in frustum otherwise false
  26043. */
  26044. isCompletelyInFrustum(target: ICullable): boolean;
  26045. /**
  26046. * Gets a ray in the forward direction from the camera.
  26047. * @param length Defines the length of the ray to create
  26048. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26049. * @param origin Defines the start point of the ray which defaults to the camera position
  26050. * @returns the forward ray
  26051. */
  26052. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26053. /**
  26054. * Releases resources associated with this node.
  26055. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26056. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26057. */
  26058. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26059. /** @hidden */
  26060. _isLeftCamera: boolean;
  26061. /**
  26062. * Gets the left camera of a rig setup in case of Rigged Camera
  26063. */
  26064. readonly isLeftCamera: boolean;
  26065. /** @hidden */
  26066. _isRightCamera: boolean;
  26067. /**
  26068. * Gets the right camera of a rig setup in case of Rigged Camera
  26069. */
  26070. readonly isRightCamera: boolean;
  26071. /**
  26072. * Gets the left camera of a rig setup in case of Rigged Camera
  26073. */
  26074. readonly leftCamera: Nullable<FreeCamera>;
  26075. /**
  26076. * Gets the right camera of a rig setup in case of Rigged Camera
  26077. */
  26078. readonly rightCamera: Nullable<FreeCamera>;
  26079. /**
  26080. * Gets the left camera target of a rig setup in case of Rigged Camera
  26081. * @returns the target position
  26082. */
  26083. getLeftTarget(): Nullable<Vector3>;
  26084. /**
  26085. * Gets the right camera target of a rig setup in case of Rigged Camera
  26086. * @returns the target position
  26087. */
  26088. getRightTarget(): Nullable<Vector3>;
  26089. /**
  26090. * @hidden
  26091. */
  26092. setCameraRigMode(mode: number, rigParams: any): void;
  26093. /** @hidden */
  26094. static _setStereoscopicRigMode(camera: Camera): void;
  26095. /** @hidden */
  26096. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26097. /** @hidden */
  26098. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26099. /** @hidden */
  26100. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26101. /** @hidden */
  26102. _getVRProjectionMatrix(): Matrix;
  26103. protected _updateCameraRotationMatrix(): void;
  26104. protected _updateWebVRCameraRotationMatrix(): void;
  26105. /**
  26106. * This function MUST be overwritten by the different WebVR cameras available.
  26107. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26108. * @hidden
  26109. */
  26110. _getWebVRProjectionMatrix(): Matrix;
  26111. /**
  26112. * This function MUST be overwritten by the different WebVR cameras available.
  26113. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26114. * @hidden
  26115. */
  26116. _getWebVRViewMatrix(): Matrix;
  26117. /** @hidden */
  26118. setCameraRigParameter(name: string, value: any): void;
  26119. /**
  26120. * needs to be overridden by children so sub has required properties to be copied
  26121. * @hidden
  26122. */
  26123. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26124. /**
  26125. * May need to be overridden by children
  26126. * @hidden
  26127. */
  26128. _updateRigCameras(): void;
  26129. /** @hidden */
  26130. _setupInputs(): void;
  26131. /**
  26132. * Serialiaze the camera setup to a json represention
  26133. * @returns the JSON representation
  26134. */
  26135. serialize(): any;
  26136. /**
  26137. * Clones the current camera.
  26138. * @param name The cloned camera name
  26139. * @returns the cloned camera
  26140. */
  26141. clone(name: string): Camera;
  26142. /**
  26143. * Gets the direction of the camera relative to a given local axis.
  26144. * @param localAxis Defines the reference axis to provide a relative direction.
  26145. * @return the direction
  26146. */
  26147. getDirection(localAxis: Vector3): Vector3;
  26148. /**
  26149. * Returns the current camera absolute rotation
  26150. */
  26151. readonly absoluteRotation: Quaternion;
  26152. /**
  26153. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26154. * @param localAxis Defines the reference axis to provide a relative direction.
  26155. * @param result Defines the vector to store the result in
  26156. */
  26157. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26158. /**
  26159. * Gets a camera constructor for a given camera type
  26160. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26161. * @param name The name of the camera the result will be able to instantiate
  26162. * @param scene The scene the result will construct the camera in
  26163. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26164. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26165. * @returns a factory method to construc the camera
  26166. */
  26167. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26168. /**
  26169. * Compute the world matrix of the camera.
  26170. * @returns the camera world matrix
  26171. */
  26172. computeWorldMatrix(): Matrix;
  26173. /**
  26174. * Parse a JSON and creates the camera from the parsed information
  26175. * @param parsedCamera The JSON to parse
  26176. * @param scene The scene to instantiate the camera in
  26177. * @returns the newly constructed camera
  26178. */
  26179. static Parse(parsedCamera: any, scene: Scene): Camera;
  26180. }
  26181. }
  26182. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26183. import { Nullable } from "babylonjs/types";
  26184. import { Scene } from "babylonjs/scene";
  26185. import { Vector4 } from "babylonjs/Maths/math.vector";
  26186. import { Mesh } from "babylonjs/Meshes/mesh";
  26187. /**
  26188. * Class containing static functions to help procedurally build meshes
  26189. */
  26190. export class DiscBuilder {
  26191. /**
  26192. * Creates a plane polygonal mesh. By default, this is a disc
  26193. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26194. * * 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
  26195. * * 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
  26196. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26197. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26199. * @param name defines the name of the mesh
  26200. * @param options defines the options used to create the mesh
  26201. * @param scene defines the hosting scene
  26202. * @returns the plane polygonal mesh
  26203. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26204. */
  26205. static CreateDisc(name: string, options: {
  26206. radius?: number;
  26207. tessellation?: number;
  26208. arc?: number;
  26209. updatable?: boolean;
  26210. sideOrientation?: number;
  26211. frontUVs?: Vector4;
  26212. backUVs?: Vector4;
  26213. }, scene?: Nullable<Scene>): Mesh;
  26214. }
  26215. }
  26216. declare module "babylonjs/Particles/solidParticleSystem" {
  26217. import { Nullable } from "babylonjs/types";
  26218. import { Vector3 } from "babylonjs/Maths/math.vector";
  26219. import { Mesh } from "babylonjs/Meshes/mesh";
  26220. import { Scene, IDisposable } from "babylonjs/scene";
  26221. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  26222. /**
  26223. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26224. *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.
  26225. * The SPS is also a particle system. It provides some methods to manage the particles.
  26226. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26227. *
  26228. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26229. */
  26230. export class SolidParticleSystem implements IDisposable {
  26231. /**
  26232. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26233. * Example : var p = SPS.particles[i];
  26234. */
  26235. particles: SolidParticle[];
  26236. /**
  26237. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26238. */
  26239. nbParticles: number;
  26240. /**
  26241. * If the particles must ever face the camera (default false). Useful for planar particles.
  26242. */
  26243. billboard: boolean;
  26244. /**
  26245. * Recompute normals when adding a shape
  26246. */
  26247. recomputeNormals: boolean;
  26248. /**
  26249. * This a counter ofr your own usage. It's not set by any SPS functions.
  26250. */
  26251. counter: number;
  26252. /**
  26253. * The SPS name. This name is also given to the underlying mesh.
  26254. */
  26255. name: string;
  26256. /**
  26257. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26258. */
  26259. mesh: Mesh;
  26260. /**
  26261. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26262. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26263. */
  26264. vars: any;
  26265. /**
  26266. * This array is populated when the SPS is set as 'pickable'.
  26267. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26268. * Each element of this array is an object `{idx: int, faceId: int}`.
  26269. * `idx` is the picked particle index in the `SPS.particles` array
  26270. * `faceId` is the picked face index counted within this particle.
  26271. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26272. */
  26273. pickedParticles: {
  26274. idx: number;
  26275. faceId: number;
  26276. }[];
  26277. /**
  26278. * This array is populated when `enableDepthSort` is set to true.
  26279. * Each element of this array is an instance of the class DepthSortedParticle.
  26280. */
  26281. depthSortedParticles: DepthSortedParticle[];
  26282. /**
  26283. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26284. * @hidden
  26285. */
  26286. _bSphereOnly: boolean;
  26287. /**
  26288. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26289. * @hidden
  26290. */
  26291. _bSphereRadiusFactor: number;
  26292. private _scene;
  26293. private _positions;
  26294. private _indices;
  26295. private _normals;
  26296. private _colors;
  26297. private _uvs;
  26298. private _indices32;
  26299. private _positions32;
  26300. private _normals32;
  26301. private _fixedNormal32;
  26302. private _colors32;
  26303. private _uvs32;
  26304. private _index;
  26305. private _updatable;
  26306. private _pickable;
  26307. private _isVisibilityBoxLocked;
  26308. private _alwaysVisible;
  26309. private _depthSort;
  26310. private _expandable;
  26311. private _shapeCounter;
  26312. private _copy;
  26313. private _color;
  26314. private _computeParticleColor;
  26315. private _computeParticleTexture;
  26316. private _computeParticleRotation;
  26317. private _computeParticleVertex;
  26318. private _computeBoundingBox;
  26319. private _depthSortParticles;
  26320. private _camera;
  26321. private _mustUnrotateFixedNormals;
  26322. private _particlesIntersect;
  26323. private _needs32Bits;
  26324. private _isNotBuilt;
  26325. private _lastParticleId;
  26326. private _idxOfId;
  26327. /**
  26328. * Creates a SPS (Solid Particle System) object.
  26329. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26330. * @param scene (Scene) is the scene in which the SPS is added.
  26331. * @param options defines the options of the sps e.g.
  26332. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26333. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26334. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26335. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26336. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26337. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26338. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26339. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26340. */
  26341. constructor(name: string, scene: Scene, options?: {
  26342. updatable?: boolean;
  26343. isPickable?: boolean;
  26344. enableDepthSort?: boolean;
  26345. particleIntersection?: boolean;
  26346. boundingSphereOnly?: boolean;
  26347. bSphereRadiusFactor?: number;
  26348. expandable?: boolean;
  26349. });
  26350. /**
  26351. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26352. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26353. * @returns the created mesh
  26354. */
  26355. buildMesh(): Mesh;
  26356. /**
  26357. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26358. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26359. * Thus the particles generated from `digest()` have their property `position` set yet.
  26360. * @param mesh ( Mesh ) is the mesh to be digested
  26361. * @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
  26362. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26363. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26364. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26365. * @returns the current SPS
  26366. */
  26367. digest(mesh: Mesh, options?: {
  26368. facetNb?: number;
  26369. number?: number;
  26370. delta?: number;
  26371. storage?: [];
  26372. }): SolidParticleSystem;
  26373. /**
  26374. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26375. * @hidden
  26376. */
  26377. private _unrotateFixedNormals;
  26378. /**
  26379. * Resets the temporary working copy particle
  26380. * @hidden
  26381. */
  26382. private _resetCopy;
  26383. /**
  26384. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26385. * @param p the current index in the positions array to be updated
  26386. * @param shape a Vector3 array, the shape geometry
  26387. * @param positions the positions array to be updated
  26388. * @param meshInd the shape indices array
  26389. * @param indices the indices array to be updated
  26390. * @param meshUV the shape uv array
  26391. * @param uvs the uv array to be updated
  26392. * @param meshCol the shape color array
  26393. * @param colors the color array to be updated
  26394. * @param meshNor the shape normals array
  26395. * @param normals the normals array to be updated
  26396. * @param idx the particle index
  26397. * @param idxInShape the particle index in its shape
  26398. * @param options the addShape() method passed options
  26399. * @hidden
  26400. */
  26401. private _meshBuilder;
  26402. /**
  26403. * Returns a shape Vector3 array from positions float array
  26404. * @param positions float array
  26405. * @returns a vector3 array
  26406. * @hidden
  26407. */
  26408. private _posToShape;
  26409. /**
  26410. * Returns a shapeUV array from a float uvs (array deep copy)
  26411. * @param uvs as a float array
  26412. * @returns a shapeUV array
  26413. * @hidden
  26414. */
  26415. private _uvsToShapeUV;
  26416. /**
  26417. * Adds a new particle object in the particles array
  26418. * @param idx particle index in particles array
  26419. * @param id particle id
  26420. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26421. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26422. * @param model particle ModelShape object
  26423. * @param shapeId model shape identifier
  26424. * @param idxInShape index of the particle in the current model
  26425. * @param bInfo model bounding info object
  26426. * @param storage target storage array, if any
  26427. * @hidden
  26428. */
  26429. private _addParticle;
  26430. /**
  26431. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26432. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26433. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26434. * @param nb (positive integer) the number of particles to be created from this model
  26435. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26436. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26437. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26438. * @returns the number of shapes in the system
  26439. */
  26440. addShape(mesh: Mesh, nb: number, options?: {
  26441. positionFunction?: any;
  26442. vertexFunction?: any;
  26443. storage?: [];
  26444. }): number;
  26445. /**
  26446. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26447. * @hidden
  26448. */
  26449. private _rebuildParticle;
  26450. /**
  26451. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26452. * @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.
  26453. * @returns the SPS.
  26454. */
  26455. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26456. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26457. * Returns an array with the removed particles.
  26458. * 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.
  26459. * The SPS can't be empty so at least one particle needs to remain in place.
  26460. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26461. * @param start index of the first particle to remove
  26462. * @param end index of the last particle to remove (included)
  26463. * @returns an array populated with the removed particles
  26464. */
  26465. removeParticles(start: number, end: number): SolidParticle[];
  26466. /**
  26467. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26468. * @param solidParticleArray an array populated with Solid Particles objects
  26469. * @returns the SPS
  26470. */
  26471. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26472. /**
  26473. * Creates a new particle and modifies the SPS mesh geometry :
  26474. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26475. * - calls _addParticle() to populate the particle array
  26476. * factorized code from addShape() and insertParticlesFromArray()
  26477. * @param idx particle index in the particles array
  26478. * @param i particle index in its shape
  26479. * @param modelShape particle ModelShape object
  26480. * @param shape shape vertex array
  26481. * @param meshInd shape indices array
  26482. * @param meshUV shape uv array
  26483. * @param meshCol shape color array
  26484. * @param meshNor shape normals array
  26485. * @param bbInfo shape bounding info
  26486. * @param storage target particle storage
  26487. * @options addShape() passed options
  26488. * @hidden
  26489. */
  26490. private _insertNewParticle;
  26491. /**
  26492. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26493. * This method calls `updateParticle()` for each particle of the SPS.
  26494. * For an animated SPS, it is usually called within the render loop.
  26495. * 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.
  26496. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26497. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26498. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26499. * @returns the SPS.
  26500. */
  26501. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26502. /**
  26503. * Disposes the SPS.
  26504. */
  26505. dispose(): void;
  26506. /**
  26507. * Returns a SolidParticle object from its identifier : particle.id
  26508. * @param id (integer) the particle Id
  26509. * @returns the searched particle or null if not found in the SPS.
  26510. */
  26511. getParticleById(id: number): Nullable<SolidParticle>;
  26512. /**
  26513. * Returns a new array populated with the particles having the passed shapeId.
  26514. * @param shapeId (integer) the shape identifier
  26515. * @returns a new solid particle array
  26516. */
  26517. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26518. /**
  26519. * Populates the passed array "ref" with the particles having the passed shapeId.
  26520. * @param shapeId the shape identifier
  26521. * @returns the SPS
  26522. * @param ref
  26523. */
  26524. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26525. /**
  26526. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26527. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26528. * @returns the SPS.
  26529. */
  26530. refreshVisibleSize(): SolidParticleSystem;
  26531. /**
  26532. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26533. * @param size the size (float) of the visibility box
  26534. * note : this doesn't lock the SPS mesh bounding box.
  26535. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26536. */
  26537. setVisibilityBox(size: number): void;
  26538. /**
  26539. * Gets whether the SPS as always visible or not
  26540. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26541. */
  26542. /**
  26543. * Sets the SPS as always visible or not
  26544. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26545. */
  26546. isAlwaysVisible: boolean;
  26547. /**
  26548. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26549. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26550. */
  26551. /**
  26552. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26553. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26554. */
  26555. isVisibilityBoxLocked: boolean;
  26556. /**
  26557. * Tells to `setParticles()` to compute the particle rotations or not.
  26558. * Default value : true. The SPS is faster when it's set to false.
  26559. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26560. */
  26561. /**
  26562. * Gets if `setParticles()` computes the particle rotations or not.
  26563. * Default value : true. The SPS is faster when it's set to false.
  26564. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26565. */
  26566. computeParticleRotation: boolean;
  26567. /**
  26568. * Tells to `setParticles()` to compute the particle colors or not.
  26569. * Default value : true. The SPS is faster when it's set to false.
  26570. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26571. */
  26572. /**
  26573. * Gets if `setParticles()` computes the particle colors or not.
  26574. * Default value : true. The SPS is faster when it's set to false.
  26575. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26576. */
  26577. computeParticleColor: boolean;
  26578. /**
  26579. * Gets if `setParticles()` computes the particle textures or not.
  26580. * Default value : true. The SPS is faster when it's set to false.
  26581. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26582. */
  26583. computeParticleTexture: boolean;
  26584. /**
  26585. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26586. * Default value : false. The SPS is faster when it's set to false.
  26587. * Note : the particle custom vertex positions aren't stored values.
  26588. */
  26589. /**
  26590. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26591. * Default value : false. The SPS is faster when it's set to false.
  26592. * Note : the particle custom vertex positions aren't stored values.
  26593. */
  26594. computeParticleVertex: boolean;
  26595. /**
  26596. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26597. */
  26598. /**
  26599. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26600. */
  26601. computeBoundingBox: boolean;
  26602. /**
  26603. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26604. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26605. * Default : `true`
  26606. */
  26607. /**
  26608. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26609. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26610. * Default : `true`
  26611. */
  26612. depthSortParticles: boolean;
  26613. /**
  26614. * Gets if the SPS is created as expandable at construction time.
  26615. * Default : `false`
  26616. */
  26617. readonly expandable: boolean;
  26618. /**
  26619. * This function does nothing. It may be overwritten to set all the particle first values.
  26620. * The SPS doesn't call this function, you may have to call it by your own.
  26621. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26622. */
  26623. initParticles(): void;
  26624. /**
  26625. * This function does nothing. It may be overwritten to recycle a particle.
  26626. * The SPS doesn't call this function, you may have to call it by your own.
  26627. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26628. * @param particle The particle to recycle
  26629. * @returns the recycled particle
  26630. */
  26631. recycleParticle(particle: SolidParticle): SolidParticle;
  26632. /**
  26633. * Updates a particle : this function should be overwritten by the user.
  26634. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26635. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26636. * @example : just set a particle position or velocity and recycle conditions
  26637. * @param particle The particle to update
  26638. * @returns the updated particle
  26639. */
  26640. updateParticle(particle: SolidParticle): SolidParticle;
  26641. /**
  26642. * Updates a vertex of a particle : it can be overwritten by the user.
  26643. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26644. * @param particle the current particle
  26645. * @param vertex the current index of the current particle
  26646. * @param pt the index of the current vertex in the particle shape
  26647. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26648. * @example : just set a vertex particle position
  26649. * @returns the updated vertex
  26650. */
  26651. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26652. /**
  26653. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26654. * This does nothing and may be overwritten by the user.
  26655. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26656. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26657. * @param update the boolean update value actually passed to setParticles()
  26658. */
  26659. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26660. /**
  26661. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26662. * This will be passed three parameters.
  26663. * This does nothing and may be overwritten by the user.
  26664. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26665. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26666. * @param update the boolean update value actually passed to setParticles()
  26667. */
  26668. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26669. }
  26670. }
  26671. declare module "babylonjs/Particles/solidParticle" {
  26672. import { Nullable } from "babylonjs/types";
  26673. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26674. import { Color4 } from "babylonjs/Maths/math.color";
  26675. import { Mesh } from "babylonjs/Meshes/mesh";
  26676. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26677. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26678. import { Plane } from "babylonjs/Maths/math.plane";
  26679. /**
  26680. * Represents one particle of a solid particle system.
  26681. */
  26682. export class SolidParticle {
  26683. /**
  26684. * particle global index
  26685. */
  26686. idx: number;
  26687. /**
  26688. * particle identifier
  26689. */
  26690. id: number;
  26691. /**
  26692. * The color of the particle
  26693. */
  26694. color: Nullable<Color4>;
  26695. /**
  26696. * The world space position of the particle.
  26697. */
  26698. position: Vector3;
  26699. /**
  26700. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26701. */
  26702. rotation: Vector3;
  26703. /**
  26704. * The world space rotation quaternion of the particle.
  26705. */
  26706. rotationQuaternion: Nullable<Quaternion>;
  26707. /**
  26708. * The scaling of the particle.
  26709. */
  26710. scaling: Vector3;
  26711. /**
  26712. * The uvs of the particle.
  26713. */
  26714. uvs: Vector4;
  26715. /**
  26716. * The current speed of the particle.
  26717. */
  26718. velocity: Vector3;
  26719. /**
  26720. * The pivot point in the particle local space.
  26721. */
  26722. pivot: Vector3;
  26723. /**
  26724. * Must the particle be translated from its pivot point in its local space ?
  26725. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26726. * Default : false
  26727. */
  26728. translateFromPivot: boolean;
  26729. /**
  26730. * Is the particle active or not ?
  26731. */
  26732. alive: boolean;
  26733. /**
  26734. * Is the particle visible or not ?
  26735. */
  26736. isVisible: boolean;
  26737. /**
  26738. * Index of this particle in the global "positions" array (Internal use)
  26739. * @hidden
  26740. */
  26741. _pos: number;
  26742. /**
  26743. * @hidden Index of this particle in the global "indices" array (Internal use)
  26744. */
  26745. _ind: number;
  26746. /**
  26747. * @hidden ModelShape of this particle (Internal use)
  26748. */
  26749. _model: ModelShape;
  26750. /**
  26751. * ModelShape id of this particle
  26752. */
  26753. shapeId: number;
  26754. /**
  26755. * Index of the particle in its shape id
  26756. */
  26757. idxInShape: number;
  26758. /**
  26759. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26760. */
  26761. _modelBoundingInfo: BoundingInfo;
  26762. /**
  26763. * @hidden Particle BoundingInfo object (Internal use)
  26764. */
  26765. _boundingInfo: BoundingInfo;
  26766. /**
  26767. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26768. */
  26769. _sps: SolidParticleSystem;
  26770. /**
  26771. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26772. */
  26773. _stillInvisible: boolean;
  26774. /**
  26775. * @hidden Last computed particle rotation matrix
  26776. */
  26777. _rotationMatrix: number[];
  26778. /**
  26779. * Parent particle Id, if any.
  26780. * Default null.
  26781. */
  26782. parentId: Nullable<number>;
  26783. /**
  26784. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26785. * The possible values are :
  26786. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26787. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26788. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26789. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26790. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26791. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26792. * */
  26793. cullingStrategy: number;
  26794. /**
  26795. * @hidden Internal global position in the SPS.
  26796. */
  26797. _globalPosition: Vector3;
  26798. /**
  26799. * Creates a Solid Particle object.
  26800. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26801. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  26802. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  26803. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26804. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26805. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26806. * @param shapeId (integer) is the model shape identifier in the SPS.
  26807. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26808. * @param sps defines the sps it is associated to
  26809. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26810. */
  26811. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26812. /**
  26813. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  26814. * @param target the particle target
  26815. * @returns the current particle
  26816. */
  26817. copyToRef(target: SolidParticle): SolidParticle;
  26818. /**
  26819. * Legacy support, changed scale to scaling
  26820. */
  26821. /**
  26822. * Legacy support, changed scale to scaling
  26823. */
  26824. scale: Vector3;
  26825. /**
  26826. * Legacy support, changed quaternion to rotationQuaternion
  26827. */
  26828. /**
  26829. * Legacy support, changed quaternion to rotationQuaternion
  26830. */
  26831. quaternion: Nullable<Quaternion>;
  26832. /**
  26833. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26834. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26835. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26836. * @returns true if it intersects
  26837. */
  26838. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26839. /**
  26840. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26841. * A particle is in the frustum if its bounding box intersects the frustum
  26842. * @param frustumPlanes defines the frustum to test
  26843. * @returns true if the particle is in the frustum planes
  26844. */
  26845. isInFrustum(frustumPlanes: Plane[]): boolean;
  26846. /**
  26847. * get the rotation matrix of the particle
  26848. * @hidden
  26849. */
  26850. getRotationMatrix(m: Matrix): void;
  26851. }
  26852. /**
  26853. * Represents the shape of the model used by one particle of a solid particle system.
  26854. * SPS internal tool, don't use it manually.
  26855. */
  26856. export class ModelShape {
  26857. /**
  26858. * The shape id
  26859. * @hidden
  26860. */
  26861. shapeID: number;
  26862. /**
  26863. * flat array of model positions (internal use)
  26864. * @hidden
  26865. */
  26866. _shape: Vector3[];
  26867. /**
  26868. * flat array of model UVs (internal use)
  26869. * @hidden
  26870. */
  26871. _shapeUV: number[];
  26872. /**
  26873. * color array of the model
  26874. * @hidden
  26875. */
  26876. _shapeColors: number[];
  26877. /**
  26878. * indices array of the model
  26879. * @hidden
  26880. */
  26881. _indices: number[];
  26882. /**
  26883. * normals array of the model
  26884. * @hidden
  26885. */
  26886. _normals: number[];
  26887. /**
  26888. * length of the shape in the model indices array (internal use)
  26889. * @hidden
  26890. */
  26891. _indicesLength: number;
  26892. /**
  26893. * Custom position function (internal use)
  26894. * @hidden
  26895. */
  26896. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26897. /**
  26898. * Custom vertex function (internal use)
  26899. * @hidden
  26900. */
  26901. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26902. /**
  26903. * 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.
  26904. * SPS internal tool, don't use it manually.
  26905. * @hidden
  26906. */
  26907. 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>);
  26908. }
  26909. /**
  26910. * Represents a Depth Sorted Particle in the solid particle system.
  26911. */
  26912. export class DepthSortedParticle {
  26913. /**
  26914. * Index of the particle in the "indices" array
  26915. */
  26916. ind: number;
  26917. /**
  26918. * Length of the particle shape in the "indices" array
  26919. */
  26920. indicesLength: number;
  26921. /**
  26922. * Squared distance from the particle to the camera
  26923. */
  26924. sqDistance: number;
  26925. }
  26926. }
  26927. declare module "babylonjs/Collisions/meshCollisionData" {
  26928. import { Collider } from "babylonjs/Collisions/collider";
  26929. import { Vector3 } from "babylonjs/Maths/math.vector";
  26930. import { Nullable } from "babylonjs/types";
  26931. import { Observer } from "babylonjs/Misc/observable";
  26932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26933. /**
  26934. * @hidden
  26935. */
  26936. export class _MeshCollisionData {
  26937. _checkCollisions: boolean;
  26938. _collisionMask: number;
  26939. _collisionGroup: number;
  26940. _collider: Nullable<Collider>;
  26941. _oldPositionForCollisions: Vector3;
  26942. _diffPositionForCollisions: Vector3;
  26943. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26944. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26945. }
  26946. }
  26947. declare module "babylonjs/Meshes/abstractMesh" {
  26948. import { Observable } from "babylonjs/Misc/observable";
  26949. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26950. import { Camera } from "babylonjs/Cameras/camera";
  26951. import { Scene, IDisposable } from "babylonjs/scene";
  26952. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26953. import { Node } from "babylonjs/node";
  26954. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26955. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26956. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26957. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26958. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26959. import { Material } from "babylonjs/Materials/material";
  26960. import { Light } from "babylonjs/Lights/light";
  26961. import { Skeleton } from "babylonjs/Bones/skeleton";
  26962. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26963. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26964. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26965. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26966. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26967. import { Plane } from "babylonjs/Maths/math.plane";
  26968. import { Ray } from "babylonjs/Culling/ray";
  26969. import { Collider } from "babylonjs/Collisions/collider";
  26970. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26971. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26972. /** @hidden */
  26973. class _FacetDataStorage {
  26974. facetPositions: Vector3[];
  26975. facetNormals: Vector3[];
  26976. facetPartitioning: number[][];
  26977. facetNb: number;
  26978. partitioningSubdivisions: number;
  26979. partitioningBBoxRatio: number;
  26980. facetDataEnabled: boolean;
  26981. facetParameters: any;
  26982. bbSize: Vector3;
  26983. subDiv: {
  26984. max: number;
  26985. X: number;
  26986. Y: number;
  26987. Z: number;
  26988. };
  26989. facetDepthSort: boolean;
  26990. facetDepthSortEnabled: boolean;
  26991. depthSortedIndices: IndicesArray;
  26992. depthSortedFacets: {
  26993. ind: number;
  26994. sqDistance: number;
  26995. }[];
  26996. facetDepthSortFunction: (f1: {
  26997. ind: number;
  26998. sqDistance: number;
  26999. }, f2: {
  27000. ind: number;
  27001. sqDistance: number;
  27002. }) => number;
  27003. facetDepthSortFrom: Vector3;
  27004. facetDepthSortOrigin: Vector3;
  27005. invertedMatrix: Matrix;
  27006. }
  27007. /**
  27008. * @hidden
  27009. **/
  27010. class _InternalAbstractMeshDataInfo {
  27011. _hasVertexAlpha: boolean;
  27012. _useVertexColors: boolean;
  27013. _numBoneInfluencers: number;
  27014. _applyFog: boolean;
  27015. _receiveShadows: boolean;
  27016. _facetData: _FacetDataStorage;
  27017. _visibility: number;
  27018. _skeleton: Nullable<Skeleton>;
  27019. _layerMask: number;
  27020. _computeBonesUsingShaders: boolean;
  27021. _isActive: boolean;
  27022. _onlyForInstances: boolean;
  27023. _isActiveIntermediate: boolean;
  27024. _onlyForInstancesIntermediate: boolean;
  27025. _actAsRegularMesh: boolean;
  27026. }
  27027. /**
  27028. * Class used to store all common mesh properties
  27029. */
  27030. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27031. /** No occlusion */
  27032. static OCCLUSION_TYPE_NONE: number;
  27033. /** Occlusion set to optimisitic */
  27034. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27035. /** Occlusion set to strict */
  27036. static OCCLUSION_TYPE_STRICT: number;
  27037. /** Use an accurante occlusion algorithm */
  27038. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27039. /** Use a conservative occlusion algorithm */
  27040. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27041. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27042. * Test order :
  27043. * Is the bounding sphere outside the frustum ?
  27044. * If not, are the bounding box vertices outside the frustum ?
  27045. * It not, then the cullable object is in the frustum.
  27046. */
  27047. static readonly CULLINGSTRATEGY_STANDARD: number;
  27048. /** Culling strategy : Bounding Sphere Only.
  27049. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27050. * It's also less accurate than the standard because some not visible objects can still be selected.
  27051. * Test : is the bounding sphere outside the frustum ?
  27052. * If not, then the cullable object is in the frustum.
  27053. */
  27054. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27055. /** Culling strategy : Optimistic Inclusion.
  27056. * This in an inclusion test first, then the standard exclusion test.
  27057. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27058. * 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.
  27059. * Anyway, it's as accurate as the standard strategy.
  27060. * Test :
  27061. * Is the cullable object bounding sphere center in the frustum ?
  27062. * If not, apply the default culling strategy.
  27063. */
  27064. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27065. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27066. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27067. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27068. * 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.
  27069. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27070. * Test :
  27071. * Is the cullable object bounding sphere center in the frustum ?
  27072. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27073. */
  27074. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27075. /**
  27076. * No billboard
  27077. */
  27078. static readonly BILLBOARDMODE_NONE: number;
  27079. /** Billboard on X axis */
  27080. static readonly BILLBOARDMODE_X: number;
  27081. /** Billboard on Y axis */
  27082. static readonly BILLBOARDMODE_Y: number;
  27083. /** Billboard on Z axis */
  27084. static readonly BILLBOARDMODE_Z: number;
  27085. /** Billboard on all axes */
  27086. static readonly BILLBOARDMODE_ALL: number;
  27087. /** Billboard on using position instead of orientation */
  27088. static readonly BILLBOARDMODE_USE_POSITION: number;
  27089. /** @hidden */
  27090. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27091. /**
  27092. * The culling strategy to use to check whether the mesh must be rendered or not.
  27093. * This value can be changed at any time and will be used on the next render mesh selection.
  27094. * The possible values are :
  27095. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27096. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27097. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27098. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27099. * Please read each static variable documentation to get details about the culling process.
  27100. * */
  27101. cullingStrategy: number;
  27102. /**
  27103. * Gets the number of facets in the mesh
  27104. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27105. */
  27106. readonly facetNb: number;
  27107. /**
  27108. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27109. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27110. */
  27111. partitioningSubdivisions: number;
  27112. /**
  27113. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27114. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27115. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27116. */
  27117. partitioningBBoxRatio: number;
  27118. /**
  27119. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27120. * Works only for updatable meshes.
  27121. * Doesn't work with multi-materials
  27122. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27123. */
  27124. mustDepthSortFacets: boolean;
  27125. /**
  27126. * The location (Vector3) where the facet depth sort must be computed from.
  27127. * By default, the active camera position.
  27128. * Used only when facet depth sort is enabled
  27129. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27130. */
  27131. facetDepthSortFrom: Vector3;
  27132. /**
  27133. * gets a boolean indicating if facetData is enabled
  27134. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27135. */
  27136. readonly isFacetDataEnabled: boolean;
  27137. /** @hidden */
  27138. _updateNonUniformScalingState(value: boolean): boolean;
  27139. /**
  27140. * An event triggered when this mesh collides with another one
  27141. */
  27142. onCollideObservable: Observable<AbstractMesh>;
  27143. /** Set a function to call when this mesh collides with another one */
  27144. onCollide: () => void;
  27145. /**
  27146. * An event triggered when the collision's position changes
  27147. */
  27148. onCollisionPositionChangeObservable: Observable<Vector3>;
  27149. /** Set a function to call when the collision's position changes */
  27150. onCollisionPositionChange: () => void;
  27151. /**
  27152. * An event triggered when material is changed
  27153. */
  27154. onMaterialChangedObservable: Observable<AbstractMesh>;
  27155. /**
  27156. * Gets or sets the orientation for POV movement & rotation
  27157. */
  27158. definedFacingForward: boolean;
  27159. /** @hidden */
  27160. _occlusionQuery: Nullable<WebGLQuery>;
  27161. /** @hidden */
  27162. _renderingGroup: Nullable<RenderingGroup>;
  27163. /**
  27164. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27165. */
  27166. /**
  27167. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27168. */
  27169. visibility: number;
  27170. /** Gets or sets the alpha index used to sort transparent meshes
  27171. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27172. */
  27173. alphaIndex: number;
  27174. /**
  27175. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27176. */
  27177. isVisible: boolean;
  27178. /**
  27179. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27180. */
  27181. isPickable: boolean;
  27182. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27183. showSubMeshesBoundingBox: boolean;
  27184. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27185. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27186. */
  27187. isBlocker: boolean;
  27188. /**
  27189. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27190. */
  27191. enablePointerMoveEvents: boolean;
  27192. /**
  27193. * Specifies the rendering group id for this mesh (0 by default)
  27194. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27195. */
  27196. renderingGroupId: number;
  27197. private _material;
  27198. /** Gets or sets current material */
  27199. material: Nullable<Material>;
  27200. /**
  27201. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27202. * @see http://doc.babylonjs.com/babylon101/shadows
  27203. */
  27204. receiveShadows: boolean;
  27205. /** Defines color to use when rendering outline */
  27206. outlineColor: Color3;
  27207. /** Define width to use when rendering outline */
  27208. outlineWidth: number;
  27209. /** Defines color to use when rendering overlay */
  27210. overlayColor: Color3;
  27211. /** Defines alpha to use when rendering overlay */
  27212. overlayAlpha: number;
  27213. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27214. hasVertexAlpha: boolean;
  27215. /** 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) */
  27216. useVertexColors: boolean;
  27217. /**
  27218. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27219. */
  27220. computeBonesUsingShaders: boolean;
  27221. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27222. numBoneInfluencers: number;
  27223. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27224. applyFog: boolean;
  27225. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27226. useOctreeForRenderingSelection: boolean;
  27227. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27228. useOctreeForPicking: boolean;
  27229. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27230. useOctreeForCollisions: boolean;
  27231. /**
  27232. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27233. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27234. */
  27235. layerMask: number;
  27236. /**
  27237. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27238. */
  27239. alwaysSelectAsActiveMesh: boolean;
  27240. /**
  27241. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27242. */
  27243. doNotSyncBoundingInfo: boolean;
  27244. /**
  27245. * Gets or sets the current action manager
  27246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27247. */
  27248. actionManager: Nullable<AbstractActionManager>;
  27249. private _meshCollisionData;
  27250. /**
  27251. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27252. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27253. */
  27254. ellipsoid: Vector3;
  27255. /**
  27256. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27257. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27258. */
  27259. ellipsoidOffset: Vector3;
  27260. /**
  27261. * Gets or sets a collision mask used to mask collisions (default is -1).
  27262. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27263. */
  27264. collisionMask: number;
  27265. /**
  27266. * Gets or sets the current collision group mask (-1 by default).
  27267. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27268. */
  27269. collisionGroup: number;
  27270. /**
  27271. * Defines edge width used when edgesRenderer is enabled
  27272. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27273. */
  27274. edgesWidth: number;
  27275. /**
  27276. * Defines edge color used when edgesRenderer is enabled
  27277. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27278. */
  27279. edgesColor: Color4;
  27280. /** @hidden */
  27281. _edgesRenderer: Nullable<IEdgesRenderer>;
  27282. /** @hidden */
  27283. _masterMesh: Nullable<AbstractMesh>;
  27284. /** @hidden */
  27285. _boundingInfo: Nullable<BoundingInfo>;
  27286. /** @hidden */
  27287. _renderId: number;
  27288. /**
  27289. * Gets or sets the list of subMeshes
  27290. * @see http://doc.babylonjs.com/how_to/multi_materials
  27291. */
  27292. subMeshes: SubMesh[];
  27293. /** @hidden */
  27294. _intersectionsInProgress: AbstractMesh[];
  27295. /** @hidden */
  27296. _unIndexed: boolean;
  27297. /** @hidden */
  27298. _lightSources: Light[];
  27299. /** Gets the list of lights affecting that mesh */
  27300. readonly lightSources: Light[];
  27301. /** @hidden */
  27302. readonly _positions: Nullable<Vector3[]>;
  27303. /** @hidden */
  27304. _waitingData: {
  27305. lods: Nullable<any>;
  27306. actions: Nullable<any>;
  27307. freezeWorldMatrix: Nullable<boolean>;
  27308. };
  27309. /** @hidden */
  27310. _bonesTransformMatrices: Nullable<Float32Array>;
  27311. /** @hidden */
  27312. _transformMatrixTexture: Nullable<RawTexture>;
  27313. /**
  27314. * Gets or sets a skeleton to apply skining transformations
  27315. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27316. */
  27317. skeleton: Nullable<Skeleton>;
  27318. /**
  27319. * An event triggered when the mesh is rebuilt.
  27320. */
  27321. onRebuildObservable: Observable<AbstractMesh>;
  27322. /**
  27323. * Creates a new AbstractMesh
  27324. * @param name defines the name of the mesh
  27325. * @param scene defines the hosting scene
  27326. */
  27327. constructor(name: string, scene?: Nullable<Scene>);
  27328. /**
  27329. * Returns the string "AbstractMesh"
  27330. * @returns "AbstractMesh"
  27331. */
  27332. getClassName(): string;
  27333. /**
  27334. * Gets a string representation of the current mesh
  27335. * @param fullDetails defines a boolean indicating if full details must be included
  27336. * @returns a string representation of the current mesh
  27337. */
  27338. toString(fullDetails?: boolean): string;
  27339. /**
  27340. * @hidden
  27341. */
  27342. protected _getEffectiveParent(): Nullable<Node>;
  27343. /** @hidden */
  27344. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27345. /** @hidden */
  27346. _rebuild(): void;
  27347. /** @hidden */
  27348. _resyncLightSources(): void;
  27349. /** @hidden */
  27350. _resyncLighSource(light: Light): void;
  27351. /** @hidden */
  27352. _unBindEffect(): void;
  27353. /** @hidden */
  27354. _removeLightSource(light: Light, dispose: boolean): void;
  27355. private _markSubMeshesAsDirty;
  27356. /** @hidden */
  27357. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27358. /** @hidden */
  27359. _markSubMeshesAsAttributesDirty(): void;
  27360. /** @hidden */
  27361. _markSubMeshesAsMiscDirty(): void;
  27362. /**
  27363. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27364. */
  27365. scaling: Vector3;
  27366. /**
  27367. * Returns true if the mesh is blocked. Implemented by child classes
  27368. */
  27369. readonly isBlocked: boolean;
  27370. /**
  27371. * Returns the mesh itself by default. Implemented by child classes
  27372. * @param camera defines the camera to use to pick the right LOD level
  27373. * @returns the currentAbstractMesh
  27374. */
  27375. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27376. /**
  27377. * Returns 0 by default. Implemented by child classes
  27378. * @returns an integer
  27379. */
  27380. getTotalVertices(): number;
  27381. /**
  27382. * Returns a positive integer : the total number of indices in this mesh geometry.
  27383. * @returns the numner of indices or zero if the mesh has no geometry.
  27384. */
  27385. getTotalIndices(): number;
  27386. /**
  27387. * Returns null by default. Implemented by child classes
  27388. * @returns null
  27389. */
  27390. getIndices(): Nullable<IndicesArray>;
  27391. /**
  27392. * Returns the array of the requested vertex data kind. Implemented by child classes
  27393. * @param kind defines the vertex data kind to use
  27394. * @returns null
  27395. */
  27396. getVerticesData(kind: string): Nullable<FloatArray>;
  27397. /**
  27398. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27399. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27400. * Note that a new underlying VertexBuffer object is created each call.
  27401. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27402. * @param kind defines vertex data kind:
  27403. * * VertexBuffer.PositionKind
  27404. * * VertexBuffer.UVKind
  27405. * * VertexBuffer.UV2Kind
  27406. * * VertexBuffer.UV3Kind
  27407. * * VertexBuffer.UV4Kind
  27408. * * VertexBuffer.UV5Kind
  27409. * * VertexBuffer.UV6Kind
  27410. * * VertexBuffer.ColorKind
  27411. * * VertexBuffer.MatricesIndicesKind
  27412. * * VertexBuffer.MatricesIndicesExtraKind
  27413. * * VertexBuffer.MatricesWeightsKind
  27414. * * VertexBuffer.MatricesWeightsExtraKind
  27415. * @param data defines the data source
  27416. * @param updatable defines if the data must be flagged as updatable (or static)
  27417. * @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
  27418. * @returns the current mesh
  27419. */
  27420. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27421. /**
  27422. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27423. * If the mesh has no geometry, it is simply returned as it is.
  27424. * @param kind defines vertex data kind:
  27425. * * VertexBuffer.PositionKind
  27426. * * VertexBuffer.UVKind
  27427. * * VertexBuffer.UV2Kind
  27428. * * VertexBuffer.UV3Kind
  27429. * * VertexBuffer.UV4Kind
  27430. * * VertexBuffer.UV5Kind
  27431. * * VertexBuffer.UV6Kind
  27432. * * VertexBuffer.ColorKind
  27433. * * VertexBuffer.MatricesIndicesKind
  27434. * * VertexBuffer.MatricesIndicesExtraKind
  27435. * * VertexBuffer.MatricesWeightsKind
  27436. * * VertexBuffer.MatricesWeightsExtraKind
  27437. * @param data defines the data source
  27438. * @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
  27439. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27440. * @returns the current mesh
  27441. */
  27442. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27443. /**
  27444. * Sets the mesh indices,
  27445. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27446. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27447. * @param totalVertices Defines the total number of vertices
  27448. * @returns the current mesh
  27449. */
  27450. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27451. /**
  27452. * Gets a boolean indicating if specific vertex data is present
  27453. * @param kind defines the vertex data kind to use
  27454. * @returns true is data kind is present
  27455. */
  27456. isVerticesDataPresent(kind: string): boolean;
  27457. /**
  27458. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27459. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27460. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27461. * @returns a BoundingInfo
  27462. */
  27463. getBoundingInfo(): BoundingInfo;
  27464. /**
  27465. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27466. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27467. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27468. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27469. * @returns the current mesh
  27470. */
  27471. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27472. /**
  27473. * Overwrite the current bounding info
  27474. * @param boundingInfo defines the new bounding info
  27475. * @returns the current mesh
  27476. */
  27477. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27478. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27479. readonly useBones: boolean;
  27480. /** @hidden */
  27481. _preActivate(): void;
  27482. /** @hidden */
  27483. _preActivateForIntermediateRendering(renderId: number): void;
  27484. /** @hidden */
  27485. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27486. /** @hidden */
  27487. _postActivate(): void;
  27488. /** @hidden */
  27489. _freeze(): void;
  27490. /** @hidden */
  27491. _unFreeze(): void;
  27492. /**
  27493. * Gets the current world matrix
  27494. * @returns a Matrix
  27495. */
  27496. getWorldMatrix(): Matrix;
  27497. /** @hidden */
  27498. _getWorldMatrixDeterminant(): number;
  27499. /**
  27500. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27501. */
  27502. readonly isAnInstance: boolean;
  27503. /**
  27504. * Gets a boolean indicating if this mesh has instances
  27505. */
  27506. readonly hasInstances: boolean;
  27507. /**
  27508. * Perform relative position change from the point of view of behind the front of the mesh.
  27509. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27510. * Supports definition of mesh facing forward or backward
  27511. * @param amountRight defines the distance on the right axis
  27512. * @param amountUp defines the distance on the up axis
  27513. * @param amountForward defines the distance on the forward axis
  27514. * @returns the current mesh
  27515. */
  27516. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27517. /**
  27518. * Calculate relative position change from the point of view of behind the front of the mesh.
  27519. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27520. * Supports definition of mesh facing forward or backward
  27521. * @param amountRight defines the distance on the right axis
  27522. * @param amountUp defines the distance on the up axis
  27523. * @param amountForward defines the distance on the forward axis
  27524. * @returns the new displacement vector
  27525. */
  27526. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27527. /**
  27528. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27529. * Supports definition of mesh facing forward or backward
  27530. * @param flipBack defines the flip
  27531. * @param twirlClockwise defines the twirl
  27532. * @param tiltRight defines the tilt
  27533. * @returns the current mesh
  27534. */
  27535. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27536. /**
  27537. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27538. * Supports definition of mesh facing forward or backward.
  27539. * @param flipBack defines the flip
  27540. * @param twirlClockwise defines the twirl
  27541. * @param tiltRight defines the tilt
  27542. * @returns the new rotation vector
  27543. */
  27544. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27545. /**
  27546. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27547. * This means the mesh underlying bounding box and sphere are recomputed.
  27548. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27549. * @returns the current mesh
  27550. */
  27551. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27552. /** @hidden */
  27553. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27554. /** @hidden */
  27555. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27556. /** @hidden */
  27557. _updateBoundingInfo(): AbstractMesh;
  27558. /** @hidden */
  27559. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27560. /** @hidden */
  27561. protected _afterComputeWorldMatrix(): void;
  27562. /** @hidden */
  27563. readonly _effectiveMesh: AbstractMesh;
  27564. /**
  27565. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27566. * A mesh is in the frustum if its bounding box intersects the frustum
  27567. * @param frustumPlanes defines the frustum to test
  27568. * @returns true if the mesh is in the frustum planes
  27569. */
  27570. isInFrustum(frustumPlanes: Plane[]): boolean;
  27571. /**
  27572. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27573. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27574. * @param frustumPlanes defines the frustum to test
  27575. * @returns true if the mesh is completely in the frustum planes
  27576. */
  27577. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27578. /**
  27579. * True if the mesh intersects another mesh or a SolidParticle object
  27580. * @param mesh defines a target mesh or SolidParticle to test
  27581. * @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)
  27582. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27583. * @returns true if there is an intersection
  27584. */
  27585. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27586. /**
  27587. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27588. * @param point defines the point to test
  27589. * @returns true if there is an intersection
  27590. */
  27591. intersectsPoint(point: Vector3): boolean;
  27592. /**
  27593. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27594. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27595. */
  27596. checkCollisions: boolean;
  27597. /**
  27598. * Gets Collider object used to compute collisions (not physics)
  27599. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27600. */
  27601. readonly collider: Nullable<Collider>;
  27602. /**
  27603. * Move the mesh using collision engine
  27604. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27605. * @param displacement defines the requested displacement vector
  27606. * @returns the current mesh
  27607. */
  27608. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27609. private _onCollisionPositionChange;
  27610. /** @hidden */
  27611. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27612. /** @hidden */
  27613. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27614. /** @hidden */
  27615. _checkCollision(collider: Collider): AbstractMesh;
  27616. /** @hidden */
  27617. _generatePointsArray(): boolean;
  27618. /**
  27619. * Checks if the passed Ray intersects with the mesh
  27620. * @param ray defines the ray to use
  27621. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27622. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27623. * @returns the picking info
  27624. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27625. */
  27626. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27627. /**
  27628. * Clones the current mesh
  27629. * @param name defines the mesh name
  27630. * @param newParent defines the new mesh parent
  27631. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27632. * @returns the new mesh
  27633. */
  27634. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27635. /**
  27636. * Disposes all the submeshes of the current meshnp
  27637. * @returns the current mesh
  27638. */
  27639. releaseSubMeshes(): AbstractMesh;
  27640. /**
  27641. * Releases resources associated with this abstract mesh.
  27642. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27643. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27644. */
  27645. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27646. /**
  27647. * Adds the passed mesh as a child to the current mesh
  27648. * @param mesh defines the child mesh
  27649. * @returns the current mesh
  27650. */
  27651. addChild(mesh: AbstractMesh): AbstractMesh;
  27652. /**
  27653. * Removes the passed mesh from the current mesh children list
  27654. * @param mesh defines the child mesh
  27655. * @returns the current mesh
  27656. */
  27657. removeChild(mesh: AbstractMesh): AbstractMesh;
  27658. /** @hidden */
  27659. private _initFacetData;
  27660. /**
  27661. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27662. * This method can be called within the render loop.
  27663. * 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
  27664. * @returns the current mesh
  27665. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27666. */
  27667. updateFacetData(): AbstractMesh;
  27668. /**
  27669. * Returns the facetLocalNormals array.
  27670. * The normals are expressed in the mesh local spac
  27671. * @returns an array of Vector3
  27672. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27673. */
  27674. getFacetLocalNormals(): Vector3[];
  27675. /**
  27676. * Returns the facetLocalPositions array.
  27677. * The facet positions are expressed in the mesh local space
  27678. * @returns an array of Vector3
  27679. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27680. */
  27681. getFacetLocalPositions(): Vector3[];
  27682. /**
  27683. * Returns the facetLocalPartioning array
  27684. * @returns an array of array of numbers
  27685. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27686. */
  27687. getFacetLocalPartitioning(): number[][];
  27688. /**
  27689. * Returns the i-th facet position in the world system.
  27690. * This method allocates a new Vector3 per call
  27691. * @param i defines the facet index
  27692. * @returns a new Vector3
  27693. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27694. */
  27695. getFacetPosition(i: number): Vector3;
  27696. /**
  27697. * Sets the reference Vector3 with the i-th facet position in the world system
  27698. * @param i defines the facet index
  27699. * @param ref defines the target vector
  27700. * @returns the current mesh
  27701. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27702. */
  27703. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27704. /**
  27705. * Returns the i-th facet normal in the world system.
  27706. * This method allocates a new Vector3 per call
  27707. * @param i defines the facet index
  27708. * @returns a new Vector3
  27709. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27710. */
  27711. getFacetNormal(i: number): Vector3;
  27712. /**
  27713. * Sets the reference Vector3 with the i-th facet normal in the world system
  27714. * @param i defines the facet index
  27715. * @param ref defines the target vector
  27716. * @returns the current mesh
  27717. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27718. */
  27719. getFacetNormalToRef(i: number, ref: Vector3): this;
  27720. /**
  27721. * 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)
  27722. * @param x defines x coordinate
  27723. * @param y defines y coordinate
  27724. * @param z defines z coordinate
  27725. * @returns the array of facet indexes
  27726. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27727. */
  27728. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27729. /**
  27730. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27731. * @param projected sets as the (x,y,z) world projection on the facet
  27732. * @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
  27733. * @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
  27734. * @param x defines x coordinate
  27735. * @param y defines y coordinate
  27736. * @param z defines z coordinate
  27737. * @returns the face index if found (or null instead)
  27738. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27739. */
  27740. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27741. /**
  27742. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27743. * @param projected sets as the (x,y,z) local projection on the facet
  27744. * @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
  27745. * @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
  27746. * @param x defines x coordinate
  27747. * @param y defines y coordinate
  27748. * @param z defines z coordinate
  27749. * @returns the face index if found (or null instead)
  27750. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27751. */
  27752. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27753. /**
  27754. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27755. * @returns the parameters
  27756. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27757. */
  27758. getFacetDataParameters(): any;
  27759. /**
  27760. * Disables the feature FacetData and frees the related memory
  27761. * @returns the current mesh
  27762. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27763. */
  27764. disableFacetData(): AbstractMesh;
  27765. /**
  27766. * Updates the AbstractMesh indices array
  27767. * @param indices defines the data source
  27768. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27769. * @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)
  27770. * @returns the current mesh
  27771. */
  27772. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27773. /**
  27774. * Creates new normals data for the mesh
  27775. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27776. * @returns the current mesh
  27777. */
  27778. createNormals(updatable: boolean): AbstractMesh;
  27779. /**
  27780. * Align the mesh with a normal
  27781. * @param normal defines the normal to use
  27782. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27783. * @returns the current mesh
  27784. */
  27785. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27786. /** @hidden */
  27787. _checkOcclusionQuery(): boolean;
  27788. /**
  27789. * Disables the mesh edge rendering mode
  27790. * @returns the currentAbstractMesh
  27791. */
  27792. disableEdgesRendering(): AbstractMesh;
  27793. /**
  27794. * Enables the edge rendering mode on the mesh.
  27795. * This mode makes the mesh edges visible
  27796. * @param epsilon defines the maximal distance between two angles to detect a face
  27797. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27798. * @returns the currentAbstractMesh
  27799. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27800. */
  27801. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27802. }
  27803. }
  27804. declare module "babylonjs/Actions/actionEvent" {
  27805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27806. import { Nullable } from "babylonjs/types";
  27807. import { Sprite } from "babylonjs/Sprites/sprite";
  27808. import { Scene } from "babylonjs/scene";
  27809. import { Vector2 } from "babylonjs/Maths/math.vector";
  27810. /**
  27811. * Interface used to define ActionEvent
  27812. */
  27813. export interface IActionEvent {
  27814. /** The mesh or sprite that triggered the action */
  27815. source: any;
  27816. /** The X mouse cursor position at the time of the event */
  27817. pointerX: number;
  27818. /** The Y mouse cursor position at the time of the event */
  27819. pointerY: number;
  27820. /** The mesh that is currently pointed at (can be null) */
  27821. meshUnderPointer: Nullable<AbstractMesh>;
  27822. /** the original (browser) event that triggered the ActionEvent */
  27823. sourceEvent?: any;
  27824. /** additional data for the event */
  27825. additionalData?: any;
  27826. }
  27827. /**
  27828. * ActionEvent is the event being sent when an action is triggered.
  27829. */
  27830. export class ActionEvent implements IActionEvent {
  27831. /** The mesh or sprite that triggered the action */
  27832. source: any;
  27833. /** The X mouse cursor position at the time of the event */
  27834. pointerX: number;
  27835. /** The Y mouse cursor position at the time of the event */
  27836. pointerY: number;
  27837. /** The mesh that is currently pointed at (can be null) */
  27838. meshUnderPointer: Nullable<AbstractMesh>;
  27839. /** the original (browser) event that triggered the ActionEvent */
  27840. sourceEvent?: any;
  27841. /** additional data for the event */
  27842. additionalData?: any;
  27843. /**
  27844. * Creates a new ActionEvent
  27845. * @param source The mesh or sprite that triggered the action
  27846. * @param pointerX The X mouse cursor position at the time of the event
  27847. * @param pointerY The Y mouse cursor position at the time of the event
  27848. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27849. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27850. * @param additionalData additional data for the event
  27851. */
  27852. constructor(
  27853. /** The mesh or sprite that triggered the action */
  27854. source: any,
  27855. /** The X mouse cursor position at the time of the event */
  27856. pointerX: number,
  27857. /** The Y mouse cursor position at the time of the event */
  27858. pointerY: number,
  27859. /** The mesh that is currently pointed at (can be null) */
  27860. meshUnderPointer: Nullable<AbstractMesh>,
  27861. /** the original (browser) event that triggered the ActionEvent */
  27862. sourceEvent?: any,
  27863. /** additional data for the event */
  27864. additionalData?: any);
  27865. /**
  27866. * Helper function to auto-create an ActionEvent from a source mesh.
  27867. * @param source The source mesh that triggered the event
  27868. * @param evt The original (browser) event
  27869. * @param additionalData additional data for the event
  27870. * @returns the new ActionEvent
  27871. */
  27872. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27873. /**
  27874. * Helper function to auto-create an ActionEvent from a source sprite
  27875. * @param source The source sprite that triggered the event
  27876. * @param scene Scene associated with the sprite
  27877. * @param evt The original (browser) event
  27878. * @param additionalData additional data for the event
  27879. * @returns the new ActionEvent
  27880. */
  27881. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27882. /**
  27883. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27884. * @param scene the scene where the event occurred
  27885. * @param evt The original (browser) event
  27886. * @returns the new ActionEvent
  27887. */
  27888. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27889. /**
  27890. * Helper function to auto-create an ActionEvent from a primitive
  27891. * @param prim defines the target primitive
  27892. * @param pointerPos defines the pointer position
  27893. * @param evt The original (browser) event
  27894. * @param additionalData additional data for the event
  27895. * @returns the new ActionEvent
  27896. */
  27897. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27898. }
  27899. }
  27900. declare module "babylonjs/Actions/abstractActionManager" {
  27901. import { IDisposable } from "babylonjs/scene";
  27902. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27903. import { IAction } from "babylonjs/Actions/action";
  27904. import { Nullable } from "babylonjs/types";
  27905. /**
  27906. * Abstract class used to decouple action Manager from scene and meshes.
  27907. * Do not instantiate.
  27908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27909. */
  27910. export abstract class AbstractActionManager implements IDisposable {
  27911. /** Gets the list of active triggers */
  27912. static Triggers: {
  27913. [key: string]: number;
  27914. };
  27915. /** Gets the cursor to use when hovering items */
  27916. hoverCursor: string;
  27917. /** Gets the list of actions */
  27918. actions: IAction[];
  27919. /**
  27920. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27921. */
  27922. isRecursive: boolean;
  27923. /**
  27924. * Releases all associated resources
  27925. */
  27926. abstract dispose(): void;
  27927. /**
  27928. * Does this action manager has pointer triggers
  27929. */
  27930. abstract readonly hasPointerTriggers: boolean;
  27931. /**
  27932. * Does this action manager has pick triggers
  27933. */
  27934. abstract readonly hasPickTriggers: boolean;
  27935. /**
  27936. * Process a specific trigger
  27937. * @param trigger defines the trigger to process
  27938. * @param evt defines the event details to be processed
  27939. */
  27940. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27941. /**
  27942. * Does this action manager handles actions of any of the given triggers
  27943. * @param triggers defines the triggers to be tested
  27944. * @return a boolean indicating whether one (or more) of the triggers is handled
  27945. */
  27946. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27947. /**
  27948. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27949. * speed.
  27950. * @param triggerA defines the trigger to be tested
  27951. * @param triggerB defines the trigger to be tested
  27952. * @return a boolean indicating whether one (or more) of the triggers is handled
  27953. */
  27954. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27955. /**
  27956. * Does this action manager handles actions of a given trigger
  27957. * @param trigger defines the trigger to be tested
  27958. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27959. * @return whether the trigger is handled
  27960. */
  27961. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27962. /**
  27963. * Serialize this manager to a JSON object
  27964. * @param name defines the property name to store this manager
  27965. * @returns a JSON representation of this manager
  27966. */
  27967. abstract serialize(name: string): any;
  27968. /**
  27969. * Registers an action to this action manager
  27970. * @param action defines the action to be registered
  27971. * @return the action amended (prepared) after registration
  27972. */
  27973. abstract registerAction(action: IAction): Nullable<IAction>;
  27974. /**
  27975. * Unregisters an action to this action manager
  27976. * @param action defines the action to be unregistered
  27977. * @return a boolean indicating whether the action has been unregistered
  27978. */
  27979. abstract unregisterAction(action: IAction): Boolean;
  27980. /**
  27981. * Does exist one action manager with at least one trigger
  27982. **/
  27983. static readonly HasTriggers: boolean;
  27984. /**
  27985. * Does exist one action manager with at least one pick trigger
  27986. **/
  27987. static readonly HasPickTriggers: boolean;
  27988. /**
  27989. * Does exist one action manager that handles actions of a given trigger
  27990. * @param trigger defines the trigger to be tested
  27991. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27992. **/
  27993. static HasSpecificTrigger(trigger: number): boolean;
  27994. }
  27995. }
  27996. declare module "babylonjs/node" {
  27997. import { Scene } from "babylonjs/scene";
  27998. import { Nullable } from "babylonjs/types";
  27999. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  28000. import { Engine } from "babylonjs/Engines/engine";
  28001. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  28002. import { Observable } from "babylonjs/Misc/observable";
  28003. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28004. import { IInspectable } from "babylonjs/Misc/iInspectable";
  28005. import { Animatable } from "babylonjs/Animations/animatable";
  28006. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  28007. import { Animation } from "babylonjs/Animations/animation";
  28008. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28010. /**
  28011. * Defines how a node can be built from a string name.
  28012. */
  28013. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28014. /**
  28015. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28016. */
  28017. export class Node implements IBehaviorAware<Node> {
  28018. /** @hidden */
  28019. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  28020. private static _NodeConstructors;
  28021. /**
  28022. * Add a new node constructor
  28023. * @param type defines the type name of the node to construct
  28024. * @param constructorFunc defines the constructor function
  28025. */
  28026. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28027. /**
  28028. * Returns a node constructor based on type name
  28029. * @param type defines the type name
  28030. * @param name defines the new node name
  28031. * @param scene defines the hosting scene
  28032. * @param options defines optional options to transmit to constructors
  28033. * @returns the new constructor or null
  28034. */
  28035. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28036. /**
  28037. * Gets or sets the name of the node
  28038. */
  28039. name: string;
  28040. /**
  28041. * Gets or sets the id of the node
  28042. */
  28043. id: string;
  28044. /**
  28045. * Gets or sets the unique id of the node
  28046. */
  28047. uniqueId: number;
  28048. /**
  28049. * Gets or sets a string used to store user defined state for the node
  28050. */
  28051. state: string;
  28052. /**
  28053. * Gets or sets an object used to store user defined information for the node
  28054. */
  28055. metadata: any;
  28056. /**
  28057. * For internal use only. Please do not use.
  28058. */
  28059. reservedDataStore: any;
  28060. /**
  28061. * List of inspectable custom properties (used by the Inspector)
  28062. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28063. */
  28064. inspectableCustomProperties: IInspectable[];
  28065. private _doNotSerialize;
  28066. /**
  28067. * Gets or sets a boolean used to define if the node must be serialized
  28068. */
  28069. doNotSerialize: boolean;
  28070. /** @hidden */
  28071. _isDisposed: boolean;
  28072. /**
  28073. * Gets a list of Animations associated with the node
  28074. */
  28075. animations: import("babylonjs/Animations/animation").Animation[];
  28076. protected _ranges: {
  28077. [name: string]: Nullable<AnimationRange>;
  28078. };
  28079. /**
  28080. * Callback raised when the node is ready to be used
  28081. */
  28082. onReady: Nullable<(node: Node) => void>;
  28083. private _isEnabled;
  28084. private _isParentEnabled;
  28085. private _isReady;
  28086. /** @hidden */
  28087. _currentRenderId: number;
  28088. private _parentUpdateId;
  28089. /** @hidden */
  28090. _childUpdateId: number;
  28091. /** @hidden */
  28092. _waitingParentId: Nullable<string>;
  28093. /** @hidden */
  28094. _scene: Scene;
  28095. /** @hidden */
  28096. _cache: any;
  28097. private _parentNode;
  28098. private _children;
  28099. /** @hidden */
  28100. _worldMatrix: Matrix;
  28101. /** @hidden */
  28102. _worldMatrixDeterminant: number;
  28103. /** @hidden */
  28104. _worldMatrixDeterminantIsDirty: boolean;
  28105. /** @hidden */
  28106. private _sceneRootNodesIndex;
  28107. /**
  28108. * Gets a boolean indicating if the node has been disposed
  28109. * @returns true if the node was disposed
  28110. */
  28111. isDisposed(): boolean;
  28112. /**
  28113. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28114. * @see https://doc.babylonjs.com/how_to/parenting
  28115. */
  28116. parent: Nullable<Node>;
  28117. /** @hidden */
  28118. _addToSceneRootNodes(): void;
  28119. /** @hidden */
  28120. _removeFromSceneRootNodes(): void;
  28121. private _animationPropertiesOverride;
  28122. /**
  28123. * Gets or sets the animation properties override
  28124. */
  28125. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  28126. /**
  28127. * Gets a string idenfifying the name of the class
  28128. * @returns "Node" string
  28129. */
  28130. getClassName(): string;
  28131. /** @hidden */
  28132. readonly _isNode: boolean;
  28133. /**
  28134. * An event triggered when the mesh is disposed
  28135. */
  28136. onDisposeObservable: Observable<Node>;
  28137. private _onDisposeObserver;
  28138. /**
  28139. * Sets a callback that will be raised when the node will be disposed
  28140. */
  28141. onDispose: () => void;
  28142. /**
  28143. * Creates a new Node
  28144. * @param name the name and id to be given to this node
  28145. * @param scene the scene this node will be added to
  28146. */
  28147. constructor(name: string, scene?: Nullable<Scene>);
  28148. /**
  28149. * Gets the scene of the node
  28150. * @returns a scene
  28151. */
  28152. getScene(): Scene;
  28153. /**
  28154. * Gets the engine of the node
  28155. * @returns a Engine
  28156. */
  28157. getEngine(): Engine;
  28158. private _behaviors;
  28159. /**
  28160. * Attach a behavior to the node
  28161. * @see http://doc.babylonjs.com/features/behaviour
  28162. * @param behavior defines the behavior to attach
  28163. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28164. * @returns the current Node
  28165. */
  28166. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28167. /**
  28168. * Remove an attached behavior
  28169. * @see http://doc.babylonjs.com/features/behaviour
  28170. * @param behavior defines the behavior to attach
  28171. * @returns the current Node
  28172. */
  28173. removeBehavior(behavior: Behavior<Node>): Node;
  28174. /**
  28175. * Gets the list of attached behaviors
  28176. * @see http://doc.babylonjs.com/features/behaviour
  28177. */
  28178. readonly behaviors: Behavior<Node>[];
  28179. /**
  28180. * Gets an attached behavior by name
  28181. * @param name defines the name of the behavior to look for
  28182. * @see http://doc.babylonjs.com/features/behaviour
  28183. * @returns null if behavior was not found else the requested behavior
  28184. */
  28185. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28186. /**
  28187. * Returns the latest update of the World matrix
  28188. * @returns a Matrix
  28189. */
  28190. getWorldMatrix(): Matrix;
  28191. /** @hidden */
  28192. _getWorldMatrixDeterminant(): number;
  28193. /**
  28194. * Returns directly the latest state of the mesh World matrix.
  28195. * A Matrix is returned.
  28196. */
  28197. readonly worldMatrixFromCache: Matrix;
  28198. /** @hidden */
  28199. _initCache(): void;
  28200. /** @hidden */
  28201. updateCache(force?: boolean): void;
  28202. /** @hidden */
  28203. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28204. /** @hidden */
  28205. _updateCache(ignoreParentClass?: boolean): void;
  28206. /** @hidden */
  28207. _isSynchronized(): boolean;
  28208. /** @hidden */
  28209. _markSyncedWithParent(): void;
  28210. /** @hidden */
  28211. isSynchronizedWithParent(): boolean;
  28212. /** @hidden */
  28213. isSynchronized(): boolean;
  28214. /**
  28215. * Is this node ready to be used/rendered
  28216. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28217. * @return true if the node is ready
  28218. */
  28219. isReady(completeCheck?: boolean): boolean;
  28220. /**
  28221. * Is this node enabled?
  28222. * 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
  28223. * @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
  28224. * @return whether this node (and its parent) is enabled
  28225. */
  28226. isEnabled(checkAncestors?: boolean): boolean;
  28227. /** @hidden */
  28228. protected _syncParentEnabledState(): void;
  28229. /**
  28230. * Set the enabled state of this node
  28231. * @param value defines the new enabled state
  28232. */
  28233. setEnabled(value: boolean): void;
  28234. /**
  28235. * Is this node a descendant of the given node?
  28236. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28237. * @param ancestor defines the parent node to inspect
  28238. * @returns a boolean indicating if this node is a descendant of the given node
  28239. */
  28240. isDescendantOf(ancestor: Node): boolean;
  28241. /** @hidden */
  28242. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28243. /**
  28244. * Will return all nodes that have this node as ascendant
  28245. * @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
  28246. * @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
  28247. * @return all children nodes of all types
  28248. */
  28249. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28250. /**
  28251. * Get all child-meshes of this node
  28252. * @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)
  28253. * @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
  28254. * @returns an array of AbstractMesh
  28255. */
  28256. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28257. /**
  28258. * Get all direct children of this node
  28259. * @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
  28260. * @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)
  28261. * @returns an array of Node
  28262. */
  28263. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28264. /** @hidden */
  28265. _setReady(state: boolean): void;
  28266. /**
  28267. * Get an animation by name
  28268. * @param name defines the name of the animation to look for
  28269. * @returns null if not found else the requested animation
  28270. */
  28271. getAnimationByName(name: string): Nullable<Animation>;
  28272. /**
  28273. * Creates an animation range for this node
  28274. * @param name defines the name of the range
  28275. * @param from defines the starting key
  28276. * @param to defines the end key
  28277. */
  28278. createAnimationRange(name: string, from: number, to: number): void;
  28279. /**
  28280. * Delete a specific animation range
  28281. * @param name defines the name of the range to delete
  28282. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28283. */
  28284. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28285. /**
  28286. * Get an animation range by name
  28287. * @param name defines the name of the animation range to look for
  28288. * @returns null if not found else the requested animation range
  28289. */
  28290. getAnimationRange(name: string): Nullable<AnimationRange>;
  28291. /**
  28292. * Gets the list of all animation ranges defined on this node
  28293. * @returns an array
  28294. */
  28295. getAnimationRanges(): Nullable<AnimationRange>[];
  28296. /**
  28297. * Will start the animation sequence
  28298. * @param name defines the range frames for animation sequence
  28299. * @param loop defines if the animation should loop (false by default)
  28300. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28301. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28302. * @returns the object created for this animation. If range does not exist, it will return null
  28303. */
  28304. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28305. /**
  28306. * Serialize animation ranges into a JSON compatible object
  28307. * @returns serialization object
  28308. */
  28309. serializeAnimationRanges(): any;
  28310. /**
  28311. * Computes the world matrix of the node
  28312. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28313. * @returns the world matrix
  28314. */
  28315. computeWorldMatrix(force?: boolean): Matrix;
  28316. /**
  28317. * Releases resources associated with this node.
  28318. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28319. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28320. */
  28321. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28322. /**
  28323. * Parse animation range data from a serialization object and store them into a given node
  28324. * @param node defines where to store the animation ranges
  28325. * @param parsedNode defines the serialization object to read data from
  28326. * @param scene defines the hosting scene
  28327. */
  28328. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28329. /**
  28330. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28331. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28332. * @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
  28333. * @returns the new bounding vectors
  28334. */
  28335. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28336. min: Vector3;
  28337. max: Vector3;
  28338. };
  28339. }
  28340. }
  28341. declare module "babylonjs/Animations/animation" {
  28342. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  28343. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  28344. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28345. import { Nullable } from "babylonjs/types";
  28346. import { Scene } from "babylonjs/scene";
  28347. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  28348. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28349. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  28350. import { Node } from "babylonjs/node";
  28351. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28352. import { Size } from "babylonjs/Maths/math.size";
  28353. import { Animatable } from "babylonjs/Animations/animatable";
  28354. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  28355. /**
  28356. * @hidden
  28357. */
  28358. export class _IAnimationState {
  28359. key: number;
  28360. repeatCount: number;
  28361. workValue?: any;
  28362. loopMode?: number;
  28363. offsetValue?: any;
  28364. highLimitValue?: any;
  28365. }
  28366. /**
  28367. * Class used to store any kind of animation
  28368. */
  28369. export class Animation {
  28370. /**Name of the animation */
  28371. name: string;
  28372. /**Property to animate */
  28373. targetProperty: string;
  28374. /**The frames per second of the animation */
  28375. framePerSecond: number;
  28376. /**The data type of the animation */
  28377. dataType: number;
  28378. /**The loop mode of the animation */
  28379. loopMode?: number | undefined;
  28380. /**Specifies if blending should be enabled */
  28381. enableBlending?: boolean | undefined;
  28382. /**
  28383. * Use matrix interpolation instead of using direct key value when animating matrices
  28384. */
  28385. static AllowMatricesInterpolation: boolean;
  28386. /**
  28387. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28388. */
  28389. static AllowMatrixDecomposeForInterpolation: boolean;
  28390. /**
  28391. * Stores the key frames of the animation
  28392. */
  28393. private _keys;
  28394. /**
  28395. * Stores the easing function of the animation
  28396. */
  28397. private _easingFunction;
  28398. /**
  28399. * @hidden Internal use only
  28400. */
  28401. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28402. /**
  28403. * The set of event that will be linked to this animation
  28404. */
  28405. private _events;
  28406. /**
  28407. * Stores an array of target property paths
  28408. */
  28409. targetPropertyPath: string[];
  28410. /**
  28411. * Stores the blending speed of the animation
  28412. */
  28413. blendingSpeed: number;
  28414. /**
  28415. * Stores the animation ranges for the animation
  28416. */
  28417. private _ranges;
  28418. /**
  28419. * @hidden Internal use
  28420. */
  28421. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28422. /**
  28423. * Sets up an animation
  28424. * @param property The property to animate
  28425. * @param animationType The animation type to apply
  28426. * @param framePerSecond The frames per second of the animation
  28427. * @param easingFunction The easing function used in the animation
  28428. * @returns The created animation
  28429. */
  28430. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28431. /**
  28432. * Create and start an animation on a node
  28433. * @param name defines the name of the global animation that will be run on all nodes
  28434. * @param node defines the root node where the animation will take place
  28435. * @param targetProperty defines property to animate
  28436. * @param framePerSecond defines the number of frame per second yo use
  28437. * @param totalFrame defines the number of frames in total
  28438. * @param from defines the initial value
  28439. * @param to defines the final value
  28440. * @param loopMode defines which loop mode you want to use (off by default)
  28441. * @param easingFunction defines the easing function to use (linear by default)
  28442. * @param onAnimationEnd defines the callback to call when animation end
  28443. * @returns the animatable created for this animation
  28444. */
  28445. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28446. /**
  28447. * Create and start an animation on a node and its descendants
  28448. * @param name defines the name of the global animation that will be run on all nodes
  28449. * @param node defines the root node where the animation will take place
  28450. * @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
  28451. * @param targetProperty defines property to animate
  28452. * @param framePerSecond defines the number of frame per second to use
  28453. * @param totalFrame defines the number of frames in total
  28454. * @param from defines the initial value
  28455. * @param to defines the final value
  28456. * @param loopMode defines which loop mode you want to use (off by default)
  28457. * @param easingFunction defines the easing function to use (linear by default)
  28458. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28459. * @returns the list of animatables created for all nodes
  28460. * @example https://www.babylonjs-playground.com/#MH0VLI
  28461. */
  28462. 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[]>;
  28463. /**
  28464. * Creates a new animation, merges it with the existing animations and starts it
  28465. * @param name Name of the animation
  28466. * @param node Node which contains the scene that begins the animations
  28467. * @param targetProperty Specifies which property to animate
  28468. * @param framePerSecond The frames per second of the animation
  28469. * @param totalFrame The total number of frames
  28470. * @param from The frame at the beginning of the animation
  28471. * @param to The frame at the end of the animation
  28472. * @param loopMode Specifies the loop mode of the animation
  28473. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28474. * @param onAnimationEnd Callback to run once the animation is complete
  28475. * @returns Nullable animation
  28476. */
  28477. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28478. /**
  28479. * Transition property of an host to the target Value
  28480. * @param property The property to transition
  28481. * @param targetValue The target Value of the property
  28482. * @param host The object where the property to animate belongs
  28483. * @param scene Scene used to run the animation
  28484. * @param frameRate Framerate (in frame/s) to use
  28485. * @param transition The transition type we want to use
  28486. * @param duration The duration of the animation, in milliseconds
  28487. * @param onAnimationEnd Callback trigger at the end of the animation
  28488. * @returns Nullable animation
  28489. */
  28490. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28491. /**
  28492. * Return the array of runtime animations currently using this animation
  28493. */
  28494. readonly runtimeAnimations: RuntimeAnimation[];
  28495. /**
  28496. * Specifies if any of the runtime animations are currently running
  28497. */
  28498. readonly hasRunningRuntimeAnimations: boolean;
  28499. /**
  28500. * Initializes the animation
  28501. * @param name Name of the animation
  28502. * @param targetProperty Property to animate
  28503. * @param framePerSecond The frames per second of the animation
  28504. * @param dataType The data type of the animation
  28505. * @param loopMode The loop mode of the animation
  28506. * @param enableBlending Specifies if blending should be enabled
  28507. */
  28508. constructor(
  28509. /**Name of the animation */
  28510. name: string,
  28511. /**Property to animate */
  28512. targetProperty: string,
  28513. /**The frames per second of the animation */
  28514. framePerSecond: number,
  28515. /**The data type of the animation */
  28516. dataType: number,
  28517. /**The loop mode of the animation */
  28518. loopMode?: number | undefined,
  28519. /**Specifies if blending should be enabled */
  28520. enableBlending?: boolean | undefined);
  28521. /**
  28522. * Converts the animation to a string
  28523. * @param fullDetails support for multiple levels of logging within scene loading
  28524. * @returns String form of the animation
  28525. */
  28526. toString(fullDetails?: boolean): string;
  28527. /**
  28528. * Add an event to this animation
  28529. * @param event Event to add
  28530. */
  28531. addEvent(event: AnimationEvent): void;
  28532. /**
  28533. * Remove all events found at the given frame
  28534. * @param frame The frame to remove events from
  28535. */
  28536. removeEvents(frame: number): void;
  28537. /**
  28538. * Retrieves all the events from the animation
  28539. * @returns Events from the animation
  28540. */
  28541. getEvents(): AnimationEvent[];
  28542. /**
  28543. * Creates an animation range
  28544. * @param name Name of the animation range
  28545. * @param from Starting frame of the animation range
  28546. * @param to Ending frame of the animation
  28547. */
  28548. createRange(name: string, from: number, to: number): void;
  28549. /**
  28550. * Deletes an animation range by name
  28551. * @param name Name of the animation range to delete
  28552. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28553. */
  28554. deleteRange(name: string, deleteFrames?: boolean): void;
  28555. /**
  28556. * Gets the animation range by name, or null if not defined
  28557. * @param name Name of the animation range
  28558. * @returns Nullable animation range
  28559. */
  28560. getRange(name: string): Nullable<AnimationRange>;
  28561. /**
  28562. * Gets the key frames from the animation
  28563. * @returns The key frames of the animation
  28564. */
  28565. getKeys(): Array<IAnimationKey>;
  28566. /**
  28567. * Gets the highest frame rate of the animation
  28568. * @returns Highest frame rate of the animation
  28569. */
  28570. getHighestFrame(): number;
  28571. /**
  28572. * Gets the easing function of the animation
  28573. * @returns Easing function of the animation
  28574. */
  28575. getEasingFunction(): IEasingFunction;
  28576. /**
  28577. * Sets the easing function of the animation
  28578. * @param easingFunction A custom mathematical formula for animation
  28579. */
  28580. setEasingFunction(easingFunction: EasingFunction): void;
  28581. /**
  28582. * Interpolates a scalar linearly
  28583. * @param startValue Start value of the animation curve
  28584. * @param endValue End value of the animation curve
  28585. * @param gradient Scalar amount to interpolate
  28586. * @returns Interpolated scalar value
  28587. */
  28588. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28589. /**
  28590. * Interpolates a scalar cubically
  28591. * @param startValue Start value of the animation curve
  28592. * @param outTangent End tangent of the animation
  28593. * @param endValue End value of the animation curve
  28594. * @param inTangent Start tangent of the animation curve
  28595. * @param gradient Scalar amount to interpolate
  28596. * @returns Interpolated scalar value
  28597. */
  28598. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28599. /**
  28600. * Interpolates a quaternion using a spherical linear interpolation
  28601. * @param startValue Start value of the animation curve
  28602. * @param endValue End value of the animation curve
  28603. * @param gradient Scalar amount to interpolate
  28604. * @returns Interpolated quaternion value
  28605. */
  28606. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28607. /**
  28608. * Interpolates a quaternion cubically
  28609. * @param startValue Start value of the animation curve
  28610. * @param outTangent End tangent of the animation curve
  28611. * @param endValue End value of the animation curve
  28612. * @param inTangent Start tangent of the animation curve
  28613. * @param gradient Scalar amount to interpolate
  28614. * @returns Interpolated quaternion value
  28615. */
  28616. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28617. /**
  28618. * Interpolates a Vector3 linearl
  28619. * @param startValue Start value of the animation curve
  28620. * @param endValue End value of the animation curve
  28621. * @param gradient Scalar amount to interpolate
  28622. * @returns Interpolated scalar value
  28623. */
  28624. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28625. /**
  28626. * Interpolates a Vector3 cubically
  28627. * @param startValue Start value of the animation curve
  28628. * @param outTangent End tangent of the animation
  28629. * @param endValue End value of the animation curve
  28630. * @param inTangent Start tangent of the animation curve
  28631. * @param gradient Scalar amount to interpolate
  28632. * @returns InterpolatedVector3 value
  28633. */
  28634. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28635. /**
  28636. * Interpolates a Vector2 linearly
  28637. * @param startValue Start value of the animation curve
  28638. * @param endValue End value of the animation curve
  28639. * @param gradient Scalar amount to interpolate
  28640. * @returns Interpolated Vector2 value
  28641. */
  28642. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28643. /**
  28644. * Interpolates a Vector2 cubically
  28645. * @param startValue Start value of the animation curve
  28646. * @param outTangent End tangent of the animation
  28647. * @param endValue End value of the animation curve
  28648. * @param inTangent Start tangent of the animation curve
  28649. * @param gradient Scalar amount to interpolate
  28650. * @returns Interpolated Vector2 value
  28651. */
  28652. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28653. /**
  28654. * Interpolates a size linearly
  28655. * @param startValue Start value of the animation curve
  28656. * @param endValue End value of the animation curve
  28657. * @param gradient Scalar amount to interpolate
  28658. * @returns Interpolated Size value
  28659. */
  28660. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28661. /**
  28662. * Interpolates a Color3 linearly
  28663. * @param startValue Start value of the animation curve
  28664. * @param endValue End value of the animation curve
  28665. * @param gradient Scalar amount to interpolate
  28666. * @returns Interpolated Color3 value
  28667. */
  28668. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28669. /**
  28670. * Interpolates a Color4 linearly
  28671. * @param startValue Start value of the animation curve
  28672. * @param endValue End value of the animation curve
  28673. * @param gradient Scalar amount to interpolate
  28674. * @returns Interpolated Color3 value
  28675. */
  28676. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28677. /**
  28678. * @hidden Internal use only
  28679. */
  28680. _getKeyValue(value: any): any;
  28681. /**
  28682. * @hidden Internal use only
  28683. */
  28684. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28685. /**
  28686. * Defines the function to use to interpolate matrices
  28687. * @param startValue defines the start matrix
  28688. * @param endValue defines the end matrix
  28689. * @param gradient defines the gradient between both matrices
  28690. * @param result defines an optional target matrix where to store the interpolation
  28691. * @returns the interpolated matrix
  28692. */
  28693. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28694. /**
  28695. * Makes a copy of the animation
  28696. * @returns Cloned animation
  28697. */
  28698. clone(): Animation;
  28699. /**
  28700. * Sets the key frames of the animation
  28701. * @param values The animation key frames to set
  28702. */
  28703. setKeys(values: Array<IAnimationKey>): void;
  28704. /**
  28705. * Serializes the animation to an object
  28706. * @returns Serialized object
  28707. */
  28708. serialize(): any;
  28709. /**
  28710. * Float animation type
  28711. */
  28712. static readonly ANIMATIONTYPE_FLOAT: number;
  28713. /**
  28714. * Vector3 animation type
  28715. */
  28716. static readonly ANIMATIONTYPE_VECTOR3: number;
  28717. /**
  28718. * Quaternion animation type
  28719. */
  28720. static readonly ANIMATIONTYPE_QUATERNION: number;
  28721. /**
  28722. * Matrix animation type
  28723. */
  28724. static readonly ANIMATIONTYPE_MATRIX: number;
  28725. /**
  28726. * Color3 animation type
  28727. */
  28728. static readonly ANIMATIONTYPE_COLOR3: number;
  28729. /**
  28730. * Color3 animation type
  28731. */
  28732. static readonly ANIMATIONTYPE_COLOR4: number;
  28733. /**
  28734. * Vector2 animation type
  28735. */
  28736. static readonly ANIMATIONTYPE_VECTOR2: number;
  28737. /**
  28738. * Size animation type
  28739. */
  28740. static readonly ANIMATIONTYPE_SIZE: number;
  28741. /**
  28742. * Relative Loop Mode
  28743. */
  28744. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28745. /**
  28746. * Cycle Loop Mode
  28747. */
  28748. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28749. /**
  28750. * Constant Loop Mode
  28751. */
  28752. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28753. /** @hidden */
  28754. static _UniversalLerp(left: any, right: any, amount: number): any;
  28755. /**
  28756. * Parses an animation object and creates an animation
  28757. * @param parsedAnimation Parsed animation object
  28758. * @returns Animation object
  28759. */
  28760. static Parse(parsedAnimation: any): Animation;
  28761. /**
  28762. * Appends the serialized animations from the source animations
  28763. * @param source Source containing the animations
  28764. * @param destination Target to store the animations
  28765. */
  28766. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28767. }
  28768. }
  28769. declare module "babylonjs/Animations/animatable.interface" {
  28770. import { Nullable } from "babylonjs/types";
  28771. import { Animation } from "babylonjs/Animations/animation";
  28772. /**
  28773. * Interface containing an array of animations
  28774. */
  28775. export interface IAnimatable {
  28776. /**
  28777. * Array of animations
  28778. */
  28779. animations: Nullable<Array<Animation>>;
  28780. }
  28781. }
  28782. declare module "babylonjs/Materials/fresnelParameters" {
  28783. import { Color3 } from "babylonjs/Maths/math.color";
  28784. /**
  28785. * This represents all the required information to add a fresnel effect on a material:
  28786. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28787. */
  28788. export class FresnelParameters {
  28789. private _isEnabled;
  28790. /**
  28791. * Define if the fresnel effect is enable or not.
  28792. */
  28793. isEnabled: boolean;
  28794. /**
  28795. * Define the color used on edges (grazing angle)
  28796. */
  28797. leftColor: Color3;
  28798. /**
  28799. * Define the color used on center
  28800. */
  28801. rightColor: Color3;
  28802. /**
  28803. * Define bias applied to computed fresnel term
  28804. */
  28805. bias: number;
  28806. /**
  28807. * Defined the power exponent applied to fresnel term
  28808. */
  28809. power: number;
  28810. /**
  28811. * Clones the current fresnel and its valuues
  28812. * @returns a clone fresnel configuration
  28813. */
  28814. clone(): FresnelParameters;
  28815. /**
  28816. * Serializes the current fresnel parameters to a JSON representation.
  28817. * @return the JSON serialization
  28818. */
  28819. serialize(): any;
  28820. /**
  28821. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28822. * @param parsedFresnelParameters Define the JSON representation
  28823. * @returns the parsed parameters
  28824. */
  28825. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28826. }
  28827. }
  28828. declare module "babylonjs/Misc/decorators" {
  28829. import { Nullable } from "babylonjs/types";
  28830. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28831. import { Scene } from "babylonjs/scene";
  28832. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28833. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28834. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28835. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28836. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28837. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28838. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28839. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28840. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28841. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28842. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28843. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28844. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28845. /**
  28846. * Decorator used to define property that can be serialized as reference to a camera
  28847. * @param sourceName defines the name of the property to decorate
  28848. */
  28849. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28850. /**
  28851. * Class used to help serialization objects
  28852. */
  28853. export class SerializationHelper {
  28854. /** @hidden */
  28855. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28856. /** @hidden */
  28857. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28858. /** @hidden */
  28859. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28860. /** @hidden */
  28861. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28862. /**
  28863. * Appends the serialized animations from the source animations
  28864. * @param source Source containing the animations
  28865. * @param destination Target to store the animations
  28866. */
  28867. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28868. /**
  28869. * Static function used to serialized a specific entity
  28870. * @param entity defines the entity to serialize
  28871. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28872. * @returns a JSON compatible object representing the serialization of the entity
  28873. */
  28874. static Serialize<T>(entity: T, serializationObject?: any): any;
  28875. /**
  28876. * Creates a new entity from a serialization data object
  28877. * @param creationFunction defines a function used to instanciated the new entity
  28878. * @param source defines the source serialization data
  28879. * @param scene defines the hosting scene
  28880. * @param rootUrl defines the root url for resources
  28881. * @returns a new entity
  28882. */
  28883. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28884. /**
  28885. * Clones an object
  28886. * @param creationFunction defines the function used to instanciate the new object
  28887. * @param source defines the source object
  28888. * @returns the cloned object
  28889. */
  28890. static Clone<T>(creationFunction: () => T, source: T): T;
  28891. /**
  28892. * Instanciates a new object based on a source one (some data will be shared between both object)
  28893. * @param creationFunction defines the function used to instanciate the new object
  28894. * @param source defines the source object
  28895. * @returns the new object
  28896. */
  28897. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28898. }
  28899. }
  28900. declare module "babylonjs/Misc/guid" {
  28901. /**
  28902. * Class used to manipulate GUIDs
  28903. */
  28904. export class GUID {
  28905. /**
  28906. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28907. * Be aware Math.random() could cause collisions, but:
  28908. * "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"
  28909. * @returns a pseudo random id
  28910. */
  28911. static RandomId(): string;
  28912. }
  28913. }
  28914. declare module "babylonjs/Materials/Textures/baseTexture" {
  28915. import { Observable } from "babylonjs/Misc/observable";
  28916. import { Nullable } from "babylonjs/types";
  28917. import { Scene } from "babylonjs/scene";
  28918. import { Matrix } from "babylonjs/Maths/math.vector";
  28919. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28920. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28921. import { ISize } from "babylonjs/Maths/math.size";
  28922. /**
  28923. * Base class of all the textures in babylon.
  28924. * It groups all the common properties the materials, post process, lights... might need
  28925. * in order to make a correct use of the texture.
  28926. */
  28927. export class BaseTexture implements IAnimatable {
  28928. /**
  28929. * Default anisotropic filtering level for the application.
  28930. * It is set to 4 as a good tradeoff between perf and quality.
  28931. */
  28932. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28933. /**
  28934. * Gets or sets the unique id of the texture
  28935. */
  28936. uniqueId: number;
  28937. /**
  28938. * Define the name of the texture.
  28939. */
  28940. name: string;
  28941. /**
  28942. * Gets or sets an object used to store user defined information.
  28943. */
  28944. metadata: any;
  28945. /**
  28946. * For internal use only. Please do not use.
  28947. */
  28948. reservedDataStore: any;
  28949. private _hasAlpha;
  28950. /**
  28951. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28952. */
  28953. hasAlpha: boolean;
  28954. /**
  28955. * Defines if the alpha value should be determined via the rgb values.
  28956. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28957. */
  28958. getAlphaFromRGB: boolean;
  28959. /**
  28960. * Intensity or strength of the texture.
  28961. * It is commonly used by materials to fine tune the intensity of the texture
  28962. */
  28963. level: number;
  28964. /**
  28965. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28966. * This is part of the texture as textures usually maps to one uv set.
  28967. */
  28968. coordinatesIndex: number;
  28969. private _coordinatesMode;
  28970. /**
  28971. * How a texture is mapped.
  28972. *
  28973. * | Value | Type | Description |
  28974. * | ----- | ----------------------------------- | ----------- |
  28975. * | 0 | EXPLICIT_MODE | |
  28976. * | 1 | SPHERICAL_MODE | |
  28977. * | 2 | PLANAR_MODE | |
  28978. * | 3 | CUBIC_MODE | |
  28979. * | 4 | PROJECTION_MODE | |
  28980. * | 5 | SKYBOX_MODE | |
  28981. * | 6 | INVCUBIC_MODE | |
  28982. * | 7 | EQUIRECTANGULAR_MODE | |
  28983. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28984. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28985. */
  28986. coordinatesMode: number;
  28987. /**
  28988. * | Value | Type | Description |
  28989. * | ----- | ------------------ | ----------- |
  28990. * | 0 | CLAMP_ADDRESSMODE | |
  28991. * | 1 | WRAP_ADDRESSMODE | |
  28992. * | 2 | MIRROR_ADDRESSMODE | |
  28993. */
  28994. wrapU: number;
  28995. /**
  28996. * | Value | Type | Description |
  28997. * | ----- | ------------------ | ----------- |
  28998. * | 0 | CLAMP_ADDRESSMODE | |
  28999. * | 1 | WRAP_ADDRESSMODE | |
  29000. * | 2 | MIRROR_ADDRESSMODE | |
  29001. */
  29002. wrapV: number;
  29003. /**
  29004. * | Value | Type | Description |
  29005. * | ----- | ------------------ | ----------- |
  29006. * | 0 | CLAMP_ADDRESSMODE | |
  29007. * | 1 | WRAP_ADDRESSMODE | |
  29008. * | 2 | MIRROR_ADDRESSMODE | |
  29009. */
  29010. wrapR: number;
  29011. /**
  29012. * With compliant hardware and browser (supporting anisotropic filtering)
  29013. * this defines the level of anisotropic filtering in the texture.
  29014. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29015. */
  29016. anisotropicFilteringLevel: number;
  29017. /**
  29018. * Define if the texture is a cube texture or if false a 2d texture.
  29019. */
  29020. isCube: boolean;
  29021. /**
  29022. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29023. */
  29024. is3D: boolean;
  29025. /**
  29026. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29027. */
  29028. is2DArray: boolean;
  29029. /**
  29030. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29031. * HDR texture are usually stored in linear space.
  29032. * This only impacts the PBR and Background materials
  29033. */
  29034. gammaSpace: boolean;
  29035. /**
  29036. * Gets or sets whether or not the texture contains RGBD data.
  29037. */
  29038. isRGBD: boolean;
  29039. /**
  29040. * Is Z inverted in the texture (useful in a cube texture).
  29041. */
  29042. invertZ: boolean;
  29043. /**
  29044. * Are mip maps generated for this texture or not.
  29045. */
  29046. readonly noMipmap: boolean;
  29047. /**
  29048. * @hidden
  29049. */
  29050. lodLevelInAlpha: boolean;
  29051. /**
  29052. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29053. */
  29054. lodGenerationOffset: number;
  29055. /**
  29056. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29057. */
  29058. lodGenerationScale: number;
  29059. /**
  29060. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29061. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29062. * average roughness values.
  29063. */
  29064. linearSpecularLOD: boolean;
  29065. /**
  29066. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29067. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29068. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29069. */
  29070. irradianceTexture: Nullable<BaseTexture>;
  29071. /**
  29072. * Define if the texture is a render target.
  29073. */
  29074. isRenderTarget: boolean;
  29075. /**
  29076. * Define the unique id of the texture in the scene.
  29077. */
  29078. readonly uid: string;
  29079. /**
  29080. * Return a string representation of the texture.
  29081. * @returns the texture as a string
  29082. */
  29083. toString(): string;
  29084. /**
  29085. * Get the class name of the texture.
  29086. * @returns "BaseTexture"
  29087. */
  29088. getClassName(): string;
  29089. /**
  29090. * Define the list of animation attached to the texture.
  29091. */
  29092. animations: import("babylonjs/Animations/animation").Animation[];
  29093. /**
  29094. * An event triggered when the texture is disposed.
  29095. */
  29096. onDisposeObservable: Observable<BaseTexture>;
  29097. private _onDisposeObserver;
  29098. /**
  29099. * Callback triggered when the texture has been disposed.
  29100. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29101. */
  29102. onDispose: () => void;
  29103. /**
  29104. * Define the current state of the loading sequence when in delayed load mode.
  29105. */
  29106. delayLoadState: number;
  29107. private _scene;
  29108. /** @hidden */
  29109. _texture: Nullable<InternalTexture>;
  29110. private _uid;
  29111. /**
  29112. * Define if the texture is preventinga material to render or not.
  29113. * If not and the texture is not ready, the engine will use a default black texture instead.
  29114. */
  29115. readonly isBlocking: boolean;
  29116. /**
  29117. * Instantiates a new BaseTexture.
  29118. * Base class of all the textures in babylon.
  29119. * It groups all the common properties the materials, post process, lights... might need
  29120. * in order to make a correct use of the texture.
  29121. * @param scene Define the scene the texture blongs to
  29122. */
  29123. constructor(scene: Nullable<Scene>);
  29124. /**
  29125. * Get the scene the texture belongs to.
  29126. * @returns the scene or null if undefined
  29127. */
  29128. getScene(): Nullable<Scene>;
  29129. /**
  29130. * Get the texture transform matrix used to offset tile the texture for istance.
  29131. * @returns the transformation matrix
  29132. */
  29133. getTextureMatrix(): Matrix;
  29134. /**
  29135. * Get the texture reflection matrix used to rotate/transform the reflection.
  29136. * @returns the reflection matrix
  29137. */
  29138. getReflectionTextureMatrix(): Matrix;
  29139. /**
  29140. * Get the underlying lower level texture from Babylon.
  29141. * @returns the insternal texture
  29142. */
  29143. getInternalTexture(): Nullable<InternalTexture>;
  29144. /**
  29145. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29146. * @returns true if ready or not blocking
  29147. */
  29148. isReadyOrNotBlocking(): boolean;
  29149. /**
  29150. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29151. * @returns true if fully ready
  29152. */
  29153. isReady(): boolean;
  29154. private _cachedSize;
  29155. /**
  29156. * Get the size of the texture.
  29157. * @returns the texture size.
  29158. */
  29159. getSize(): ISize;
  29160. /**
  29161. * Get the base size of the texture.
  29162. * It can be different from the size if the texture has been resized for POT for instance
  29163. * @returns the base size
  29164. */
  29165. getBaseSize(): ISize;
  29166. /**
  29167. * Update the sampling mode of the texture.
  29168. * Default is Trilinear mode.
  29169. *
  29170. * | Value | Type | Description |
  29171. * | ----- | ------------------ | ----------- |
  29172. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29173. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29174. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29175. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29176. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29177. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29178. * | 7 | NEAREST_LINEAR | |
  29179. * | 8 | NEAREST_NEAREST | |
  29180. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29181. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29182. * | 11 | LINEAR_LINEAR | |
  29183. * | 12 | LINEAR_NEAREST | |
  29184. *
  29185. * > _mag_: magnification filter (close to the viewer)
  29186. * > _min_: minification filter (far from the viewer)
  29187. * > _mip_: filter used between mip map levels
  29188. *@param samplingMode Define the new sampling mode of the texture
  29189. */
  29190. updateSamplingMode(samplingMode: number): void;
  29191. /**
  29192. * Scales the texture if is `canRescale()`
  29193. * @param ratio the resize factor we want to use to rescale
  29194. */
  29195. scale(ratio: number): void;
  29196. /**
  29197. * Get if the texture can rescale.
  29198. */
  29199. readonly canRescale: boolean;
  29200. /** @hidden */
  29201. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29202. /** @hidden */
  29203. _rebuild(): void;
  29204. /**
  29205. * Triggers the load sequence in delayed load mode.
  29206. */
  29207. delayLoad(): void;
  29208. /**
  29209. * Clones the texture.
  29210. * @returns the cloned texture
  29211. */
  29212. clone(): Nullable<BaseTexture>;
  29213. /**
  29214. * Get the texture underlying type (INT, FLOAT...)
  29215. */
  29216. readonly textureType: number;
  29217. /**
  29218. * Get the texture underlying format (RGB, RGBA...)
  29219. */
  29220. readonly textureFormat: number;
  29221. /**
  29222. * Indicates that textures need to be re-calculated for all materials
  29223. */
  29224. protected _markAllSubMeshesAsTexturesDirty(): void;
  29225. /**
  29226. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29227. * This will returns an RGBA array buffer containing either in values (0-255) or
  29228. * float values (0-1) depending of the underlying buffer type.
  29229. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29230. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29231. * @param buffer defines a user defined buffer to fill with data (can be null)
  29232. * @returns The Array buffer containing the pixels data.
  29233. */
  29234. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29235. /**
  29236. * Release and destroy the underlying lower level texture aka internalTexture.
  29237. */
  29238. releaseInternalTexture(): void;
  29239. /** @hidden */
  29240. readonly _lodTextureHigh: Nullable<BaseTexture>;
  29241. /** @hidden */
  29242. readonly _lodTextureMid: Nullable<BaseTexture>;
  29243. /** @hidden */
  29244. readonly _lodTextureLow: Nullable<BaseTexture>;
  29245. /**
  29246. * Dispose the texture and release its associated resources.
  29247. */
  29248. dispose(): void;
  29249. /**
  29250. * Serialize the texture into a JSON representation that can be parsed later on.
  29251. * @returns the JSON representation of the texture
  29252. */
  29253. serialize(): any;
  29254. /**
  29255. * Helper function to be called back once a list of texture contains only ready textures.
  29256. * @param textures Define the list of textures to wait for
  29257. * @param callback Define the callback triggered once the entire list will be ready
  29258. */
  29259. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29260. }
  29261. }
  29262. declare module "babylonjs/Materials/effect" {
  29263. import { Observable } from "babylonjs/Misc/observable";
  29264. import { Nullable } from "babylonjs/types";
  29265. import { IDisposable } from "babylonjs/scene";
  29266. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29267. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29268. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29269. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29270. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29271. import { Engine } from "babylonjs/Engines/engine";
  29272. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29273. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29274. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29275. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29276. /**
  29277. * Options to be used when creating an effect.
  29278. */
  29279. export interface IEffectCreationOptions {
  29280. /**
  29281. * Atrributes that will be used in the shader.
  29282. */
  29283. attributes: string[];
  29284. /**
  29285. * Uniform varible names that will be set in the shader.
  29286. */
  29287. uniformsNames: string[];
  29288. /**
  29289. * Uniform buffer variable names that will be set in the shader.
  29290. */
  29291. uniformBuffersNames: string[];
  29292. /**
  29293. * Sampler texture variable names that will be set in the shader.
  29294. */
  29295. samplers: string[];
  29296. /**
  29297. * Define statements that will be set in the shader.
  29298. */
  29299. defines: any;
  29300. /**
  29301. * Possible fallbacks for this effect to improve performance when needed.
  29302. */
  29303. fallbacks: Nullable<IEffectFallbacks>;
  29304. /**
  29305. * Callback that will be called when the shader is compiled.
  29306. */
  29307. onCompiled: Nullable<(effect: Effect) => void>;
  29308. /**
  29309. * Callback that will be called if an error occurs during shader compilation.
  29310. */
  29311. onError: Nullable<(effect: Effect, errors: string) => void>;
  29312. /**
  29313. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29314. */
  29315. indexParameters?: any;
  29316. /**
  29317. * Max number of lights that can be used in the shader.
  29318. */
  29319. maxSimultaneousLights?: number;
  29320. /**
  29321. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29322. */
  29323. transformFeedbackVaryings?: Nullable<string[]>;
  29324. }
  29325. /**
  29326. * Effect containing vertex and fragment shader that can be executed on an object.
  29327. */
  29328. export class Effect implements IDisposable {
  29329. /**
  29330. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29331. */
  29332. static ShadersRepository: string;
  29333. /**
  29334. * Name of the effect.
  29335. */
  29336. name: any;
  29337. /**
  29338. * String container all the define statements that should be set on the shader.
  29339. */
  29340. defines: string;
  29341. /**
  29342. * Callback that will be called when the shader is compiled.
  29343. */
  29344. onCompiled: Nullable<(effect: Effect) => void>;
  29345. /**
  29346. * Callback that will be called if an error occurs during shader compilation.
  29347. */
  29348. onError: Nullable<(effect: Effect, errors: string) => void>;
  29349. /**
  29350. * Callback that will be called when effect is bound.
  29351. */
  29352. onBind: Nullable<(effect: Effect) => void>;
  29353. /**
  29354. * Unique ID of the effect.
  29355. */
  29356. uniqueId: number;
  29357. /**
  29358. * Observable that will be called when the shader is compiled.
  29359. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29360. */
  29361. onCompileObservable: Observable<Effect>;
  29362. /**
  29363. * Observable that will be called if an error occurs during shader compilation.
  29364. */
  29365. onErrorObservable: Observable<Effect>;
  29366. /** @hidden */
  29367. _onBindObservable: Nullable<Observable<Effect>>;
  29368. /**
  29369. * Observable that will be called when effect is bound.
  29370. */
  29371. readonly onBindObservable: Observable<Effect>;
  29372. /** @hidden */
  29373. _bonesComputationForcedToCPU: boolean;
  29374. private static _uniqueIdSeed;
  29375. private _engine;
  29376. private _uniformBuffersNames;
  29377. private _uniformsNames;
  29378. private _samplerList;
  29379. private _samplers;
  29380. private _isReady;
  29381. private _compilationError;
  29382. private _allFallbacksProcessed;
  29383. private _attributesNames;
  29384. private _attributes;
  29385. private _uniforms;
  29386. /**
  29387. * Key for the effect.
  29388. * @hidden
  29389. */
  29390. _key: string;
  29391. private _indexParameters;
  29392. private _fallbacks;
  29393. private _vertexSourceCode;
  29394. private _fragmentSourceCode;
  29395. private _vertexSourceCodeOverride;
  29396. private _fragmentSourceCodeOverride;
  29397. private _transformFeedbackVaryings;
  29398. /**
  29399. * Compiled shader to webGL program.
  29400. * @hidden
  29401. */
  29402. _pipelineContext: Nullable<IPipelineContext>;
  29403. private _valueCache;
  29404. private static _baseCache;
  29405. /**
  29406. * Instantiates an effect.
  29407. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29408. * @param baseName Name of the effect.
  29409. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29410. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29411. * @param samplers List of sampler variables that will be passed to the shader.
  29412. * @param engine Engine to be used to render the effect
  29413. * @param defines Define statements to be added to the shader.
  29414. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29415. * @param onCompiled Callback that will be called when the shader is compiled.
  29416. * @param onError Callback that will be called if an error occurs during shader compilation.
  29417. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29418. */
  29419. 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);
  29420. private _useFinalCode;
  29421. /**
  29422. * Unique key for this effect
  29423. */
  29424. readonly key: string;
  29425. /**
  29426. * If the effect has been compiled and prepared.
  29427. * @returns if the effect is compiled and prepared.
  29428. */
  29429. isReady(): boolean;
  29430. private _isReadyInternal;
  29431. /**
  29432. * The engine the effect was initialized with.
  29433. * @returns the engine.
  29434. */
  29435. getEngine(): Engine;
  29436. /**
  29437. * The pipeline context for this effect
  29438. * @returns the associated pipeline context
  29439. */
  29440. getPipelineContext(): Nullable<IPipelineContext>;
  29441. /**
  29442. * The set of names of attribute variables for the shader.
  29443. * @returns An array of attribute names.
  29444. */
  29445. getAttributesNames(): string[];
  29446. /**
  29447. * Returns the attribute at the given index.
  29448. * @param index The index of the attribute.
  29449. * @returns The location of the attribute.
  29450. */
  29451. getAttributeLocation(index: number): number;
  29452. /**
  29453. * Returns the attribute based on the name of the variable.
  29454. * @param name of the attribute to look up.
  29455. * @returns the attribute location.
  29456. */
  29457. getAttributeLocationByName(name: string): number;
  29458. /**
  29459. * The number of attributes.
  29460. * @returns the numnber of attributes.
  29461. */
  29462. getAttributesCount(): number;
  29463. /**
  29464. * Gets the index of a uniform variable.
  29465. * @param uniformName of the uniform to look up.
  29466. * @returns the index.
  29467. */
  29468. getUniformIndex(uniformName: string): number;
  29469. /**
  29470. * Returns the attribute based on the name of the variable.
  29471. * @param uniformName of the uniform to look up.
  29472. * @returns the location of the uniform.
  29473. */
  29474. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29475. /**
  29476. * Returns an array of sampler variable names
  29477. * @returns The array of sampler variable neames.
  29478. */
  29479. getSamplers(): string[];
  29480. /**
  29481. * The error from the last compilation.
  29482. * @returns the error string.
  29483. */
  29484. getCompilationError(): string;
  29485. /**
  29486. * Gets a boolean indicating that all fallbacks were used during compilation
  29487. * @returns true if all fallbacks were used
  29488. */
  29489. allFallbacksProcessed(): boolean;
  29490. /**
  29491. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29492. * @param func The callback to be used.
  29493. */
  29494. executeWhenCompiled(func: (effect: Effect) => void): void;
  29495. private _checkIsReady;
  29496. private _loadShader;
  29497. /**
  29498. * Recompiles the webGL program
  29499. * @param vertexSourceCode The source code for the vertex shader.
  29500. * @param fragmentSourceCode The source code for the fragment shader.
  29501. * @param onCompiled Callback called when completed.
  29502. * @param onError Callback called on error.
  29503. * @hidden
  29504. */
  29505. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29506. /**
  29507. * Prepares the effect
  29508. * @hidden
  29509. */
  29510. _prepareEffect(): void;
  29511. private _processCompilationErrors;
  29512. /**
  29513. * Checks if the effect is supported. (Must be called after compilation)
  29514. */
  29515. readonly isSupported: boolean;
  29516. /**
  29517. * Binds a texture to the engine to be used as output of the shader.
  29518. * @param channel Name of the output variable.
  29519. * @param texture Texture to bind.
  29520. * @hidden
  29521. */
  29522. _bindTexture(channel: string, texture: InternalTexture): void;
  29523. /**
  29524. * Sets a texture on the engine to be used in the shader.
  29525. * @param channel Name of the sampler variable.
  29526. * @param texture Texture to set.
  29527. */
  29528. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29529. /**
  29530. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29531. * @param channel Name of the sampler variable.
  29532. * @param texture Texture to set.
  29533. */
  29534. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29535. /**
  29536. * Sets an array of textures on the engine to be used in the shader.
  29537. * @param channel Name of the variable.
  29538. * @param textures Textures to set.
  29539. */
  29540. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29541. /**
  29542. * 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)
  29543. * @param channel Name of the sampler variable.
  29544. * @param postProcess Post process to get the input texture from.
  29545. */
  29546. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29547. /**
  29548. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29549. * 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)
  29550. * @param channel Name of the sampler variable.
  29551. * @param postProcess Post process to get the output texture from.
  29552. */
  29553. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29554. /** @hidden */
  29555. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29556. /** @hidden */
  29557. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29558. /** @hidden */
  29559. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29560. /** @hidden */
  29561. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29562. /**
  29563. * Binds a buffer to a uniform.
  29564. * @param buffer Buffer to bind.
  29565. * @param name Name of the uniform variable to bind to.
  29566. */
  29567. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29568. /**
  29569. * Binds block to a uniform.
  29570. * @param blockName Name of the block to bind.
  29571. * @param index Index to bind.
  29572. */
  29573. bindUniformBlock(blockName: string, index: number): void;
  29574. /**
  29575. * Sets an interger value on a uniform variable.
  29576. * @param uniformName Name of the variable.
  29577. * @param value Value to be set.
  29578. * @returns this effect.
  29579. */
  29580. setInt(uniformName: string, value: number): Effect;
  29581. /**
  29582. * Sets an int array on a uniform variable.
  29583. * @param uniformName Name of the variable.
  29584. * @param array array to be set.
  29585. * @returns this effect.
  29586. */
  29587. setIntArray(uniformName: string, array: Int32Array): Effect;
  29588. /**
  29589. * 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)
  29590. * @param uniformName Name of the variable.
  29591. * @param array array to be set.
  29592. * @returns this effect.
  29593. */
  29594. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29595. /**
  29596. * 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)
  29597. * @param uniformName Name of the variable.
  29598. * @param array array to be set.
  29599. * @returns this effect.
  29600. */
  29601. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29602. /**
  29603. * 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)
  29604. * @param uniformName Name of the variable.
  29605. * @param array array to be set.
  29606. * @returns this effect.
  29607. */
  29608. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29609. /**
  29610. * Sets an float array on a uniform variable.
  29611. * @param uniformName Name of the variable.
  29612. * @param array array to be set.
  29613. * @returns this effect.
  29614. */
  29615. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29616. /**
  29617. * 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)
  29618. * @param uniformName Name of the variable.
  29619. * @param array array to be set.
  29620. * @returns this effect.
  29621. */
  29622. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29623. /**
  29624. * 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)
  29625. * @param uniformName Name of the variable.
  29626. * @param array array to be set.
  29627. * @returns this effect.
  29628. */
  29629. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29630. /**
  29631. * 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)
  29632. * @param uniformName Name of the variable.
  29633. * @param array array to be set.
  29634. * @returns this effect.
  29635. */
  29636. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29637. /**
  29638. * Sets an array on a uniform variable.
  29639. * @param uniformName Name of the variable.
  29640. * @param array array to be set.
  29641. * @returns this effect.
  29642. */
  29643. setArray(uniformName: string, array: number[]): Effect;
  29644. /**
  29645. * 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)
  29646. * @param uniformName Name of the variable.
  29647. * @param array array to be set.
  29648. * @returns this effect.
  29649. */
  29650. setArray2(uniformName: string, array: number[]): Effect;
  29651. /**
  29652. * 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)
  29653. * @param uniformName Name of the variable.
  29654. * @param array array to be set.
  29655. * @returns this effect.
  29656. */
  29657. setArray3(uniformName: string, array: number[]): Effect;
  29658. /**
  29659. * 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)
  29660. * @param uniformName Name of the variable.
  29661. * @param array array to be set.
  29662. * @returns this effect.
  29663. */
  29664. setArray4(uniformName: string, array: number[]): Effect;
  29665. /**
  29666. * Sets matrices on a uniform variable.
  29667. * @param uniformName Name of the variable.
  29668. * @param matrices matrices to be set.
  29669. * @returns this effect.
  29670. */
  29671. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29672. /**
  29673. * Sets matrix on a uniform variable.
  29674. * @param uniformName Name of the variable.
  29675. * @param matrix matrix to be set.
  29676. * @returns this effect.
  29677. */
  29678. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29679. /**
  29680. * 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)
  29681. * @param uniformName Name of the variable.
  29682. * @param matrix matrix to be set.
  29683. * @returns this effect.
  29684. */
  29685. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29686. /**
  29687. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29688. * @param uniformName Name of the variable.
  29689. * @param matrix matrix to be set.
  29690. * @returns this effect.
  29691. */
  29692. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29693. /**
  29694. * Sets a float on a uniform variable.
  29695. * @param uniformName Name of the variable.
  29696. * @param value value to be set.
  29697. * @returns this effect.
  29698. */
  29699. setFloat(uniformName: string, value: number): Effect;
  29700. /**
  29701. * Sets a boolean on a uniform variable.
  29702. * @param uniformName Name of the variable.
  29703. * @param bool value to be set.
  29704. * @returns this effect.
  29705. */
  29706. setBool(uniformName: string, bool: boolean): Effect;
  29707. /**
  29708. * Sets a Vector2 on a uniform variable.
  29709. * @param uniformName Name of the variable.
  29710. * @param vector2 vector2 to be set.
  29711. * @returns this effect.
  29712. */
  29713. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29714. /**
  29715. * Sets a float2 on a uniform variable.
  29716. * @param uniformName Name of the variable.
  29717. * @param x First float in float2.
  29718. * @param y Second float in float2.
  29719. * @returns this effect.
  29720. */
  29721. setFloat2(uniformName: string, x: number, y: number): Effect;
  29722. /**
  29723. * Sets a Vector3 on a uniform variable.
  29724. * @param uniformName Name of the variable.
  29725. * @param vector3 Value to be set.
  29726. * @returns this effect.
  29727. */
  29728. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29729. /**
  29730. * Sets a float3 on a uniform variable.
  29731. * @param uniformName Name of the variable.
  29732. * @param x First float in float3.
  29733. * @param y Second float in float3.
  29734. * @param z Third float in float3.
  29735. * @returns this effect.
  29736. */
  29737. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29738. /**
  29739. * Sets a Vector4 on a uniform variable.
  29740. * @param uniformName Name of the variable.
  29741. * @param vector4 Value to be set.
  29742. * @returns this effect.
  29743. */
  29744. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29745. /**
  29746. * Sets a float4 on a uniform variable.
  29747. * @param uniformName Name of the variable.
  29748. * @param x First float in float4.
  29749. * @param y Second float in float4.
  29750. * @param z Third float in float4.
  29751. * @param w Fourth float in float4.
  29752. * @returns this effect.
  29753. */
  29754. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29755. /**
  29756. * Sets a Color3 on a uniform variable.
  29757. * @param uniformName Name of the variable.
  29758. * @param color3 Value to be set.
  29759. * @returns this effect.
  29760. */
  29761. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29762. /**
  29763. * Sets a Color4 on a uniform variable.
  29764. * @param uniformName Name of the variable.
  29765. * @param color3 Value to be set.
  29766. * @param alpha Alpha value to be set.
  29767. * @returns this effect.
  29768. */
  29769. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29770. /**
  29771. * Sets a Color4 on a uniform variable
  29772. * @param uniformName defines the name of the variable
  29773. * @param color4 defines the value to be set
  29774. * @returns this effect.
  29775. */
  29776. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29777. /** Release all associated resources */
  29778. dispose(): void;
  29779. /**
  29780. * This function will add a new shader to the shader store
  29781. * @param name the name of the shader
  29782. * @param pixelShader optional pixel shader content
  29783. * @param vertexShader optional vertex shader content
  29784. */
  29785. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29786. /**
  29787. * Store of each shader (The can be looked up using effect.key)
  29788. */
  29789. static ShadersStore: {
  29790. [key: string]: string;
  29791. };
  29792. /**
  29793. * Store of each included file for a shader (The can be looked up using effect.key)
  29794. */
  29795. static IncludesShadersStore: {
  29796. [key: string]: string;
  29797. };
  29798. /**
  29799. * Resets the cache of effects.
  29800. */
  29801. static ResetCache(): void;
  29802. }
  29803. }
  29804. declare module "babylonjs/Engines/engineCapabilities" {
  29805. /**
  29806. * Interface used to describe the capabilities of the engine relatively to the current browser
  29807. */
  29808. export interface EngineCapabilities {
  29809. /** Maximum textures units per fragment shader */
  29810. maxTexturesImageUnits: number;
  29811. /** Maximum texture units per vertex shader */
  29812. maxVertexTextureImageUnits: number;
  29813. /** Maximum textures units in the entire pipeline */
  29814. maxCombinedTexturesImageUnits: number;
  29815. /** Maximum texture size */
  29816. maxTextureSize: number;
  29817. /** Maximum texture samples */
  29818. maxSamples?: number;
  29819. /** Maximum cube texture size */
  29820. maxCubemapTextureSize: number;
  29821. /** Maximum render texture size */
  29822. maxRenderTextureSize: number;
  29823. /** Maximum number of vertex attributes */
  29824. maxVertexAttribs: number;
  29825. /** Maximum number of varyings */
  29826. maxVaryingVectors: number;
  29827. /** Maximum number of uniforms per vertex shader */
  29828. maxVertexUniformVectors: number;
  29829. /** Maximum number of uniforms per fragment shader */
  29830. maxFragmentUniformVectors: number;
  29831. /** Defines if standard derivates (dx/dy) are supported */
  29832. standardDerivatives: boolean;
  29833. /** Defines if s3tc texture compression is supported */
  29834. s3tc?: WEBGL_compressed_texture_s3tc;
  29835. /** Defines if pvrtc texture compression is supported */
  29836. pvrtc: any;
  29837. /** Defines if etc1 texture compression is supported */
  29838. etc1: any;
  29839. /** Defines if etc2 texture compression is supported */
  29840. etc2: any;
  29841. /** Defines if astc texture compression is supported */
  29842. astc: any;
  29843. /** Defines if float textures are supported */
  29844. textureFloat: boolean;
  29845. /** Defines if vertex array objects are supported */
  29846. vertexArrayObject: boolean;
  29847. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29848. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  29849. /** Gets the maximum level of anisotropy supported */
  29850. maxAnisotropy: number;
  29851. /** Defines if instancing is supported */
  29852. instancedArrays: boolean;
  29853. /** Defines if 32 bits indices are supported */
  29854. uintIndices: boolean;
  29855. /** Defines if high precision shaders are supported */
  29856. highPrecisionShaderSupported: boolean;
  29857. /** Defines if depth reading in the fragment shader is supported */
  29858. fragmentDepthSupported: boolean;
  29859. /** Defines if float texture linear filtering is supported*/
  29860. textureFloatLinearFiltering: boolean;
  29861. /** Defines if rendering to float textures is supported */
  29862. textureFloatRender: boolean;
  29863. /** Defines if half float textures are supported*/
  29864. textureHalfFloat: boolean;
  29865. /** Defines if half float texture linear filtering is supported*/
  29866. textureHalfFloatLinearFiltering: boolean;
  29867. /** Defines if rendering to half float textures is supported */
  29868. textureHalfFloatRender: boolean;
  29869. /** Defines if textureLOD shader command is supported */
  29870. textureLOD: boolean;
  29871. /** Defines if draw buffers extension is supported */
  29872. drawBuffersExtension: boolean;
  29873. /** Defines if depth textures are supported */
  29874. depthTextureExtension: boolean;
  29875. /** Defines if float color buffer are supported */
  29876. colorBufferFloat: boolean;
  29877. /** Gets disjoint timer query extension (null if not supported) */
  29878. timerQuery?: EXT_disjoint_timer_query;
  29879. /** Defines if timestamp can be used with timer query */
  29880. canUseTimestampForTimerQuery: boolean;
  29881. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29882. multiview?: any;
  29883. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  29884. oculusMultiview?: any;
  29885. /** Function used to let the system compiles shaders in background */
  29886. parallelShaderCompile?: {
  29887. COMPLETION_STATUS_KHR: number;
  29888. };
  29889. /** Max number of texture samples for MSAA */
  29890. maxMSAASamples: number;
  29891. /** Defines if the blend min max extension is supported */
  29892. blendMinMax: boolean;
  29893. }
  29894. }
  29895. declare module "babylonjs/States/depthCullingState" {
  29896. import { Nullable } from "babylonjs/types";
  29897. /**
  29898. * @hidden
  29899. **/
  29900. export class DepthCullingState {
  29901. private _isDepthTestDirty;
  29902. private _isDepthMaskDirty;
  29903. private _isDepthFuncDirty;
  29904. private _isCullFaceDirty;
  29905. private _isCullDirty;
  29906. private _isZOffsetDirty;
  29907. private _isFrontFaceDirty;
  29908. private _depthTest;
  29909. private _depthMask;
  29910. private _depthFunc;
  29911. private _cull;
  29912. private _cullFace;
  29913. private _zOffset;
  29914. private _frontFace;
  29915. /**
  29916. * Initializes the state.
  29917. */
  29918. constructor();
  29919. readonly isDirty: boolean;
  29920. zOffset: number;
  29921. cullFace: Nullable<number>;
  29922. cull: Nullable<boolean>;
  29923. depthFunc: Nullable<number>;
  29924. depthMask: boolean;
  29925. depthTest: boolean;
  29926. frontFace: Nullable<number>;
  29927. reset(): void;
  29928. apply(gl: WebGLRenderingContext): void;
  29929. }
  29930. }
  29931. declare module "babylonjs/States/stencilState" {
  29932. /**
  29933. * @hidden
  29934. **/
  29935. export class StencilState {
  29936. /** 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 */
  29937. static readonly ALWAYS: number;
  29938. /** Passed to stencilOperation to specify that stencil value must be kept */
  29939. static readonly KEEP: number;
  29940. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29941. static readonly REPLACE: number;
  29942. private _isStencilTestDirty;
  29943. private _isStencilMaskDirty;
  29944. private _isStencilFuncDirty;
  29945. private _isStencilOpDirty;
  29946. private _stencilTest;
  29947. private _stencilMask;
  29948. private _stencilFunc;
  29949. private _stencilFuncRef;
  29950. private _stencilFuncMask;
  29951. private _stencilOpStencilFail;
  29952. private _stencilOpDepthFail;
  29953. private _stencilOpStencilDepthPass;
  29954. readonly isDirty: boolean;
  29955. stencilFunc: number;
  29956. stencilFuncRef: number;
  29957. stencilFuncMask: number;
  29958. stencilOpStencilFail: number;
  29959. stencilOpDepthFail: number;
  29960. stencilOpStencilDepthPass: number;
  29961. stencilMask: number;
  29962. stencilTest: boolean;
  29963. constructor();
  29964. reset(): void;
  29965. apply(gl: WebGLRenderingContext): void;
  29966. }
  29967. }
  29968. declare module "babylonjs/States/alphaCullingState" {
  29969. /**
  29970. * @hidden
  29971. **/
  29972. export class AlphaState {
  29973. private _isAlphaBlendDirty;
  29974. private _isBlendFunctionParametersDirty;
  29975. private _isBlendEquationParametersDirty;
  29976. private _isBlendConstantsDirty;
  29977. private _alphaBlend;
  29978. private _blendFunctionParameters;
  29979. private _blendEquationParameters;
  29980. private _blendConstants;
  29981. /**
  29982. * Initializes the state.
  29983. */
  29984. constructor();
  29985. readonly isDirty: boolean;
  29986. alphaBlend: boolean;
  29987. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29988. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29989. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29990. reset(): void;
  29991. apply(gl: WebGLRenderingContext): void;
  29992. }
  29993. }
  29994. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29995. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29996. /** @hidden */
  29997. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29998. attributeProcessor(attribute: string): string;
  29999. varyingProcessor(varying: string, isFragment: boolean): string;
  30000. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30001. }
  30002. }
  30003. declare module "babylonjs/Engines/instancingAttributeInfo" {
  30004. /**
  30005. * Interface for attribute information associated with buffer instanciation
  30006. */
  30007. export interface InstancingAttributeInfo {
  30008. /**
  30009. * Index/offset of the attribute in the vertex shader
  30010. */
  30011. index: number;
  30012. /**
  30013. * size of the attribute, 1, 2, 3 or 4
  30014. */
  30015. attributeSize: number;
  30016. /**
  30017. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30018. * default is FLOAT
  30019. */
  30020. attributeType: number;
  30021. /**
  30022. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30023. */
  30024. normalized: boolean;
  30025. /**
  30026. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30027. */
  30028. offset: number;
  30029. /**
  30030. * Name of the GLSL attribute, for debugging purpose only
  30031. */
  30032. attributeName: string;
  30033. }
  30034. }
  30035. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  30036. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30037. import { Nullable } from "babylonjs/types";
  30038. module "babylonjs/Engines/thinEngine" {
  30039. interface ThinEngine {
  30040. /**
  30041. * Update a video texture
  30042. * @param texture defines the texture to update
  30043. * @param video defines the video element to use
  30044. * @param invertY defines if data must be stored with Y axis inverted
  30045. */
  30046. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30047. }
  30048. }
  30049. }
  30050. declare module "babylonjs/Materials/Textures/videoTexture" {
  30051. import { Observable } from "babylonjs/Misc/observable";
  30052. import { Nullable } from "babylonjs/types";
  30053. import { Scene } from "babylonjs/scene";
  30054. import { Texture } from "babylonjs/Materials/Textures/texture";
  30055. import "babylonjs/Engines/Extensions/engine.videoTexture";
  30056. /**
  30057. * Settings for finer control over video usage
  30058. */
  30059. export interface VideoTextureSettings {
  30060. /**
  30061. * Applies `autoplay` to video, if specified
  30062. */
  30063. autoPlay?: boolean;
  30064. /**
  30065. * Applies `loop` to video, if specified
  30066. */
  30067. loop?: boolean;
  30068. /**
  30069. * Automatically updates internal texture from video at every frame in the render loop
  30070. */
  30071. autoUpdateTexture: boolean;
  30072. /**
  30073. * Image src displayed during the video loading or until the user interacts with the video.
  30074. */
  30075. poster?: string;
  30076. }
  30077. /**
  30078. * If you want to display a video in your scene, this is the special texture for that.
  30079. * This special texture works similar to other textures, with the exception of a few parameters.
  30080. * @see https://doc.babylonjs.com/how_to/video_texture
  30081. */
  30082. export class VideoTexture extends Texture {
  30083. /**
  30084. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30085. */
  30086. readonly autoUpdateTexture: boolean;
  30087. /**
  30088. * The video instance used by the texture internally
  30089. */
  30090. readonly video: HTMLVideoElement;
  30091. private _onUserActionRequestedObservable;
  30092. /**
  30093. * Event triggerd when a dom action is required by the user to play the video.
  30094. * This happens due to recent changes in browser policies preventing video to auto start.
  30095. */
  30096. readonly onUserActionRequestedObservable: Observable<Texture>;
  30097. private _generateMipMaps;
  30098. private _engine;
  30099. private _stillImageCaptured;
  30100. private _displayingPosterTexture;
  30101. private _settings;
  30102. private _createInternalTextureOnEvent;
  30103. private _frameId;
  30104. /**
  30105. * Creates a video texture.
  30106. * If you want to display a video in your scene, this is the special texture for that.
  30107. * This special texture works similar to other textures, with the exception of a few parameters.
  30108. * @see https://doc.babylonjs.com/how_to/video_texture
  30109. * @param name optional name, will detect from video source, if not defined
  30110. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30111. * @param scene is obviously the current scene.
  30112. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30113. * @param invertY is false by default but can be used to invert video on Y axis
  30114. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30115. * @param settings allows finer control over video usage
  30116. */
  30117. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30118. private _getName;
  30119. private _getVideo;
  30120. private _createInternalTexture;
  30121. private reset;
  30122. /**
  30123. * @hidden Internal method to initiate `update`.
  30124. */
  30125. _rebuild(): void;
  30126. /**
  30127. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30128. */
  30129. update(): void;
  30130. /**
  30131. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30132. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30133. */
  30134. updateTexture(isVisible: boolean): void;
  30135. protected _updateInternalTexture: () => void;
  30136. /**
  30137. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30138. * @param url New url.
  30139. */
  30140. updateURL(url: string): void;
  30141. /**
  30142. * Dispose the texture and release its associated resources.
  30143. */
  30144. dispose(): void;
  30145. /**
  30146. * Creates a video texture straight from a stream.
  30147. * @param scene Define the scene the texture should be created in
  30148. * @param stream Define the stream the texture should be created from
  30149. * @returns The created video texture as a promise
  30150. */
  30151. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30152. /**
  30153. * Creates a video texture straight from your WebCam video feed.
  30154. * @param scene Define the scene the texture should be created in
  30155. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30156. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30157. * @returns The created video texture as a promise
  30158. */
  30159. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30160. minWidth: number;
  30161. maxWidth: number;
  30162. minHeight: number;
  30163. maxHeight: number;
  30164. deviceId: string;
  30165. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30166. /**
  30167. * Creates a video texture straight from your WebCam video feed.
  30168. * @param scene Define the scene the texture should be created in
  30169. * @param onReady Define a callback to triggered once the texture will be ready
  30170. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30171. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30172. */
  30173. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30174. minWidth: number;
  30175. maxWidth: number;
  30176. minHeight: number;
  30177. maxHeight: number;
  30178. deviceId: string;
  30179. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30180. }
  30181. }
  30182. declare module "babylonjs/Engines/thinEngine" {
  30183. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30184. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  30185. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30186. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30187. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  30188. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  30189. import { Observable } from "babylonjs/Misc/observable";
  30190. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  30191. import { StencilState } from "babylonjs/States/stencilState";
  30192. import { AlphaState } from "babylonjs/States/alphaCullingState";
  30193. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30194. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30195. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30196. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30197. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30198. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30199. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30200. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  30201. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30202. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30203. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30204. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  30205. /**
  30206. * Defines the interface used by objects working like Scene
  30207. * @hidden
  30208. */
  30209. interface ISceneLike {
  30210. _addPendingData(data: any): void;
  30211. _removePendingData(data: any): void;
  30212. offlineProvider: IOfflineProvider;
  30213. }
  30214. /** Interface defining initialization parameters for Engine class */
  30215. export interface EngineOptions extends WebGLContextAttributes {
  30216. /**
  30217. * Defines if the engine should no exceed a specified device ratio
  30218. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30219. */
  30220. limitDeviceRatio?: number;
  30221. /**
  30222. * Defines if webvr should be enabled automatically
  30223. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30224. */
  30225. autoEnableWebVR?: boolean;
  30226. /**
  30227. * Defines if webgl2 should be turned off even if supported
  30228. * @see http://doc.babylonjs.com/features/webgl2
  30229. */
  30230. disableWebGL2Support?: boolean;
  30231. /**
  30232. * Defines if webaudio should be initialized as well
  30233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30234. */
  30235. audioEngine?: boolean;
  30236. /**
  30237. * Defines if animations should run using a deterministic lock step
  30238. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30239. */
  30240. deterministicLockstep?: boolean;
  30241. /** Defines the maximum steps to use with deterministic lock step mode */
  30242. lockstepMaxSteps?: number;
  30243. /**
  30244. * Defines that engine should ignore context lost events
  30245. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30246. */
  30247. doNotHandleContextLost?: boolean;
  30248. /**
  30249. * Defines that engine should ignore modifying touch action attribute and style
  30250. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30251. */
  30252. doNotHandleTouchAction?: boolean;
  30253. /**
  30254. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30255. */
  30256. useHighPrecisionFloats?: boolean;
  30257. }
  30258. /**
  30259. * The base engine class (root of all engines)
  30260. */
  30261. export class ThinEngine {
  30262. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30263. static ExceptionList: ({
  30264. key: string;
  30265. capture: string;
  30266. captureConstraint: number;
  30267. targets: string[];
  30268. } | {
  30269. key: string;
  30270. capture: null;
  30271. captureConstraint: null;
  30272. targets: string[];
  30273. })[];
  30274. /** @hidden */
  30275. static _TextureLoaders: IInternalTextureLoader[];
  30276. /**
  30277. * Returns the current npm package of the sdk
  30278. */
  30279. static readonly NpmPackage: string;
  30280. /**
  30281. * Returns the current version of the framework
  30282. */
  30283. static readonly Version: string;
  30284. /**
  30285. * Returns a string describing the current engine
  30286. */
  30287. readonly description: string;
  30288. /**
  30289. * Gets or sets the epsilon value used by collision engine
  30290. */
  30291. static CollisionsEpsilon: number;
  30292. /**
  30293. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30294. */
  30295. static ShadersRepository: string;
  30296. /** @hidden */
  30297. _shaderProcessor: IShaderProcessor;
  30298. /**
  30299. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30300. */
  30301. forcePOTTextures: boolean;
  30302. /**
  30303. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30304. */
  30305. isFullscreen: boolean;
  30306. /**
  30307. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30308. */
  30309. cullBackFaces: boolean;
  30310. /**
  30311. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30312. */
  30313. renderEvenInBackground: boolean;
  30314. /**
  30315. * Gets or sets a boolean indicating that cache can be kept between frames
  30316. */
  30317. preventCacheWipeBetweenFrames: boolean;
  30318. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30319. validateShaderPrograms: boolean;
  30320. /**
  30321. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30322. */
  30323. disableUniformBuffers: boolean;
  30324. /** @hidden */
  30325. _uniformBuffers: UniformBuffer[];
  30326. /**
  30327. * Gets a boolean indicating that the engine supports uniform buffers
  30328. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30329. */
  30330. readonly supportsUniformBuffers: boolean;
  30331. /** @hidden */
  30332. _gl: WebGLRenderingContext;
  30333. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30334. protected _windowIsBackground: boolean;
  30335. protected _webGLVersion: number;
  30336. protected _creationOptions: EngineOptions;
  30337. protected _highPrecisionShadersAllowed: boolean;
  30338. /** @hidden */
  30339. readonly _shouldUseHighPrecisionShader: boolean;
  30340. /**
  30341. * Gets a boolean indicating that only power of 2 textures are supported
  30342. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30343. */
  30344. readonly needPOTTextures: boolean;
  30345. /** @hidden */
  30346. _badOS: boolean;
  30347. /** @hidden */
  30348. _badDesktopOS: boolean;
  30349. private _hardwareScalingLevel;
  30350. /** @hidden */
  30351. _caps: EngineCapabilities;
  30352. private _isStencilEnable;
  30353. protected _colorWrite: boolean;
  30354. private _glVersion;
  30355. private _glRenderer;
  30356. private _glVendor;
  30357. /** @hidden */
  30358. _videoTextureSupported: boolean;
  30359. protected _renderingQueueLaunched: boolean;
  30360. protected _activeRenderLoops: (() => void)[];
  30361. /**
  30362. * Observable signaled when a context lost event is raised
  30363. */
  30364. onContextLostObservable: Observable<ThinEngine>;
  30365. /**
  30366. * Observable signaled when a context restored event is raised
  30367. */
  30368. onContextRestoredObservable: Observable<ThinEngine>;
  30369. private _onContextLost;
  30370. private _onContextRestored;
  30371. protected _contextWasLost: boolean;
  30372. /** @hidden */
  30373. _doNotHandleContextLost: boolean;
  30374. /**
  30375. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30376. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30377. */
  30378. doNotHandleContextLost: boolean;
  30379. /**
  30380. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30381. */
  30382. disableVertexArrayObjects: boolean;
  30383. /** @hidden */
  30384. protected _depthCullingState: DepthCullingState;
  30385. /** @hidden */
  30386. protected _stencilState: StencilState;
  30387. /** @hidden */
  30388. protected _alphaState: AlphaState;
  30389. /** @hidden */
  30390. _internalTexturesCache: InternalTexture[];
  30391. /** @hidden */
  30392. protected _activeChannel: number;
  30393. private _currentTextureChannel;
  30394. /** @hidden */
  30395. protected _boundTexturesCache: {
  30396. [key: string]: Nullable<InternalTexture>;
  30397. };
  30398. /** @hidden */
  30399. protected _currentEffect: Nullable<Effect>;
  30400. /** @hidden */
  30401. protected _currentProgram: Nullable<WebGLProgram>;
  30402. private _compiledEffects;
  30403. private _vertexAttribArraysEnabled;
  30404. /** @hidden */
  30405. protected _cachedViewport: Nullable<IViewportLike>;
  30406. private _cachedVertexArrayObject;
  30407. /** @hidden */
  30408. protected _cachedVertexBuffers: any;
  30409. /** @hidden */
  30410. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30411. /** @hidden */
  30412. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30413. /** @hidden */
  30414. _currentRenderTarget: Nullable<InternalTexture>;
  30415. private _uintIndicesCurrentlySet;
  30416. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30417. /** @hidden */
  30418. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30419. private _currentBufferPointers;
  30420. private _currentInstanceLocations;
  30421. private _currentInstanceBuffers;
  30422. private _textureUnits;
  30423. /** @hidden */
  30424. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30425. /** @hidden */
  30426. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30427. /** @hidden */
  30428. _boundRenderFunction: any;
  30429. private _vaoRecordInProgress;
  30430. private _mustWipeVertexAttributes;
  30431. private _emptyTexture;
  30432. private _emptyCubeTexture;
  30433. private _emptyTexture3D;
  30434. private _emptyTexture2DArray;
  30435. /** @hidden */
  30436. _frameHandler: number;
  30437. private _nextFreeTextureSlots;
  30438. private _maxSimultaneousTextures;
  30439. private _activeRequests;
  30440. protected _texturesSupported: string[];
  30441. /** @hidden */
  30442. _textureFormatInUse: Nullable<string>;
  30443. protected readonly _supportsHardwareTextureRescaling: boolean;
  30444. /**
  30445. * Gets the list of texture formats supported
  30446. */
  30447. readonly texturesSupported: Array<string>;
  30448. /**
  30449. * Gets the list of texture formats in use
  30450. */
  30451. readonly textureFormatInUse: Nullable<string>;
  30452. /**
  30453. * Gets the current viewport
  30454. */
  30455. readonly currentViewport: Nullable<IViewportLike>;
  30456. /**
  30457. * Gets the default empty texture
  30458. */
  30459. readonly emptyTexture: InternalTexture;
  30460. /**
  30461. * Gets the default empty 3D texture
  30462. */
  30463. readonly emptyTexture3D: InternalTexture;
  30464. /**
  30465. * Gets the default empty 2D array texture
  30466. */
  30467. readonly emptyTexture2DArray: InternalTexture;
  30468. /**
  30469. * Gets the default empty cube texture
  30470. */
  30471. readonly emptyCubeTexture: InternalTexture;
  30472. /**
  30473. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30474. */
  30475. readonly premultipliedAlpha: boolean;
  30476. /**
  30477. * Observable event triggered before each texture is initialized
  30478. */
  30479. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30480. /**
  30481. * Creates a new engine
  30482. * @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
  30483. * @param antialias defines enable antialiasing (default: false)
  30484. * @param options defines further options to be sent to the getContext() function
  30485. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30486. */
  30487. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30488. private _rebuildInternalTextures;
  30489. private _rebuildEffects;
  30490. /**
  30491. * Gets a boolean indicating if all created effects are ready
  30492. * @returns true if all effects are ready
  30493. */
  30494. areAllEffectsReady(): boolean;
  30495. protected _rebuildBuffers(): void;
  30496. private _initGLContext;
  30497. /**
  30498. * Gets version of the current webGL context
  30499. */
  30500. readonly webGLVersion: number;
  30501. /**
  30502. * Gets a string idenfifying the name of the class
  30503. * @returns "Engine" string
  30504. */
  30505. getClassName(): string;
  30506. /**
  30507. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30508. */
  30509. readonly isStencilEnable: boolean;
  30510. /** @hidden */
  30511. _prepareWorkingCanvas(): void;
  30512. /**
  30513. * Reset the texture cache to empty state
  30514. */
  30515. resetTextureCache(): void;
  30516. /**
  30517. * Gets an object containing information about the current webGL context
  30518. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30519. */
  30520. getGlInfo(): {
  30521. vendor: string;
  30522. renderer: string;
  30523. version: string;
  30524. };
  30525. /**
  30526. * Defines the hardware scaling level.
  30527. * By default the hardware scaling level is computed from the window device ratio.
  30528. * 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.
  30529. * @param level defines the level to use
  30530. */
  30531. setHardwareScalingLevel(level: number): void;
  30532. /**
  30533. * Gets the current hardware scaling level.
  30534. * By default the hardware scaling level is computed from the window device ratio.
  30535. * 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.
  30536. * @returns a number indicating the current hardware scaling level
  30537. */
  30538. getHardwareScalingLevel(): number;
  30539. /**
  30540. * Gets the list of loaded textures
  30541. * @returns an array containing all loaded textures
  30542. */
  30543. getLoadedTexturesCache(): InternalTexture[];
  30544. /**
  30545. * Gets the object containing all engine capabilities
  30546. * @returns the EngineCapabilities object
  30547. */
  30548. getCaps(): EngineCapabilities;
  30549. /**
  30550. * stop executing a render loop function and remove it from the execution array
  30551. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30552. */
  30553. stopRenderLoop(renderFunction?: () => void): void;
  30554. /** @hidden */
  30555. _renderLoop(): void;
  30556. /**
  30557. * Gets the HTML canvas attached with the current webGL context
  30558. * @returns a HTML canvas
  30559. */
  30560. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30561. /**
  30562. * Gets host window
  30563. * @returns the host window object
  30564. */
  30565. getHostWindow(): Nullable<Window>;
  30566. /**
  30567. * Gets the current render width
  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 width
  30570. */
  30571. getRenderWidth(useScreen?: boolean): number;
  30572. /**
  30573. * Gets the current render height
  30574. * @param useScreen defines if screen size must be used (or the current render target if any)
  30575. * @returns a number defining the current render height
  30576. */
  30577. getRenderHeight(useScreen?: boolean): number;
  30578. /**
  30579. * Can be used to override the current requestAnimationFrame requester.
  30580. * @hidden
  30581. */
  30582. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30583. /**
  30584. * Register and execute a render loop. The engine can have more than one render function
  30585. * @param renderFunction defines the function to continuously execute
  30586. */
  30587. runRenderLoop(renderFunction: () => void): void;
  30588. /**
  30589. * Clear the current render buffer or the current render target (if any is set up)
  30590. * @param color defines the color to use
  30591. * @param backBuffer defines if the back buffer must be cleared
  30592. * @param depth defines if the depth buffer must be cleared
  30593. * @param stencil defines if the stencil buffer must be cleared
  30594. */
  30595. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30596. private _viewportCached;
  30597. /** @hidden */
  30598. _viewport(x: number, y: number, width: number, height: number): void;
  30599. /**
  30600. * Set the WebGL's viewport
  30601. * @param viewport defines the viewport element to be used
  30602. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30603. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30604. */
  30605. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30606. /**
  30607. * Begin a new frame
  30608. */
  30609. beginFrame(): void;
  30610. /**
  30611. * Enf the current frame
  30612. */
  30613. endFrame(): void;
  30614. /**
  30615. * Resize the view according to the canvas' size
  30616. */
  30617. resize(): void;
  30618. /**
  30619. * Force a specific size of the canvas
  30620. * @param width defines the new canvas' width
  30621. * @param height defines the new canvas' height
  30622. */
  30623. setSize(width: number, height: number): void;
  30624. /**
  30625. * Binds the frame buffer to the specified texture.
  30626. * @param texture The texture to render to or null for the default canvas
  30627. * @param faceIndex The face of the texture to render to in case of cube texture
  30628. * @param requiredWidth The width of the target to render to
  30629. * @param requiredHeight The height of the target to render to
  30630. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30631. * @param depthStencilTexture The depth stencil texture to use to render
  30632. * @param lodLevel defines le lod level to bind to the frame buffer
  30633. */
  30634. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30635. /** @hidden */
  30636. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30637. /**
  30638. * Unbind the current render target texture from the webGL context
  30639. * @param texture defines the render target texture to unbind
  30640. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30641. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30642. */
  30643. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30644. /**
  30645. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30646. */
  30647. flushFramebuffer(): void;
  30648. /**
  30649. * Unbind the current render target and bind the default framebuffer
  30650. */
  30651. restoreDefaultFramebuffer(): void;
  30652. /** @hidden */
  30653. protected _resetVertexBufferBinding(): void;
  30654. /**
  30655. * Creates a vertex buffer
  30656. * @param data the data for the vertex buffer
  30657. * @returns the new WebGL static buffer
  30658. */
  30659. createVertexBuffer(data: DataArray): DataBuffer;
  30660. private _createVertexBuffer;
  30661. /**
  30662. * Creates a dynamic vertex buffer
  30663. * @param data the data for the dynamic vertex buffer
  30664. * @returns the new WebGL dynamic buffer
  30665. */
  30666. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30667. protected _resetIndexBufferBinding(): void;
  30668. /**
  30669. * Creates a new index buffer
  30670. * @param indices defines the content of the index buffer
  30671. * @param updatable defines if the index buffer must be updatable
  30672. * @returns a new webGL buffer
  30673. */
  30674. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30675. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30676. /**
  30677. * Bind a webGL buffer to the webGL context
  30678. * @param buffer defines the buffer to bind
  30679. */
  30680. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30681. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30682. private bindBuffer;
  30683. /**
  30684. * update the bound buffer with the given data
  30685. * @param data defines the data to update
  30686. */
  30687. updateArrayBuffer(data: Float32Array): void;
  30688. private _vertexAttribPointer;
  30689. private _bindIndexBufferWithCache;
  30690. private _bindVertexBuffersAttributes;
  30691. /**
  30692. * Records a vertex array object
  30693. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30694. * @param vertexBuffers defines the list of vertex buffers to store
  30695. * @param indexBuffer defines the index buffer to store
  30696. * @param effect defines the effect to store
  30697. * @returns the new vertex array object
  30698. */
  30699. recordVertexArrayObject(vertexBuffers: {
  30700. [key: string]: VertexBuffer;
  30701. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30702. /**
  30703. * Bind a specific vertex array object
  30704. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30705. * @param vertexArrayObject defines the vertex array object to bind
  30706. * @param indexBuffer defines the index buffer to bind
  30707. */
  30708. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30709. /**
  30710. * Bind webGl buffers directly to the webGL context
  30711. * @param vertexBuffer defines the vertex buffer to bind
  30712. * @param indexBuffer defines the index buffer to bind
  30713. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30714. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30715. * @param effect defines the effect associated with the vertex buffer
  30716. */
  30717. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30718. private _unbindVertexArrayObject;
  30719. /**
  30720. * Bind a list of vertex buffers to the webGL context
  30721. * @param vertexBuffers defines the list of vertex buffers to bind
  30722. * @param indexBuffer defines the index buffer to bind
  30723. * @param effect defines the effect associated with the vertex buffers
  30724. */
  30725. bindBuffers(vertexBuffers: {
  30726. [key: string]: Nullable<VertexBuffer>;
  30727. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30728. /**
  30729. * Unbind all instance attributes
  30730. */
  30731. unbindInstanceAttributes(): void;
  30732. /**
  30733. * Release and free the memory of a vertex array object
  30734. * @param vao defines the vertex array object to delete
  30735. */
  30736. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30737. /** @hidden */
  30738. _releaseBuffer(buffer: DataBuffer): boolean;
  30739. protected _deleteBuffer(buffer: DataBuffer): void;
  30740. /**
  30741. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30742. * @param instancesBuffer defines the webGL buffer to update and bind
  30743. * @param data defines the data to store in the buffer
  30744. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30745. */
  30746. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30747. /**
  30748. * Apply all cached states (depth, culling, stencil and alpha)
  30749. */
  30750. applyStates(): void;
  30751. /**
  30752. * Send a draw order
  30753. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30754. * @param indexStart defines the starting index
  30755. * @param indexCount defines the number of index to draw
  30756. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30757. */
  30758. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30759. /**
  30760. * Draw a list of points
  30761. * @param verticesStart defines the index of first vertex to draw
  30762. * @param verticesCount defines the count of vertices to draw
  30763. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30764. */
  30765. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30766. /**
  30767. * Draw a list of unindexed primitives
  30768. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30769. * @param verticesStart defines the index of first vertex to draw
  30770. * @param verticesCount defines the count of vertices to draw
  30771. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30772. */
  30773. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30774. /**
  30775. * Draw a list of indexed primitives
  30776. * @param fillMode defines the primitive to use
  30777. * @param indexStart defines the starting index
  30778. * @param indexCount defines the number of index to draw
  30779. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30780. */
  30781. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30782. /**
  30783. * Draw a list of unindexed primitives
  30784. * @param fillMode defines the primitive to use
  30785. * @param verticesStart defines the index of first vertex to draw
  30786. * @param verticesCount defines the count of vertices to draw
  30787. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30788. */
  30789. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30790. private _drawMode;
  30791. /** @hidden */
  30792. protected _reportDrawCall(): void;
  30793. /** @hidden */
  30794. _releaseEffect(effect: Effect): void;
  30795. /** @hidden */
  30796. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30797. /**
  30798. * Create a new effect (used to store vertex/fragment shaders)
  30799. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30800. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30801. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30802. * @param samplers defines an array of string used to represent textures
  30803. * @param defines defines the string containing the defines to use to compile the shaders
  30804. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30805. * @param onCompiled defines a function to call when the effect creation is successful
  30806. * @param onError defines a function to call when the effect creation has failed
  30807. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30808. * @returns the new Effect
  30809. */
  30810. 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;
  30811. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30812. private _compileShader;
  30813. private _compileRawShader;
  30814. /**
  30815. * Directly creates a webGL program
  30816. * @param pipelineContext defines the pipeline context to attach to
  30817. * @param vertexCode defines the vertex shader code to use
  30818. * @param fragmentCode defines the fragment shader code to use
  30819. * @param context defines the webGL context to use (if not set, the current one will be used)
  30820. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30821. * @returns the new webGL program
  30822. */
  30823. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30824. /**
  30825. * Creates a webGL program
  30826. * @param pipelineContext defines the pipeline context to attach to
  30827. * @param vertexCode defines the vertex shader code to use
  30828. * @param fragmentCode defines the fragment shader code to use
  30829. * @param defines defines the string containing the defines to use to compile the shaders
  30830. * @param context defines the webGL context to use (if not set, the current one will be used)
  30831. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30832. * @returns the new webGL program
  30833. */
  30834. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30835. /**
  30836. * Creates a new pipeline context
  30837. * @returns the new pipeline
  30838. */
  30839. createPipelineContext(): IPipelineContext;
  30840. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30841. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30842. /** @hidden */
  30843. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30844. /** @hidden */
  30845. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30846. /** @hidden */
  30847. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30848. /**
  30849. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30850. * @param pipelineContext defines the pipeline context to use
  30851. * @param uniformsNames defines the list of uniform names
  30852. * @returns an array of webGL uniform locations
  30853. */
  30854. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30855. /**
  30856. * Gets the lsit of active attributes for a given webGL program
  30857. * @param pipelineContext defines the pipeline context to use
  30858. * @param attributesNames defines the list of attribute names to get
  30859. * @returns an array of indices indicating the offset of each attribute
  30860. */
  30861. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30862. /**
  30863. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30864. * @param effect defines the effect to activate
  30865. */
  30866. enableEffect(effect: Nullable<Effect>): void;
  30867. /**
  30868. * Set the value of an uniform to a number (int)
  30869. * @param uniform defines the webGL uniform location where to store the value
  30870. * @param value defines the int number to store
  30871. */
  30872. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30873. /**
  30874. * Set the value of an uniform to an array of int32
  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. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30879. /**
  30880. * Set the value of an uniform to an array of int32 (stored as vec2)
  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. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30885. /**
  30886. * Set the value of an uniform to an array of int32 (stored as vec3)
  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. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30891. /**
  30892. * Set the value of an uniform to an array of int32 (stored as vec4)
  30893. * @param uniform defines the webGL uniform location where to store the value
  30894. * @param array defines the array of int32 to store
  30895. */
  30896. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30897. /**
  30898. * Set the value of an uniform to an array of number
  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. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30903. /**
  30904. * Set the value of an uniform to an array of number (stored as vec2)
  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. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30909. /**
  30910. * Set the value of an uniform to an array of number (stored as vec3)
  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. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30915. /**
  30916. * Set the value of an uniform to an array of number (stored as vec4)
  30917. * @param uniform defines the webGL uniform location where to store the value
  30918. * @param array defines the array of number to store
  30919. */
  30920. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30921. /**
  30922. * Set the value of an uniform to an array of float32 (stored as matrices)
  30923. * @param uniform defines the webGL uniform location where to store the value
  30924. * @param matrices defines the array of float32 to store
  30925. */
  30926. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30927. /**
  30928. * Set the value of an uniform to a matrix (3x3)
  30929. * @param uniform defines the webGL uniform location where to store the value
  30930. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30931. */
  30932. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30933. /**
  30934. * Set the value of an uniform to a matrix (2x2)
  30935. * @param uniform defines the webGL uniform location where to store the value
  30936. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30937. */
  30938. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30939. /**
  30940. * Set the value of an uniform to a number (float)
  30941. * @param uniform defines the webGL uniform location where to store the value
  30942. * @param value defines the float number to store
  30943. */
  30944. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30945. /**
  30946. * Set the value of an uniform to a vec2
  30947. * @param uniform defines the webGL uniform location where to store the value
  30948. * @param x defines the 1st component of the value
  30949. * @param y defines the 2nd component of the value
  30950. */
  30951. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30952. /**
  30953. * Set the value of an uniform to a vec3
  30954. * @param uniform defines the webGL uniform location where to store the value
  30955. * @param x defines the 1st component of the value
  30956. * @param y defines the 2nd component of the value
  30957. * @param z defines the 3rd component of the value
  30958. */
  30959. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30960. /**
  30961. * Set the value of an uniform to a vec4
  30962. * @param uniform defines the webGL uniform location where to store the value
  30963. * @param x defines the 1st component of the value
  30964. * @param y defines the 2nd component of the value
  30965. * @param z defines the 3rd component of the value
  30966. * @param w defines the 4th component of the value
  30967. */
  30968. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30969. /**
  30970. * Gets the depth culling state manager
  30971. */
  30972. readonly depthCullingState: DepthCullingState;
  30973. /**
  30974. * Gets the alpha state manager
  30975. */
  30976. readonly alphaState: AlphaState;
  30977. /**
  30978. * Gets the stencil state manager
  30979. */
  30980. readonly stencilState: StencilState;
  30981. /**
  30982. * Clears the list of texture accessible through engine.
  30983. * This can help preventing texture load conflict due to name collision.
  30984. */
  30985. clearInternalTexturesCache(): void;
  30986. /**
  30987. * Force the entire cache to be cleared
  30988. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30989. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30990. */
  30991. wipeCaches(bruteForce?: boolean): void;
  30992. /** @hidden */
  30993. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30994. min: number;
  30995. mag: number;
  30996. };
  30997. /** @hidden */
  30998. _createTexture(): WebGLTexture;
  30999. /**
  31000. * Usually called from Texture.ts.
  31001. * Passed information to create a WebGLTexture
  31002. * @param urlArg defines a value which contains one of the following:
  31003. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31004. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31005. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31006. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31007. * @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)
  31008. * @param scene needed for loading to the correct scene
  31009. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31010. * @param onLoad optional callback to be called upon successful completion
  31011. * @param onError optional callback to be called upon failure
  31012. * @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
  31013. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31014. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31015. * @param forcedExtension defines the extension to use to pick the right loader
  31016. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31017. * @param mimeType defines an optional mime type
  31018. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31019. */
  31020. 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;
  31021. /**
  31022. * @hidden
  31023. */
  31024. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31025. /**
  31026. * Creates a raw texture
  31027. * @param data defines the data to store in the texture
  31028. * @param width defines the width of the texture
  31029. * @param height defines the height of the texture
  31030. * @param format defines the format of the data
  31031. * @param generateMipMaps defines if the engine should generate the mip levels
  31032. * @param invertY defines if data must be stored with Y axis inverted
  31033. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31034. * @param compression defines the compression used (null by default)
  31035. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31036. * @returns the raw texture inside an InternalTexture
  31037. */
  31038. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31039. /**
  31040. * Creates a new raw cube texture
  31041. * @param data defines the array of data to use to create each face
  31042. * @param size defines the size of the textures
  31043. * @param format defines the format of the data
  31044. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31045. * @param generateMipMaps defines if the engine should generate the mip levels
  31046. * @param invertY defines if data must be stored with Y axis inverted
  31047. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31048. * @param compression defines the compression used (null by default)
  31049. * @returns the cube texture as an InternalTexture
  31050. */
  31051. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31052. /**
  31053. * Creates a new raw 3D texture
  31054. * @param data defines the data used to create the texture
  31055. * @param width defines the width of the texture
  31056. * @param height defines the height of the texture
  31057. * @param depth defines the depth of the texture
  31058. * @param format defines the format of the texture
  31059. * @param generateMipMaps defines if the engine must generate mip levels
  31060. * @param invertY defines if data must be stored with Y axis inverted
  31061. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31062. * @param compression defines the compressed used (can be null)
  31063. * @param textureType defines the compressed used (can be null)
  31064. * @returns a new raw 3D texture (stored in an InternalTexture)
  31065. */
  31066. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31067. /**
  31068. * Creates a new raw 2D array texture
  31069. * @param data defines the data used to create the texture
  31070. * @param width defines the width of the texture
  31071. * @param height defines the height of the texture
  31072. * @param depth defines the number of layers of the texture
  31073. * @param format defines the format of the texture
  31074. * @param generateMipMaps defines if the engine must generate mip levels
  31075. * @param invertY defines if data must be stored with Y axis inverted
  31076. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31077. * @param compression defines the compressed used (can be null)
  31078. * @param textureType defines the compressed used (can be null)
  31079. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31080. */
  31081. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31082. private _unpackFlipYCached;
  31083. /**
  31084. * In case you are sharing the context with other applications, it might
  31085. * be interested to not cache the unpack flip y state to ensure a consistent
  31086. * value would be set.
  31087. */
  31088. enableUnpackFlipYCached: boolean;
  31089. /** @hidden */
  31090. _unpackFlipY(value: boolean): void;
  31091. /** @hidden */
  31092. _getUnpackAlignement(): number;
  31093. /**
  31094. * Update the sampling mode of a given texture
  31095. * @param samplingMode defines the required sampling mode
  31096. * @param texture defines the texture to update
  31097. */
  31098. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31099. /** @hidden */
  31100. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31101. width: number;
  31102. height: number;
  31103. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31104. /** @hidden */
  31105. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31106. /** @hidden */
  31107. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31108. /** @hidden */
  31109. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31110. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31111. private _prepareWebGLTexture;
  31112. /** @hidden */
  31113. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31114. /** @hidden */
  31115. _releaseFramebufferObjects(texture: InternalTexture): void;
  31116. /** @hidden */
  31117. _releaseTexture(texture: InternalTexture): void;
  31118. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31119. protected _setProgram(program: WebGLProgram): void;
  31120. protected _boundUniforms: {
  31121. [key: number]: WebGLUniformLocation;
  31122. };
  31123. /**
  31124. * Binds an effect to the webGL context
  31125. * @param effect defines the effect to bind
  31126. */
  31127. bindSamplers(effect: Effect): void;
  31128. private _activateCurrentTexture;
  31129. /** @hidden */
  31130. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31131. /** @hidden */
  31132. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31133. /**
  31134. * Unbind all textures from the webGL context
  31135. */
  31136. unbindAllTextures(): void;
  31137. /**
  31138. * Sets a texture to the according uniform.
  31139. * @param channel The texture channel
  31140. * @param uniform The uniform to set
  31141. * @param texture The texture to apply
  31142. */
  31143. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31144. private _bindSamplerUniformToChannel;
  31145. private _getTextureWrapMode;
  31146. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31147. /**
  31148. * Sets an array of texture to the webGL context
  31149. * @param channel defines the channel where the texture array must be set
  31150. * @param uniform defines the associated uniform location
  31151. * @param textures defines the array of textures to bind
  31152. */
  31153. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31154. /** @hidden */
  31155. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31156. private _setTextureParameterFloat;
  31157. private _setTextureParameterInteger;
  31158. /**
  31159. * Unbind all vertex attributes from the webGL context
  31160. */
  31161. unbindAllAttributes(): void;
  31162. /**
  31163. * 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
  31164. */
  31165. releaseEffects(): void;
  31166. /**
  31167. * Dispose and release all associated resources
  31168. */
  31169. dispose(): void;
  31170. /**
  31171. * Attach a new callback raised when context lost event is fired
  31172. * @param callback defines the callback to call
  31173. */
  31174. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31175. /**
  31176. * Attach a new callback raised when context restored event is fired
  31177. * @param callback defines the callback to call
  31178. */
  31179. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31180. /**
  31181. * Get the current error code of the webGL context
  31182. * @returns the error code
  31183. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31184. */
  31185. getError(): number;
  31186. private _canRenderToFloatFramebuffer;
  31187. private _canRenderToHalfFloatFramebuffer;
  31188. private _canRenderToFramebuffer;
  31189. /** @hidden */
  31190. _getWebGLTextureType(type: number): number;
  31191. /** @hidden */
  31192. _getInternalFormat(format: number): number;
  31193. /** @hidden */
  31194. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31195. /** @hidden */
  31196. _getRGBAMultiSampleBufferFormat(type: number): number;
  31197. /** @hidden */
  31198. _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;
  31199. /**
  31200. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31201. * @returns true if the engine can be created
  31202. * @ignorenaming
  31203. */
  31204. static isSupported(): boolean;
  31205. /**
  31206. * Find the next highest power of two.
  31207. * @param x Number to start search from.
  31208. * @return Next highest power of two.
  31209. */
  31210. static CeilingPOT(x: number): number;
  31211. /**
  31212. * Find the next lowest power of two.
  31213. * @param x Number to start search from.
  31214. * @return Next lowest power of two.
  31215. */
  31216. static FloorPOT(x: number): number;
  31217. /**
  31218. * Find the nearest power of two.
  31219. * @param x Number to start search from.
  31220. * @return Next nearest power of two.
  31221. */
  31222. static NearestPOT(x: number): number;
  31223. /**
  31224. * Get the closest exponent of two
  31225. * @param value defines the value to approximate
  31226. * @param max defines the maximum value to return
  31227. * @param mode defines how to define the closest value
  31228. * @returns closest exponent of two of the given value
  31229. */
  31230. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31231. /**
  31232. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31233. * @param func - the function to be called
  31234. * @param requester - the object that will request the next frame. Falls back to window.
  31235. * @returns frame number
  31236. */
  31237. static QueueNewFrame(func: () => void, requester?: any): number;
  31238. }
  31239. }
  31240. declare module "babylonjs/Maths/sphericalPolynomial" {
  31241. import { Vector3 } from "babylonjs/Maths/math.vector";
  31242. import { Color3 } from "babylonjs/Maths/math.color";
  31243. /**
  31244. * Class representing spherical harmonics coefficients to the 3rd degree
  31245. */
  31246. export class SphericalHarmonics {
  31247. /**
  31248. * Defines whether or not the harmonics have been prescaled for rendering.
  31249. */
  31250. preScaled: boolean;
  31251. /**
  31252. * The l0,0 coefficients of the spherical harmonics
  31253. */
  31254. l00: Vector3;
  31255. /**
  31256. * The l1,-1 coefficients of the spherical harmonics
  31257. */
  31258. l1_1: Vector3;
  31259. /**
  31260. * The l1,0 coefficients of the spherical harmonics
  31261. */
  31262. l10: Vector3;
  31263. /**
  31264. * The l1,1 coefficients of the spherical harmonics
  31265. */
  31266. l11: Vector3;
  31267. /**
  31268. * The l2,-2 coefficients of the spherical harmonics
  31269. */
  31270. l2_2: Vector3;
  31271. /**
  31272. * The l2,-1 coefficients of the spherical harmonics
  31273. */
  31274. l2_1: Vector3;
  31275. /**
  31276. * The l2,0 coefficients of the spherical harmonics
  31277. */
  31278. l20: Vector3;
  31279. /**
  31280. * The l2,1 coefficients of the spherical harmonics
  31281. */
  31282. l21: Vector3;
  31283. /**
  31284. * The l2,2 coefficients of the spherical harmonics
  31285. */
  31286. l22: Vector3;
  31287. /**
  31288. * Adds a light to the spherical harmonics
  31289. * @param direction the direction of the light
  31290. * @param color the color of the light
  31291. * @param deltaSolidAngle the delta solid angle of the light
  31292. */
  31293. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31294. /**
  31295. * Scales the spherical harmonics by the given amount
  31296. * @param scale the amount to scale
  31297. */
  31298. scaleInPlace(scale: number): void;
  31299. /**
  31300. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31301. *
  31302. * ```
  31303. * E_lm = A_l * L_lm
  31304. * ```
  31305. *
  31306. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31307. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31308. * the scaling factors are given in equation 9.
  31309. */
  31310. convertIncidentRadianceToIrradiance(): void;
  31311. /**
  31312. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31313. *
  31314. * ```
  31315. * L = (1/pi) * E * rho
  31316. * ```
  31317. *
  31318. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31319. */
  31320. convertIrradianceToLambertianRadiance(): void;
  31321. /**
  31322. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31323. * required operations at run time.
  31324. *
  31325. * This is simply done by scaling back the SH with Ylm constants parameter.
  31326. * The trigonometric part being applied by the shader at run time.
  31327. */
  31328. preScaleForRendering(): void;
  31329. /**
  31330. * Constructs a spherical harmonics from an array.
  31331. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31332. * @returns the spherical harmonics
  31333. */
  31334. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31335. /**
  31336. * Gets the spherical harmonics from polynomial
  31337. * @param polynomial the spherical polynomial
  31338. * @returns the spherical harmonics
  31339. */
  31340. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31341. }
  31342. /**
  31343. * Class representing spherical polynomial coefficients to the 3rd degree
  31344. */
  31345. export class SphericalPolynomial {
  31346. private _harmonics;
  31347. /**
  31348. * The spherical harmonics used to create the polynomials.
  31349. */
  31350. readonly preScaledHarmonics: SphericalHarmonics;
  31351. /**
  31352. * The x coefficients of the spherical polynomial
  31353. */
  31354. x: Vector3;
  31355. /**
  31356. * The y coefficients of the spherical polynomial
  31357. */
  31358. y: Vector3;
  31359. /**
  31360. * The z coefficients of the spherical polynomial
  31361. */
  31362. z: Vector3;
  31363. /**
  31364. * The xx coefficients of the spherical polynomial
  31365. */
  31366. xx: Vector3;
  31367. /**
  31368. * The yy coefficients of the spherical polynomial
  31369. */
  31370. yy: Vector3;
  31371. /**
  31372. * The zz coefficients of the spherical polynomial
  31373. */
  31374. zz: Vector3;
  31375. /**
  31376. * The xy coefficients of the spherical polynomial
  31377. */
  31378. xy: Vector3;
  31379. /**
  31380. * The yz coefficients of the spherical polynomial
  31381. */
  31382. yz: Vector3;
  31383. /**
  31384. * The zx coefficients of the spherical polynomial
  31385. */
  31386. zx: Vector3;
  31387. /**
  31388. * Adds an ambient color to the spherical polynomial
  31389. * @param color the color to add
  31390. */
  31391. addAmbient(color: Color3): void;
  31392. /**
  31393. * Scales the spherical polynomial by the given amount
  31394. * @param scale the amount to scale
  31395. */
  31396. scaleInPlace(scale: number): void;
  31397. /**
  31398. * Gets the spherical polynomial from harmonics
  31399. * @param harmonics the spherical harmonics
  31400. * @returns the spherical polynomial
  31401. */
  31402. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31403. /**
  31404. * Constructs a spherical polynomial from an array.
  31405. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31406. * @returns the spherical polynomial
  31407. */
  31408. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31409. }
  31410. }
  31411. declare module "babylonjs/Materials/Textures/internalTexture" {
  31412. import { Observable } from "babylonjs/Misc/observable";
  31413. import { Nullable, int } from "babylonjs/types";
  31414. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31415. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31416. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31417. /**
  31418. * Defines the source of the internal texture
  31419. */
  31420. export enum InternalTextureSource {
  31421. /**
  31422. * The source of the texture data is unknown
  31423. */
  31424. Unknown = 0,
  31425. /**
  31426. * Texture data comes from an URL
  31427. */
  31428. Url = 1,
  31429. /**
  31430. * Texture data is only used for temporary storage
  31431. */
  31432. Temp = 2,
  31433. /**
  31434. * Texture data comes from raw data (ArrayBuffer)
  31435. */
  31436. Raw = 3,
  31437. /**
  31438. * Texture content is dynamic (video or dynamic texture)
  31439. */
  31440. Dynamic = 4,
  31441. /**
  31442. * Texture content is generated by rendering to it
  31443. */
  31444. RenderTarget = 5,
  31445. /**
  31446. * Texture content is part of a multi render target process
  31447. */
  31448. MultiRenderTarget = 6,
  31449. /**
  31450. * Texture data comes from a cube data file
  31451. */
  31452. Cube = 7,
  31453. /**
  31454. * Texture data comes from a raw cube data
  31455. */
  31456. CubeRaw = 8,
  31457. /**
  31458. * Texture data come from a prefiltered cube data file
  31459. */
  31460. CubePrefiltered = 9,
  31461. /**
  31462. * Texture content is raw 3D data
  31463. */
  31464. Raw3D = 10,
  31465. /**
  31466. * Texture content is raw 2D array data
  31467. */
  31468. Raw2DArray = 11,
  31469. /**
  31470. * Texture content is a depth texture
  31471. */
  31472. Depth = 12,
  31473. /**
  31474. * Texture data comes from a raw cube data encoded with RGBD
  31475. */
  31476. CubeRawRGBD = 13
  31477. }
  31478. /**
  31479. * Class used to store data associated with WebGL texture data for the engine
  31480. * This class should not be used directly
  31481. */
  31482. export class InternalTexture {
  31483. /** @hidden */
  31484. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31485. /**
  31486. * Defines if the texture is ready
  31487. */
  31488. isReady: boolean;
  31489. /**
  31490. * Defines if the texture is a cube texture
  31491. */
  31492. isCube: boolean;
  31493. /**
  31494. * Defines if the texture contains 3D data
  31495. */
  31496. is3D: boolean;
  31497. /**
  31498. * Defines if the texture contains 2D array data
  31499. */
  31500. is2DArray: boolean;
  31501. /**
  31502. * Defines if the texture contains multiview data
  31503. */
  31504. isMultiview: boolean;
  31505. /**
  31506. * Gets the URL used to load this texture
  31507. */
  31508. url: string;
  31509. /**
  31510. * Gets the sampling mode of the texture
  31511. */
  31512. samplingMode: number;
  31513. /**
  31514. * Gets a boolean indicating if the texture needs mipmaps generation
  31515. */
  31516. generateMipMaps: boolean;
  31517. /**
  31518. * Gets the number of samples used by the texture (WebGL2+ only)
  31519. */
  31520. samples: number;
  31521. /**
  31522. * Gets the type of the texture (int, float...)
  31523. */
  31524. type: number;
  31525. /**
  31526. * Gets the format of the texture (RGB, RGBA...)
  31527. */
  31528. format: number;
  31529. /**
  31530. * Observable called when the texture is loaded
  31531. */
  31532. onLoadedObservable: Observable<InternalTexture>;
  31533. /**
  31534. * Gets the width of the texture
  31535. */
  31536. width: number;
  31537. /**
  31538. * Gets the height of the texture
  31539. */
  31540. height: number;
  31541. /**
  31542. * Gets the depth of the texture
  31543. */
  31544. depth: number;
  31545. /**
  31546. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31547. */
  31548. baseWidth: number;
  31549. /**
  31550. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31551. */
  31552. baseHeight: number;
  31553. /**
  31554. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31555. */
  31556. baseDepth: number;
  31557. /**
  31558. * Gets a boolean indicating if the texture is inverted on Y axis
  31559. */
  31560. invertY: boolean;
  31561. /** @hidden */
  31562. _invertVScale: boolean;
  31563. /** @hidden */
  31564. _associatedChannel: number;
  31565. /** @hidden */
  31566. _source: InternalTextureSource;
  31567. /** @hidden */
  31568. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31569. /** @hidden */
  31570. _bufferView: Nullable<ArrayBufferView>;
  31571. /** @hidden */
  31572. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31573. /** @hidden */
  31574. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31575. /** @hidden */
  31576. _size: number;
  31577. /** @hidden */
  31578. _extension: string;
  31579. /** @hidden */
  31580. _files: Nullable<string[]>;
  31581. /** @hidden */
  31582. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31583. /** @hidden */
  31584. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31585. /** @hidden */
  31586. _framebuffer: Nullable<WebGLFramebuffer>;
  31587. /** @hidden */
  31588. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31589. /** @hidden */
  31590. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31591. /** @hidden */
  31592. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31593. /** @hidden */
  31594. _attachments: Nullable<number[]>;
  31595. /** @hidden */
  31596. _cachedCoordinatesMode: Nullable<number>;
  31597. /** @hidden */
  31598. _cachedWrapU: Nullable<number>;
  31599. /** @hidden */
  31600. _cachedWrapV: Nullable<number>;
  31601. /** @hidden */
  31602. _cachedWrapR: Nullable<number>;
  31603. /** @hidden */
  31604. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31605. /** @hidden */
  31606. _isDisabled: boolean;
  31607. /** @hidden */
  31608. _compression: Nullable<string>;
  31609. /** @hidden */
  31610. _generateStencilBuffer: boolean;
  31611. /** @hidden */
  31612. _generateDepthBuffer: boolean;
  31613. /** @hidden */
  31614. _comparisonFunction: number;
  31615. /** @hidden */
  31616. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31617. /** @hidden */
  31618. _lodGenerationScale: number;
  31619. /** @hidden */
  31620. _lodGenerationOffset: number;
  31621. /** @hidden */
  31622. _colorTextureArray: Nullable<WebGLTexture>;
  31623. /** @hidden */
  31624. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31625. /** @hidden */
  31626. _lodTextureHigh: Nullable<BaseTexture>;
  31627. /** @hidden */
  31628. _lodTextureMid: Nullable<BaseTexture>;
  31629. /** @hidden */
  31630. _lodTextureLow: Nullable<BaseTexture>;
  31631. /** @hidden */
  31632. _isRGBD: boolean;
  31633. /** @hidden */
  31634. _linearSpecularLOD: boolean;
  31635. /** @hidden */
  31636. _irradianceTexture: Nullable<BaseTexture>;
  31637. /** @hidden */
  31638. _webGLTexture: Nullable<WebGLTexture>;
  31639. /** @hidden */
  31640. _references: number;
  31641. private _engine;
  31642. /**
  31643. * Gets the Engine the texture belongs to.
  31644. * @returns The babylon engine
  31645. */
  31646. getEngine(): ThinEngine;
  31647. /**
  31648. * Gets the data source type of the texture
  31649. */
  31650. readonly source: InternalTextureSource;
  31651. /**
  31652. * Creates a new InternalTexture
  31653. * @param engine defines the engine to use
  31654. * @param source defines the type of data that will be used
  31655. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31656. */
  31657. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31658. /**
  31659. * Increments the number of references (ie. the number of Texture that point to it)
  31660. */
  31661. incrementReferences(): void;
  31662. /**
  31663. * Change the size of the texture (not the size of the content)
  31664. * @param width defines the new width
  31665. * @param height defines the new height
  31666. * @param depth defines the new depth (1 by default)
  31667. */
  31668. updateSize(width: int, height: int, depth?: int): void;
  31669. /** @hidden */
  31670. _rebuild(): void;
  31671. /** @hidden */
  31672. _swapAndDie(target: InternalTexture): void;
  31673. /**
  31674. * Dispose the current allocated resources
  31675. */
  31676. dispose(): void;
  31677. }
  31678. }
  31679. declare module "babylonjs/Audio/analyser" {
  31680. import { Scene } from "babylonjs/scene";
  31681. /**
  31682. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31683. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31684. */
  31685. export class Analyser {
  31686. /**
  31687. * Gets or sets the smoothing
  31688. * @ignorenaming
  31689. */
  31690. SMOOTHING: number;
  31691. /**
  31692. * Gets or sets the FFT table size
  31693. * @ignorenaming
  31694. */
  31695. FFT_SIZE: number;
  31696. /**
  31697. * Gets or sets the bar graph amplitude
  31698. * @ignorenaming
  31699. */
  31700. BARGRAPHAMPLITUDE: number;
  31701. /**
  31702. * Gets or sets the position of the debug canvas
  31703. * @ignorenaming
  31704. */
  31705. DEBUGCANVASPOS: {
  31706. x: number;
  31707. y: number;
  31708. };
  31709. /**
  31710. * Gets or sets the debug canvas size
  31711. * @ignorenaming
  31712. */
  31713. DEBUGCANVASSIZE: {
  31714. width: number;
  31715. height: number;
  31716. };
  31717. private _byteFreqs;
  31718. private _byteTime;
  31719. private _floatFreqs;
  31720. private _webAudioAnalyser;
  31721. private _debugCanvas;
  31722. private _debugCanvasContext;
  31723. private _scene;
  31724. private _registerFunc;
  31725. private _audioEngine;
  31726. /**
  31727. * Creates a new analyser
  31728. * @param scene defines hosting scene
  31729. */
  31730. constructor(scene: Scene);
  31731. /**
  31732. * Get the number of data values you will have to play with for the visualization
  31733. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31734. * @returns a number
  31735. */
  31736. getFrequencyBinCount(): number;
  31737. /**
  31738. * Gets the current frequency data as a byte array
  31739. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31740. * @returns a Uint8Array
  31741. */
  31742. getByteFrequencyData(): Uint8Array;
  31743. /**
  31744. * Gets the current waveform as a byte array
  31745. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31746. * @returns a Uint8Array
  31747. */
  31748. getByteTimeDomainData(): Uint8Array;
  31749. /**
  31750. * Gets the current frequency data as a float array
  31751. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31752. * @returns a Float32Array
  31753. */
  31754. getFloatFrequencyData(): Float32Array;
  31755. /**
  31756. * Renders the debug canvas
  31757. */
  31758. drawDebugCanvas(): void;
  31759. /**
  31760. * Stops rendering the debug canvas and removes it
  31761. */
  31762. stopDebugCanvas(): void;
  31763. /**
  31764. * Connects two audio nodes
  31765. * @param inputAudioNode defines first node to connect
  31766. * @param outputAudioNode defines second node to connect
  31767. */
  31768. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31769. /**
  31770. * Releases all associated resources
  31771. */
  31772. dispose(): void;
  31773. }
  31774. }
  31775. declare module "babylonjs/Audio/audioEngine" {
  31776. import { IDisposable } from "babylonjs/scene";
  31777. import { Analyser } from "babylonjs/Audio/analyser";
  31778. import { Nullable } from "babylonjs/types";
  31779. import { Observable } from "babylonjs/Misc/observable";
  31780. /**
  31781. * This represents an audio engine and it is responsible
  31782. * to play, synchronize and analyse sounds throughout the application.
  31783. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31784. */
  31785. export interface IAudioEngine extends IDisposable {
  31786. /**
  31787. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31788. */
  31789. readonly canUseWebAudio: boolean;
  31790. /**
  31791. * Gets the current AudioContext if available.
  31792. */
  31793. readonly audioContext: Nullable<AudioContext>;
  31794. /**
  31795. * The master gain node defines the global audio volume of your audio engine.
  31796. */
  31797. readonly masterGain: GainNode;
  31798. /**
  31799. * Gets whether or not mp3 are supported by your browser.
  31800. */
  31801. readonly isMP3supported: boolean;
  31802. /**
  31803. * Gets whether or not ogg are supported by your browser.
  31804. */
  31805. readonly isOGGsupported: boolean;
  31806. /**
  31807. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31808. * @ignoreNaming
  31809. */
  31810. WarnedWebAudioUnsupported: boolean;
  31811. /**
  31812. * Defines if the audio engine relies on a custom unlocked button.
  31813. * In this case, the embedded button will not be displayed.
  31814. */
  31815. useCustomUnlockedButton: boolean;
  31816. /**
  31817. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31818. */
  31819. readonly unlocked: boolean;
  31820. /**
  31821. * Event raised when audio has been unlocked on the browser.
  31822. */
  31823. onAudioUnlockedObservable: Observable<AudioEngine>;
  31824. /**
  31825. * Event raised when audio has been locked on the browser.
  31826. */
  31827. onAudioLockedObservable: Observable<AudioEngine>;
  31828. /**
  31829. * Flags the audio engine in Locked state.
  31830. * This happens due to new browser policies preventing audio to autoplay.
  31831. */
  31832. lock(): void;
  31833. /**
  31834. * Unlocks the audio engine once a user action has been done on the dom.
  31835. * This is helpful to resume play once browser policies have been satisfied.
  31836. */
  31837. unlock(): void;
  31838. }
  31839. /**
  31840. * This represents the default audio engine used in babylon.
  31841. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31843. */
  31844. export class AudioEngine implements IAudioEngine {
  31845. private _audioContext;
  31846. private _audioContextInitialized;
  31847. private _muteButton;
  31848. private _hostElement;
  31849. /**
  31850. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31851. */
  31852. canUseWebAudio: boolean;
  31853. /**
  31854. * The master gain node defines the global audio volume of your audio engine.
  31855. */
  31856. masterGain: GainNode;
  31857. /**
  31858. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31859. * @ignoreNaming
  31860. */
  31861. WarnedWebAudioUnsupported: boolean;
  31862. /**
  31863. * Gets whether or not mp3 are supported by your browser.
  31864. */
  31865. isMP3supported: boolean;
  31866. /**
  31867. * Gets whether or not ogg are supported by your browser.
  31868. */
  31869. isOGGsupported: boolean;
  31870. /**
  31871. * Gets whether audio has been unlocked on the device.
  31872. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31873. * a user interaction has happened.
  31874. */
  31875. unlocked: boolean;
  31876. /**
  31877. * Defines if the audio engine relies on a custom unlocked button.
  31878. * In this case, the embedded button will not be displayed.
  31879. */
  31880. useCustomUnlockedButton: boolean;
  31881. /**
  31882. * Event raised when audio has been unlocked on the browser.
  31883. */
  31884. onAudioUnlockedObservable: Observable<AudioEngine>;
  31885. /**
  31886. * Event raised when audio has been locked on the browser.
  31887. */
  31888. onAudioLockedObservable: Observable<AudioEngine>;
  31889. /**
  31890. * Gets the current AudioContext if available.
  31891. */
  31892. readonly audioContext: Nullable<AudioContext>;
  31893. private _connectedAnalyser;
  31894. /**
  31895. * Instantiates a new audio engine.
  31896. *
  31897. * There should be only one per page as some browsers restrict the number
  31898. * of audio contexts you can create.
  31899. * @param hostElement defines the host element where to display the mute icon if necessary
  31900. */
  31901. constructor(hostElement?: Nullable<HTMLElement>);
  31902. /**
  31903. * Flags the audio engine in Locked state.
  31904. * This happens due to new browser policies preventing audio to autoplay.
  31905. */
  31906. lock(): void;
  31907. /**
  31908. * Unlocks the audio engine once a user action has been done on the dom.
  31909. * This is helpful to resume play once browser policies have been satisfied.
  31910. */
  31911. unlock(): void;
  31912. private _resumeAudioContext;
  31913. private _initializeAudioContext;
  31914. private _tryToRun;
  31915. private _triggerRunningState;
  31916. private _triggerSuspendedState;
  31917. private _displayMuteButton;
  31918. private _moveButtonToTopLeft;
  31919. private _onResize;
  31920. private _hideMuteButton;
  31921. /**
  31922. * Destroy and release the resources associated with the audio ccontext.
  31923. */
  31924. dispose(): void;
  31925. /**
  31926. * Gets the global volume sets on the master gain.
  31927. * @returns the global volume if set or -1 otherwise
  31928. */
  31929. getGlobalVolume(): number;
  31930. /**
  31931. * Sets the global volume of your experience (sets on the master gain).
  31932. * @param newVolume Defines the new global volume of the application
  31933. */
  31934. setGlobalVolume(newVolume: number): void;
  31935. /**
  31936. * Connect the audio engine to an audio analyser allowing some amazing
  31937. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31939. * @param analyser The analyser to connect to the engine
  31940. */
  31941. connectToAnalyser(analyser: Analyser): void;
  31942. }
  31943. }
  31944. declare module "babylonjs/Loading/loadingScreen" {
  31945. /**
  31946. * Interface used to present a loading screen while loading a scene
  31947. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31948. */
  31949. export interface ILoadingScreen {
  31950. /**
  31951. * Function called to display the loading screen
  31952. */
  31953. displayLoadingUI: () => void;
  31954. /**
  31955. * Function called to hide the loading screen
  31956. */
  31957. hideLoadingUI: () => void;
  31958. /**
  31959. * Gets or sets the color to use for the background
  31960. */
  31961. loadingUIBackgroundColor: string;
  31962. /**
  31963. * Gets or sets the text to display while loading
  31964. */
  31965. loadingUIText: string;
  31966. }
  31967. /**
  31968. * Class used for the default loading screen
  31969. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31970. */
  31971. export class DefaultLoadingScreen implements ILoadingScreen {
  31972. private _renderingCanvas;
  31973. private _loadingText;
  31974. private _loadingDivBackgroundColor;
  31975. private _loadingDiv;
  31976. private _loadingTextDiv;
  31977. /** Gets or sets the logo url to use for the default loading screen */
  31978. static DefaultLogoUrl: string;
  31979. /** Gets or sets the spinner url to use for the default loading screen */
  31980. static DefaultSpinnerUrl: string;
  31981. /**
  31982. * Creates a new default loading screen
  31983. * @param _renderingCanvas defines the canvas used to render the scene
  31984. * @param _loadingText defines the default text to display
  31985. * @param _loadingDivBackgroundColor defines the default background color
  31986. */
  31987. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31988. /**
  31989. * Function called to display the loading screen
  31990. */
  31991. displayLoadingUI(): void;
  31992. /**
  31993. * Function called to hide the loading screen
  31994. */
  31995. hideLoadingUI(): void;
  31996. /**
  31997. * Gets or sets the text to display while loading
  31998. */
  31999. loadingUIText: string;
  32000. /**
  32001. * Gets or sets the color to use for the background
  32002. */
  32003. loadingUIBackgroundColor: string;
  32004. private _resizeLoadingUI;
  32005. }
  32006. }
  32007. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  32008. /**
  32009. * Interface for any object that can request an animation frame
  32010. */
  32011. export interface ICustomAnimationFrameRequester {
  32012. /**
  32013. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32014. */
  32015. renderFunction?: Function;
  32016. /**
  32017. * Called to request the next frame to render to
  32018. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32019. */
  32020. requestAnimationFrame: Function;
  32021. /**
  32022. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32023. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32024. */
  32025. requestID?: number;
  32026. }
  32027. }
  32028. declare module "babylonjs/Misc/performanceMonitor" {
  32029. /**
  32030. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32031. */
  32032. export class PerformanceMonitor {
  32033. private _enabled;
  32034. private _rollingFrameTime;
  32035. private _lastFrameTimeMs;
  32036. /**
  32037. * constructor
  32038. * @param frameSampleSize The number of samples required to saturate the sliding window
  32039. */
  32040. constructor(frameSampleSize?: number);
  32041. /**
  32042. * Samples current frame
  32043. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32044. */
  32045. sampleFrame(timeMs?: number): void;
  32046. /**
  32047. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32048. */
  32049. readonly averageFrameTime: number;
  32050. /**
  32051. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32052. */
  32053. readonly averageFrameTimeVariance: number;
  32054. /**
  32055. * Returns the frame time of the most recent frame
  32056. */
  32057. readonly instantaneousFrameTime: number;
  32058. /**
  32059. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32060. */
  32061. readonly averageFPS: number;
  32062. /**
  32063. * Returns the average framerate in frames per second using the most recent frame time
  32064. */
  32065. readonly instantaneousFPS: number;
  32066. /**
  32067. * Returns true if enough samples have been taken to completely fill the sliding window
  32068. */
  32069. readonly isSaturated: boolean;
  32070. /**
  32071. * Enables contributions to the sliding window sample set
  32072. */
  32073. enable(): void;
  32074. /**
  32075. * Disables contributions to the sliding window sample set
  32076. * Samples will not be interpolated over the disabled period
  32077. */
  32078. disable(): void;
  32079. /**
  32080. * Returns true if sampling is enabled
  32081. */
  32082. readonly isEnabled: boolean;
  32083. /**
  32084. * Resets performance monitor
  32085. */
  32086. reset(): void;
  32087. }
  32088. /**
  32089. * RollingAverage
  32090. *
  32091. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32092. */
  32093. export class RollingAverage {
  32094. /**
  32095. * Current average
  32096. */
  32097. average: number;
  32098. /**
  32099. * Current variance
  32100. */
  32101. variance: number;
  32102. protected _samples: Array<number>;
  32103. protected _sampleCount: number;
  32104. protected _pos: number;
  32105. protected _m2: number;
  32106. /**
  32107. * constructor
  32108. * @param length The number of samples required to saturate the sliding window
  32109. */
  32110. constructor(length: number);
  32111. /**
  32112. * Adds a sample to the sample set
  32113. * @param v The sample value
  32114. */
  32115. add(v: number): void;
  32116. /**
  32117. * Returns previously added values or null if outside of history or outside the sliding window domain
  32118. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32119. * @return Value previously recorded with add() or null if outside of range
  32120. */
  32121. history(i: number): number;
  32122. /**
  32123. * Returns true if enough samples have been taken to completely fill the sliding window
  32124. * @return true if sample-set saturated
  32125. */
  32126. isSaturated(): boolean;
  32127. /**
  32128. * Resets the rolling average (equivalent to 0 samples taken so far)
  32129. */
  32130. reset(): void;
  32131. /**
  32132. * Wraps a value around the sample range boundaries
  32133. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32134. * @return Wrapped position in sample range
  32135. */
  32136. protected _wrapPosition(i: number): number;
  32137. }
  32138. }
  32139. declare module "babylonjs/Misc/perfCounter" {
  32140. /**
  32141. * This class is used to track a performance counter which is number based.
  32142. * The user has access to many properties which give statistics of different nature.
  32143. *
  32144. * The implementer can track two kinds of Performance Counter: time and count.
  32145. * 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.
  32146. * 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.
  32147. */
  32148. export class PerfCounter {
  32149. /**
  32150. * Gets or sets a global boolean to turn on and off all the counters
  32151. */
  32152. static Enabled: boolean;
  32153. /**
  32154. * Returns the smallest value ever
  32155. */
  32156. readonly min: number;
  32157. /**
  32158. * Returns the biggest value ever
  32159. */
  32160. readonly max: number;
  32161. /**
  32162. * Returns the average value since the performance counter is running
  32163. */
  32164. readonly average: number;
  32165. /**
  32166. * Returns the average value of the last second the counter was monitored
  32167. */
  32168. readonly lastSecAverage: number;
  32169. /**
  32170. * Returns the current value
  32171. */
  32172. readonly current: number;
  32173. /**
  32174. * Gets the accumulated total
  32175. */
  32176. readonly total: number;
  32177. /**
  32178. * Gets the total value count
  32179. */
  32180. readonly count: number;
  32181. /**
  32182. * Creates a new counter
  32183. */
  32184. constructor();
  32185. /**
  32186. * Call this method to start monitoring a new frame.
  32187. * 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.
  32188. */
  32189. fetchNewFrame(): void;
  32190. /**
  32191. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32192. * @param newCount the count value to add to the monitored count
  32193. * @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.
  32194. */
  32195. addCount(newCount: number, fetchResult: boolean): void;
  32196. /**
  32197. * Start monitoring this performance counter
  32198. */
  32199. beginMonitoring(): void;
  32200. /**
  32201. * Compute the time lapsed since the previous beginMonitoring() call.
  32202. * @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
  32203. */
  32204. endMonitoring(newFrame?: boolean): void;
  32205. private _fetchResult;
  32206. private _startMonitoringTime;
  32207. private _min;
  32208. private _max;
  32209. private _average;
  32210. private _current;
  32211. private _totalValueCount;
  32212. private _totalAccumulated;
  32213. private _lastSecAverage;
  32214. private _lastSecAccumulated;
  32215. private _lastSecTime;
  32216. private _lastSecValueCount;
  32217. }
  32218. }
  32219. declare module "babylonjs/Engines/engine" {
  32220. import { Observable } from "babylonjs/Misc/observable";
  32221. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  32222. import { Scene } from "babylonjs/scene";
  32223. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32224. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  32225. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32226. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  32227. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32228. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32229. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  32230. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  32231. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32232. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32233. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  32234. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32235. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  32236. import { Material } from "babylonjs/Materials/material";
  32237. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32238. /**
  32239. * Defines the interface used by display changed events
  32240. */
  32241. export interface IDisplayChangedEventArgs {
  32242. /** Gets the vrDisplay object (if any) */
  32243. vrDisplay: Nullable<any>;
  32244. /** Gets a boolean indicating if webVR is supported */
  32245. vrSupported: boolean;
  32246. }
  32247. /**
  32248. * Defines the interface used by objects containing a viewport (like a camera)
  32249. */
  32250. interface IViewportOwnerLike {
  32251. /**
  32252. * Gets or sets the viewport
  32253. */
  32254. viewport: IViewportLike;
  32255. }
  32256. /**
  32257. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32258. */
  32259. export class Engine extends ThinEngine {
  32260. /** Defines that alpha blending is disabled */
  32261. static readonly ALPHA_DISABLE: number;
  32262. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32263. static readonly ALPHA_ADD: number;
  32264. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32265. static readonly ALPHA_COMBINE: number;
  32266. /** Defines that alpha blending to DEST - SRC * DEST */
  32267. static readonly ALPHA_SUBTRACT: number;
  32268. /** Defines that alpha blending to SRC * DEST */
  32269. static readonly ALPHA_MULTIPLY: number;
  32270. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32271. static readonly ALPHA_MAXIMIZED: number;
  32272. /** Defines that alpha blending to SRC + DEST */
  32273. static readonly ALPHA_ONEONE: number;
  32274. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32275. static readonly ALPHA_PREMULTIPLIED: number;
  32276. /**
  32277. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32278. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32279. */
  32280. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32281. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32282. static readonly ALPHA_INTERPOLATE: number;
  32283. /**
  32284. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32285. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32286. */
  32287. static readonly ALPHA_SCREENMODE: number;
  32288. /** Defines that the ressource is not delayed*/
  32289. static readonly DELAYLOADSTATE_NONE: number;
  32290. /** Defines that the ressource was successfully delay loaded */
  32291. static readonly DELAYLOADSTATE_LOADED: number;
  32292. /** Defines that the ressource is currently delay loading */
  32293. static readonly DELAYLOADSTATE_LOADING: number;
  32294. /** Defines that the ressource is delayed and has not started loading */
  32295. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32296. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32297. static readonly NEVER: number;
  32298. /** 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 */
  32299. static readonly ALWAYS: number;
  32300. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32301. static readonly LESS: number;
  32302. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32303. static readonly EQUAL: number;
  32304. /** 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 */
  32305. static readonly LEQUAL: number;
  32306. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32307. static readonly GREATER: number;
  32308. /** 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 */
  32309. static readonly GEQUAL: number;
  32310. /** 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 */
  32311. static readonly NOTEQUAL: number;
  32312. /** Passed to stencilOperation to specify that stencil value must be kept */
  32313. static readonly KEEP: number;
  32314. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32315. static readonly REPLACE: number;
  32316. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32317. static readonly INCR: number;
  32318. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32319. static readonly DECR: number;
  32320. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32321. static readonly INVERT: number;
  32322. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32323. static readonly INCR_WRAP: number;
  32324. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32325. static readonly DECR_WRAP: number;
  32326. /** Texture is not repeating outside of 0..1 UVs */
  32327. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32328. /** Texture is repeating outside of 0..1 UVs */
  32329. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32330. /** Texture is repeating and mirrored */
  32331. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32332. /** ALPHA */
  32333. static readonly TEXTUREFORMAT_ALPHA: number;
  32334. /** LUMINANCE */
  32335. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32336. /** LUMINANCE_ALPHA */
  32337. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32338. /** RGB */
  32339. static readonly TEXTUREFORMAT_RGB: number;
  32340. /** RGBA */
  32341. static readonly TEXTUREFORMAT_RGBA: number;
  32342. /** RED */
  32343. static readonly TEXTUREFORMAT_RED: number;
  32344. /** RED (2nd reference) */
  32345. static readonly TEXTUREFORMAT_R: number;
  32346. /** RG */
  32347. static readonly TEXTUREFORMAT_RG: number;
  32348. /** RED_INTEGER */
  32349. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32350. /** RED_INTEGER (2nd reference) */
  32351. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32352. /** RG_INTEGER */
  32353. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32354. /** RGB_INTEGER */
  32355. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32356. /** RGBA_INTEGER */
  32357. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32358. /** UNSIGNED_BYTE */
  32359. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32360. /** UNSIGNED_BYTE (2nd reference) */
  32361. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32362. /** FLOAT */
  32363. static readonly TEXTURETYPE_FLOAT: number;
  32364. /** HALF_FLOAT */
  32365. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32366. /** BYTE */
  32367. static readonly TEXTURETYPE_BYTE: number;
  32368. /** SHORT */
  32369. static readonly TEXTURETYPE_SHORT: number;
  32370. /** UNSIGNED_SHORT */
  32371. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32372. /** INT */
  32373. static readonly TEXTURETYPE_INT: number;
  32374. /** UNSIGNED_INT */
  32375. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32376. /** UNSIGNED_SHORT_4_4_4_4 */
  32377. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32378. /** UNSIGNED_SHORT_5_5_5_1 */
  32379. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32380. /** UNSIGNED_SHORT_5_6_5 */
  32381. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32382. /** UNSIGNED_INT_2_10_10_10_REV */
  32383. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32384. /** UNSIGNED_INT_24_8 */
  32385. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32386. /** UNSIGNED_INT_10F_11F_11F_REV */
  32387. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32388. /** UNSIGNED_INT_5_9_9_9_REV */
  32389. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32390. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32391. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32392. /** nearest is mag = nearest and min = nearest and mip = linear */
  32393. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32394. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32395. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32396. /** Trilinear is mag = linear and min = linear and mip = linear */
  32397. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32398. /** nearest is mag = nearest and min = nearest and mip = linear */
  32399. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32400. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32401. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32402. /** Trilinear is mag = linear and min = linear and mip = linear */
  32403. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32404. /** mag = nearest and min = nearest and mip = nearest */
  32405. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32406. /** mag = nearest and min = linear and mip = nearest */
  32407. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32408. /** mag = nearest and min = linear and mip = linear */
  32409. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32410. /** mag = nearest and min = linear and mip = none */
  32411. static readonly TEXTURE_NEAREST_LINEAR: number;
  32412. /** mag = nearest and min = nearest and mip = none */
  32413. static readonly TEXTURE_NEAREST_NEAREST: number;
  32414. /** mag = linear and min = nearest and mip = nearest */
  32415. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32416. /** mag = linear and min = nearest and mip = linear */
  32417. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32418. /** mag = linear and min = linear and mip = none */
  32419. static readonly TEXTURE_LINEAR_LINEAR: number;
  32420. /** mag = linear and min = nearest and mip = none */
  32421. static readonly TEXTURE_LINEAR_NEAREST: number;
  32422. /** Explicit coordinates mode */
  32423. static readonly TEXTURE_EXPLICIT_MODE: number;
  32424. /** Spherical coordinates mode */
  32425. static readonly TEXTURE_SPHERICAL_MODE: number;
  32426. /** Planar coordinates mode */
  32427. static readonly TEXTURE_PLANAR_MODE: number;
  32428. /** Cubic coordinates mode */
  32429. static readonly TEXTURE_CUBIC_MODE: number;
  32430. /** Projection coordinates mode */
  32431. static readonly TEXTURE_PROJECTION_MODE: number;
  32432. /** Skybox coordinates mode */
  32433. static readonly TEXTURE_SKYBOX_MODE: number;
  32434. /** Inverse Cubic coordinates mode */
  32435. static readonly TEXTURE_INVCUBIC_MODE: number;
  32436. /** Equirectangular coordinates mode */
  32437. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32438. /** Equirectangular Fixed coordinates mode */
  32439. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32440. /** Equirectangular Fixed Mirrored coordinates mode */
  32441. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32442. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32443. static readonly SCALEMODE_FLOOR: number;
  32444. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32445. static readonly SCALEMODE_NEAREST: number;
  32446. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32447. static readonly SCALEMODE_CEILING: number;
  32448. /**
  32449. * Returns the current npm package of the sdk
  32450. */
  32451. static readonly NpmPackage: string;
  32452. /**
  32453. * Returns the current version of the framework
  32454. */
  32455. static readonly Version: string;
  32456. /** Gets the list of created engines */
  32457. static readonly Instances: Engine[];
  32458. /**
  32459. * Gets the latest created engine
  32460. */
  32461. static readonly LastCreatedEngine: Nullable<Engine>;
  32462. /**
  32463. * Gets the latest created scene
  32464. */
  32465. static readonly LastCreatedScene: Nullable<Scene>;
  32466. /**
  32467. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32468. * @param flag defines which part of the materials must be marked as dirty
  32469. * @param predicate defines a predicate used to filter which materials should be affected
  32470. */
  32471. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32472. /**
  32473. * Method called to create the default loading screen.
  32474. * This can be overriden in your own app.
  32475. * @param canvas The rendering canvas element
  32476. * @returns The loading screen
  32477. */
  32478. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32479. /**
  32480. * Method called to create the default rescale post process on each engine.
  32481. */
  32482. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32483. /**
  32484. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32485. **/
  32486. enableOfflineSupport: boolean;
  32487. /**
  32488. * 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)
  32489. **/
  32490. disableManifestCheck: boolean;
  32491. /**
  32492. * Gets the list of created scenes
  32493. */
  32494. scenes: Scene[];
  32495. /**
  32496. * Event raised when a new scene is created
  32497. */
  32498. onNewSceneAddedObservable: Observable<Scene>;
  32499. /**
  32500. * Gets the list of created postprocesses
  32501. */
  32502. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32503. /**
  32504. * Gets a boolean indicating if the pointer is currently locked
  32505. */
  32506. isPointerLock: boolean;
  32507. /**
  32508. * Observable event triggered each time the rendering canvas is resized
  32509. */
  32510. onResizeObservable: Observable<Engine>;
  32511. /**
  32512. * Observable event triggered each time the canvas loses focus
  32513. */
  32514. onCanvasBlurObservable: Observable<Engine>;
  32515. /**
  32516. * Observable event triggered each time the canvas gains focus
  32517. */
  32518. onCanvasFocusObservable: Observable<Engine>;
  32519. /**
  32520. * Observable event triggered each time the canvas receives pointerout event
  32521. */
  32522. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32523. /**
  32524. * Observable raised when the engine begins a new frame
  32525. */
  32526. onBeginFrameObservable: Observable<Engine>;
  32527. /**
  32528. * If set, will be used to request the next animation frame for the render loop
  32529. */
  32530. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32531. /**
  32532. * Observable raised when the engine ends the current frame
  32533. */
  32534. onEndFrameObservable: Observable<Engine>;
  32535. /**
  32536. * Observable raised when the engine is about to compile a shader
  32537. */
  32538. onBeforeShaderCompilationObservable: Observable<Engine>;
  32539. /**
  32540. * Observable raised when the engine has jsut compiled a shader
  32541. */
  32542. onAfterShaderCompilationObservable: Observable<Engine>;
  32543. /**
  32544. * Gets the audio engine
  32545. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32546. * @ignorenaming
  32547. */
  32548. static audioEngine: IAudioEngine;
  32549. /**
  32550. * Default AudioEngine factory responsible of creating the Audio Engine.
  32551. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32552. */
  32553. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32554. /**
  32555. * Default offline support factory responsible of creating a tool used to store data locally.
  32556. * By default, this will create a Database object if the workload has been embedded.
  32557. */
  32558. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32559. private _loadingScreen;
  32560. private _pointerLockRequested;
  32561. private _dummyFramebuffer;
  32562. private _rescalePostProcess;
  32563. /** @hidden */
  32564. protected _alphaMode: number;
  32565. /** @hidden */
  32566. protected _alphaEquation: number;
  32567. private _deterministicLockstep;
  32568. private _lockstepMaxSteps;
  32569. protected readonly _supportsHardwareTextureRescaling: boolean;
  32570. private _fps;
  32571. private _deltaTime;
  32572. /** @hidden */
  32573. _drawCalls: PerfCounter;
  32574. /**
  32575. * Turn this value on if you want to pause FPS computation when in background
  32576. */
  32577. disablePerformanceMonitorInBackground: boolean;
  32578. private _performanceMonitor;
  32579. /**
  32580. * Gets the performance monitor attached to this engine
  32581. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32582. */
  32583. readonly performanceMonitor: PerformanceMonitor;
  32584. private _onFocus;
  32585. private _onBlur;
  32586. private _onCanvasPointerOut;
  32587. private _onCanvasBlur;
  32588. private _onCanvasFocus;
  32589. private _onFullscreenChange;
  32590. private _onPointerLockChange;
  32591. /**
  32592. * Gets the HTML element used to attach event listeners
  32593. * @returns a HTML element
  32594. */
  32595. getInputElement(): Nullable<HTMLElement>;
  32596. /**
  32597. * Creates a new engine
  32598. * @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
  32599. * @param antialias defines enable antialiasing (default: false)
  32600. * @param options defines further options to be sent to the getContext() function
  32601. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32602. */
  32603. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32604. /**
  32605. * Gets current aspect ratio
  32606. * @param viewportOwner defines the camera to use to get the aspect ratio
  32607. * @param useScreen defines if screen size must be used (or the current render target if any)
  32608. * @returns a number defining the aspect ratio
  32609. */
  32610. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32611. /**
  32612. * Gets current screen aspect ratio
  32613. * @returns a number defining the aspect ratio
  32614. */
  32615. getScreenAspectRatio(): number;
  32616. /**
  32617. * Gets host document
  32618. * @returns the host document object
  32619. */
  32620. getHostDocument(): Document;
  32621. /**
  32622. * Gets the client rect of the HTML canvas attached with the current webGL context
  32623. * @returns a client rectanglee
  32624. */
  32625. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32626. /**
  32627. * Gets the client rect of the HTML element used for events
  32628. * @returns a client rectanglee
  32629. */
  32630. getInputElementClientRect(): Nullable<ClientRect>;
  32631. /**
  32632. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32633. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32634. * @returns true if engine is in deterministic lock step mode
  32635. */
  32636. isDeterministicLockStep(): boolean;
  32637. /**
  32638. * Gets the max steps when engine is running in deterministic lock step
  32639. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32640. * @returns the max steps
  32641. */
  32642. getLockstepMaxSteps(): number;
  32643. /**
  32644. * Force the mipmap generation for the given render target texture
  32645. * @param texture defines the render target texture to use
  32646. */
  32647. generateMipMapsForCubemap(texture: InternalTexture): void;
  32648. /** States */
  32649. /**
  32650. * Set various states to the webGL context
  32651. * @param culling defines backface culling state
  32652. * @param zOffset defines the value to apply to zOffset (0 by default)
  32653. * @param force defines if states must be applied even if cache is up to date
  32654. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32655. */
  32656. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32657. /**
  32658. * Set the z offset to apply to current rendering
  32659. * @param value defines the offset to apply
  32660. */
  32661. setZOffset(value: number): void;
  32662. /**
  32663. * Gets the current value of the zOffset
  32664. * @returns the current zOffset state
  32665. */
  32666. getZOffset(): number;
  32667. /**
  32668. * Enable or disable depth buffering
  32669. * @param enable defines the state to set
  32670. */
  32671. setDepthBuffer(enable: boolean): void;
  32672. /**
  32673. * Gets a boolean indicating if depth writing is enabled
  32674. * @returns the current depth writing state
  32675. */
  32676. getDepthWrite(): boolean;
  32677. /**
  32678. * Enable or disable depth writing
  32679. * @param enable defines the state to set
  32680. */
  32681. setDepthWrite(enable: boolean): void;
  32682. /**
  32683. * Enable or disable color writing
  32684. * @param enable defines the state to set
  32685. */
  32686. setColorWrite(enable: boolean): void;
  32687. /**
  32688. * Gets a boolean indicating if color writing is enabled
  32689. * @returns the current color writing state
  32690. */
  32691. getColorWrite(): boolean;
  32692. /**
  32693. * Sets alpha constants used by some alpha blending modes
  32694. * @param r defines the red component
  32695. * @param g defines the green component
  32696. * @param b defines the blue component
  32697. * @param a defines the alpha component
  32698. */
  32699. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32700. /**
  32701. * Sets the current alpha mode
  32702. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32703. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32704. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32705. */
  32706. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32707. /**
  32708. * Gets the current alpha mode
  32709. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32710. * @returns the current alpha mode
  32711. */
  32712. getAlphaMode(): number;
  32713. /**
  32714. * Sets the current alpha equation
  32715. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32716. */
  32717. setAlphaEquation(equation: number): void;
  32718. /**
  32719. * Gets the current alpha equation.
  32720. * @returns the current alpha equation
  32721. */
  32722. getAlphaEquation(): number;
  32723. /**
  32724. * Gets a boolean indicating if stencil buffer is enabled
  32725. * @returns the current stencil buffer state
  32726. */
  32727. getStencilBuffer(): boolean;
  32728. /**
  32729. * Enable or disable the stencil buffer
  32730. * @param enable defines if the stencil buffer must be enabled or disabled
  32731. */
  32732. setStencilBuffer(enable: boolean): void;
  32733. /**
  32734. * Gets the current stencil mask
  32735. * @returns a number defining the new stencil mask to use
  32736. */
  32737. getStencilMask(): number;
  32738. /**
  32739. * Sets the current stencil mask
  32740. * @param mask defines the new stencil mask to use
  32741. */
  32742. setStencilMask(mask: number): void;
  32743. /**
  32744. * Gets the current stencil function
  32745. * @returns a number defining the stencil function to use
  32746. */
  32747. getStencilFunction(): number;
  32748. /**
  32749. * Gets the current stencil reference value
  32750. * @returns a number defining the stencil reference value to use
  32751. */
  32752. getStencilFunctionReference(): number;
  32753. /**
  32754. * Gets the current stencil mask
  32755. * @returns a number defining the stencil mask to use
  32756. */
  32757. getStencilFunctionMask(): number;
  32758. /**
  32759. * Sets the current stencil function
  32760. * @param stencilFunc defines the new stencil function to use
  32761. */
  32762. setStencilFunction(stencilFunc: number): void;
  32763. /**
  32764. * Sets the current stencil reference
  32765. * @param reference defines the new stencil reference to use
  32766. */
  32767. setStencilFunctionReference(reference: number): void;
  32768. /**
  32769. * Sets the current stencil mask
  32770. * @param mask defines the new stencil mask to use
  32771. */
  32772. setStencilFunctionMask(mask: number): void;
  32773. /**
  32774. * Gets the current stencil operation when stencil fails
  32775. * @returns a number defining stencil operation to use when stencil fails
  32776. */
  32777. getStencilOperationFail(): number;
  32778. /**
  32779. * Gets the current stencil operation when depth fails
  32780. * @returns a number defining stencil operation to use when depth fails
  32781. */
  32782. getStencilOperationDepthFail(): number;
  32783. /**
  32784. * Gets the current stencil operation when stencil passes
  32785. * @returns a number defining stencil operation to use when stencil passes
  32786. */
  32787. getStencilOperationPass(): number;
  32788. /**
  32789. * Sets the stencil operation to use when stencil fails
  32790. * @param operation defines the stencil operation to use when stencil fails
  32791. */
  32792. setStencilOperationFail(operation: number): void;
  32793. /**
  32794. * Sets the stencil operation to use when depth fails
  32795. * @param operation defines the stencil operation to use when depth fails
  32796. */
  32797. setStencilOperationDepthFail(operation: number): void;
  32798. /**
  32799. * Sets the stencil operation to use when stencil passes
  32800. * @param operation defines the stencil operation to use when stencil passes
  32801. */
  32802. setStencilOperationPass(operation: number): void;
  32803. /**
  32804. * Sets a boolean indicating if the dithering state is enabled or disabled
  32805. * @param value defines the dithering state
  32806. */
  32807. setDitheringState(value: boolean): void;
  32808. /**
  32809. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32810. * @param value defines the rasterizer state
  32811. */
  32812. setRasterizerState(value: boolean): void;
  32813. /**
  32814. * Gets the current depth function
  32815. * @returns a number defining the depth function
  32816. */
  32817. getDepthFunction(): Nullable<number>;
  32818. /**
  32819. * Sets the current depth function
  32820. * @param depthFunc defines the function to use
  32821. */
  32822. setDepthFunction(depthFunc: number): void;
  32823. /**
  32824. * Sets the current depth function to GREATER
  32825. */
  32826. setDepthFunctionToGreater(): void;
  32827. /**
  32828. * Sets the current depth function to GEQUAL
  32829. */
  32830. setDepthFunctionToGreaterOrEqual(): void;
  32831. /**
  32832. * Sets the current depth function to LESS
  32833. */
  32834. setDepthFunctionToLess(): void;
  32835. /**
  32836. * Sets the current depth function to LEQUAL
  32837. */
  32838. setDepthFunctionToLessOrEqual(): void;
  32839. private _cachedStencilBuffer;
  32840. private _cachedStencilFunction;
  32841. private _cachedStencilMask;
  32842. private _cachedStencilOperationPass;
  32843. private _cachedStencilOperationFail;
  32844. private _cachedStencilOperationDepthFail;
  32845. private _cachedStencilReference;
  32846. /**
  32847. * Caches the the state of the stencil buffer
  32848. */
  32849. cacheStencilState(): void;
  32850. /**
  32851. * Restores the state of the stencil buffer
  32852. */
  32853. restoreStencilState(): void;
  32854. /**
  32855. * Directly set the WebGL Viewport
  32856. * @param x defines the x coordinate of the viewport (in screen space)
  32857. * @param y defines the y coordinate of the viewport (in screen space)
  32858. * @param width defines the width of the viewport (in screen space)
  32859. * @param height defines the height of the viewport (in screen space)
  32860. * @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
  32861. */
  32862. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32863. /**
  32864. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32865. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32866. * @param y defines the y-coordinate of the corner of the clear rectangle
  32867. * @param width defines the width of the clear rectangle
  32868. * @param height defines the height of the clear rectangle
  32869. * @param clearColor defines the clear color
  32870. */
  32871. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32872. /**
  32873. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32874. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32875. * @param y defines the y-coordinate of the corner of the clear rectangle
  32876. * @param width defines the width of the clear rectangle
  32877. * @param height defines the height of the clear rectangle
  32878. */
  32879. enableScissor(x: number, y: number, width: number, height: number): void;
  32880. /**
  32881. * Disable previously set scissor test rectangle
  32882. */
  32883. disableScissor(): void;
  32884. protected _reportDrawCall(): void;
  32885. /**
  32886. * Initializes a webVR display and starts listening to display change events
  32887. * The onVRDisplayChangedObservable will be notified upon these changes
  32888. * @returns The onVRDisplayChangedObservable
  32889. */
  32890. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32891. /** @hidden */
  32892. _prepareVRComponent(): void;
  32893. /** @hidden */
  32894. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32895. /** @hidden */
  32896. _submitVRFrame(): void;
  32897. /**
  32898. * Call this function to leave webVR mode
  32899. * Will do nothing if webVR is not supported or if there is no webVR device
  32900. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32901. */
  32902. disableVR(): void;
  32903. /**
  32904. * Gets a boolean indicating that the system is in VR mode and is presenting
  32905. * @returns true if VR mode is engaged
  32906. */
  32907. isVRPresenting(): boolean;
  32908. /** @hidden */
  32909. _requestVRFrame(): void;
  32910. /** @hidden */
  32911. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32912. /**
  32913. * Gets the source code of the vertex 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 vertex shader associated with the program
  32916. */
  32917. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32918. /**
  32919. * Gets the source code of the fragment shader associated with a specific webGL program
  32920. * @param program defines the program to use
  32921. * @returns a string containing the source code of the fragment shader associated with the program
  32922. */
  32923. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32924. /**
  32925. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32926. * @param x defines the x coordinate of the rectangle where pixels must be read
  32927. * @param y defines the y coordinate of the rectangle where pixels must be read
  32928. * @param width defines the width of the rectangle where pixels must be read
  32929. * @param height defines the height of the rectangle where pixels must be read
  32930. * @returns a Uint8Array containing RGBA colors
  32931. */
  32932. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32933. /**
  32934. * Sets a depth stencil texture from a render target to the according uniform.
  32935. * @param channel The texture channel
  32936. * @param uniform The uniform to set
  32937. * @param texture The render target texture containing the depth stencil texture to apply
  32938. */
  32939. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32940. /**
  32941. * Sets a texture to the webGL context from a postprocess
  32942. * @param channel defines the channel to use
  32943. * @param postProcess defines the source postprocess
  32944. */
  32945. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32946. /**
  32947. * Binds the output of the passed in post process to the texture channel specified
  32948. * @param channel The channel the texture should be bound to
  32949. * @param postProcess The post process which's output should be bound
  32950. */
  32951. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32952. /** @hidden */
  32953. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32954. protected _rebuildBuffers(): void;
  32955. /** @hidden */
  32956. _renderFrame(): void;
  32957. _renderLoop(): void;
  32958. /** @hidden */
  32959. _renderViews(): boolean;
  32960. /**
  32961. * Toggle full screen mode
  32962. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32963. */
  32964. switchFullscreen(requestPointerLock: boolean): void;
  32965. /**
  32966. * Enters full screen mode
  32967. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32968. */
  32969. enterFullscreen(requestPointerLock: boolean): void;
  32970. /**
  32971. * Exits full screen mode
  32972. */
  32973. exitFullscreen(): void;
  32974. /**
  32975. * Enters Pointerlock mode
  32976. */
  32977. enterPointerlock(): void;
  32978. /**
  32979. * Exits Pointerlock mode
  32980. */
  32981. exitPointerlock(): void;
  32982. /**
  32983. * Begin a new frame
  32984. */
  32985. beginFrame(): void;
  32986. /**
  32987. * Enf the current frame
  32988. */
  32989. endFrame(): void;
  32990. resize(): void;
  32991. /**
  32992. * Set the compressed texture format to use, based on the formats you have, and the formats
  32993. * supported by the hardware / browser.
  32994. *
  32995. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32996. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32997. * to API arguments needed to compressed textures. This puts the burden on the container
  32998. * generator to house the arcane code for determining these for current & future formats.
  32999. *
  33000. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33001. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33002. *
  33003. * Note: The result of this call is not taken into account when a texture is base64.
  33004. *
  33005. * @param formatsAvailable defines the list of those format families you have created
  33006. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33007. *
  33008. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33009. * @returns The extension selected.
  33010. */
  33011. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33012. /**
  33013. * Force a specific size of the canvas
  33014. * @param width defines the new canvas' width
  33015. * @param height defines the new canvas' height
  33016. */
  33017. setSize(width: number, height: number): void;
  33018. /**
  33019. * Updates a dynamic vertex buffer.
  33020. * @param vertexBuffer the vertex buffer to update
  33021. * @param data the data used to update the vertex buffer
  33022. * @param byteOffset the byte offset of the data
  33023. * @param byteLength the byte length of the data
  33024. */
  33025. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33026. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33027. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33028. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33029. _releaseTexture(texture: InternalTexture): void;
  33030. /**
  33031. * @hidden
  33032. * Rescales a texture
  33033. * @param source input texutre
  33034. * @param destination destination texture
  33035. * @param scene scene to use to render the resize
  33036. * @param internalFormat format to use when resizing
  33037. * @param onComplete callback to be called when resize has completed
  33038. */
  33039. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33040. /**
  33041. * Gets the current framerate
  33042. * @returns a number representing the framerate
  33043. */
  33044. getFps(): number;
  33045. /**
  33046. * Gets the time spent between current and previous frame
  33047. * @returns a number representing the delta time in ms
  33048. */
  33049. getDeltaTime(): number;
  33050. private _measureFps;
  33051. /** @hidden */
  33052. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33053. /**
  33054. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  33055. * @param renderTarget The render target to set the frame buffer for
  33056. */
  33057. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  33058. /**
  33059. * Update a dynamic index buffer
  33060. * @param indexBuffer defines the target index buffer
  33061. * @param indices defines the data to update
  33062. * @param offset defines the offset in the target index buffer where update should start
  33063. */
  33064. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33065. /**
  33066. * Updates the sample count of a render target texture
  33067. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33068. * @param texture defines the texture to update
  33069. * @param samples defines the sample count to set
  33070. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33071. */
  33072. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33073. /**
  33074. * Updates a depth texture Comparison Mode and Function.
  33075. * If the comparison Function is equal to 0, the mode will be set to none.
  33076. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33077. * @param texture The texture to set the comparison function for
  33078. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33079. */
  33080. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33081. /**
  33082. * Creates a webGL buffer to use with instanciation
  33083. * @param capacity defines the size of the buffer
  33084. * @returns the webGL buffer
  33085. */
  33086. createInstancesBuffer(capacity: number): DataBuffer;
  33087. /**
  33088. * Delete a webGL buffer used with instanciation
  33089. * @param buffer defines the webGL buffer to delete
  33090. */
  33091. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33092. /** @hidden */
  33093. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33094. dispose(): void;
  33095. private _disableTouchAction;
  33096. /**
  33097. * Display the loading screen
  33098. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33099. */
  33100. displayLoadingUI(): void;
  33101. /**
  33102. * Hide the loading screen
  33103. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33104. */
  33105. hideLoadingUI(): void;
  33106. /**
  33107. * Gets the current loading screen object
  33108. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33109. */
  33110. /**
  33111. * Sets the current loading screen object
  33112. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33113. */
  33114. loadingScreen: ILoadingScreen;
  33115. /**
  33116. * Sets the current loading screen text
  33117. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33118. */
  33119. loadingUIText: string;
  33120. /**
  33121. * Sets the current loading screen background color
  33122. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33123. */
  33124. loadingUIBackgroundColor: string;
  33125. /** Pointerlock and fullscreen */
  33126. /**
  33127. * Ask the browser to promote the current element to pointerlock mode
  33128. * @param element defines the DOM element to promote
  33129. */
  33130. static _RequestPointerlock(element: HTMLElement): void;
  33131. /**
  33132. * Asks the browser to exit pointerlock mode
  33133. */
  33134. static _ExitPointerlock(): void;
  33135. /**
  33136. * Ask the browser to promote the current element to fullscreen rendering mode
  33137. * @param element defines the DOM element to promote
  33138. */
  33139. static _RequestFullscreen(element: HTMLElement): void;
  33140. /**
  33141. * Asks the browser to exit fullscreen mode
  33142. */
  33143. static _ExitFullscreen(): void;
  33144. }
  33145. }
  33146. declare module "babylonjs/Engines/engineStore" {
  33147. import { Nullable } from "babylonjs/types";
  33148. import { Engine } from "babylonjs/Engines/engine";
  33149. import { Scene } from "babylonjs/scene";
  33150. /**
  33151. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33152. * during the life time of the application.
  33153. */
  33154. export class EngineStore {
  33155. /** Gets the list of created engines */
  33156. static Instances: import("babylonjs/Engines/engine").Engine[];
  33157. /** @hidden */
  33158. static _LastCreatedScene: Nullable<Scene>;
  33159. /**
  33160. * Gets the latest created engine
  33161. */
  33162. static readonly LastCreatedEngine: Nullable<Engine>;
  33163. /**
  33164. * Gets the latest created scene
  33165. */
  33166. static readonly LastCreatedScene: Nullable<Scene>;
  33167. /**
  33168. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33169. * @ignorenaming
  33170. */
  33171. static UseFallbackTexture: boolean;
  33172. /**
  33173. * Texture content used if a texture cannot loaded
  33174. * @ignorenaming
  33175. */
  33176. static FallbackTexture: string;
  33177. }
  33178. }
  33179. declare module "babylonjs/Misc/promise" {
  33180. /**
  33181. * Helper class that provides a small promise polyfill
  33182. */
  33183. export class PromisePolyfill {
  33184. /**
  33185. * Static function used to check if the polyfill is required
  33186. * If this is the case then the function will inject the polyfill to window.Promise
  33187. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33188. */
  33189. static Apply(force?: boolean): void;
  33190. }
  33191. }
  33192. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  33193. /**
  33194. * Interface for screenshot methods with describe argument called `size` as object with options
  33195. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33196. */
  33197. export interface IScreenshotSize {
  33198. /**
  33199. * number in pixels for canvas height
  33200. */
  33201. height?: number;
  33202. /**
  33203. * multiplier allowing render at a higher or lower resolution
  33204. * If value is defined then height and width will be ignored and taken from camera
  33205. */
  33206. precision?: number;
  33207. /**
  33208. * number in pixels for canvas width
  33209. */
  33210. width?: number;
  33211. }
  33212. }
  33213. declare module "babylonjs/Misc/tools" {
  33214. import { Nullable, float } from "babylonjs/types";
  33215. import { DomManagement } from "babylonjs/Misc/domManagement";
  33216. import { WebRequest } from "babylonjs/Misc/webRequest";
  33217. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33218. import { ReadFileError } from "babylonjs/Misc/fileTools";
  33219. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33220. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  33221. import { Camera } from "babylonjs/Cameras/camera";
  33222. import { Engine } from "babylonjs/Engines/engine";
  33223. interface IColor4Like {
  33224. r: float;
  33225. g: float;
  33226. b: float;
  33227. a: float;
  33228. }
  33229. /**
  33230. * Class containing a set of static utilities functions
  33231. */
  33232. export class Tools {
  33233. /**
  33234. * Gets or sets the base URL to use to load assets
  33235. */
  33236. static BaseUrl: string;
  33237. /**
  33238. * Enable/Disable Custom HTTP Request Headers globally.
  33239. * default = false
  33240. * @see CustomRequestHeaders
  33241. */
  33242. static UseCustomRequestHeaders: boolean;
  33243. /**
  33244. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33245. * i.e. when loading files, where the server/service expects an Authorization header
  33246. */
  33247. static CustomRequestHeaders: {
  33248. [key: string]: string;
  33249. };
  33250. /**
  33251. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33252. */
  33253. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  33254. /**
  33255. * Default behaviour for cors in the application.
  33256. * It can be a string if the expected behavior is identical in the entire app.
  33257. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33258. */
  33259. static CorsBehavior: string | ((url: string | string[]) => string);
  33260. /**
  33261. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33262. * @ignorenaming
  33263. */
  33264. static UseFallbackTexture: boolean;
  33265. /**
  33266. * Use this object to register external classes like custom textures or material
  33267. * to allow the laoders to instantiate them
  33268. */
  33269. static RegisteredExternalClasses: {
  33270. [key: string]: Object;
  33271. };
  33272. /**
  33273. * Texture content used if a texture cannot loaded
  33274. * @ignorenaming
  33275. */
  33276. static fallbackTexture: string;
  33277. /**
  33278. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33279. * @param u defines the coordinate on X axis
  33280. * @param v defines the coordinate on Y axis
  33281. * @param width defines the width of the source data
  33282. * @param height defines the height of the source data
  33283. * @param pixels defines the source byte array
  33284. * @param color defines the output color
  33285. */
  33286. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33287. /**
  33288. * Interpolates between a and b via alpha
  33289. * @param a The lower value (returned when alpha = 0)
  33290. * @param b The upper value (returned when alpha = 1)
  33291. * @param alpha The interpolation-factor
  33292. * @return The mixed value
  33293. */
  33294. static Mix(a: number, b: number, alpha: number): number;
  33295. /**
  33296. * Tries to instantiate a new object from a given class name
  33297. * @param className defines the class name to instantiate
  33298. * @returns the new object or null if the system was not able to do the instantiation
  33299. */
  33300. static Instantiate(className: string): any;
  33301. /**
  33302. * Provides a slice function that will work even on IE
  33303. * @param data defines the array to slice
  33304. * @param start defines the start of the data (optional)
  33305. * @param end defines the end of the data (optional)
  33306. * @returns the new sliced array
  33307. */
  33308. static Slice<T>(data: T, start?: number, end?: number): T;
  33309. /**
  33310. * Polyfill for setImmediate
  33311. * @param action defines the action to execute after the current execution block
  33312. */
  33313. static SetImmediate(action: () => void): void;
  33314. /**
  33315. * Function indicating if a number is an exponent of 2
  33316. * @param value defines the value to test
  33317. * @returns true if the value is an exponent of 2
  33318. */
  33319. static IsExponentOfTwo(value: number): boolean;
  33320. private static _tmpFloatArray;
  33321. /**
  33322. * Returns the nearest 32-bit single precision float representation of a Number
  33323. * @param value A Number. If the parameter is of a different type, it will get converted
  33324. * to a number or to NaN if it cannot be converted
  33325. * @returns number
  33326. */
  33327. static FloatRound(value: number): number;
  33328. /**
  33329. * Extracts the filename from a path
  33330. * @param path defines the path to use
  33331. * @returns the filename
  33332. */
  33333. static GetFilename(path: string): string;
  33334. /**
  33335. * Extracts the "folder" part of a path (everything before the filename).
  33336. * @param uri The URI to extract the info from
  33337. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33338. * @returns The "folder" part of the path
  33339. */
  33340. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33341. /**
  33342. * Extracts text content from a DOM element hierarchy
  33343. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33344. */
  33345. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33346. /**
  33347. * Convert an angle in radians to degrees
  33348. * @param angle defines the angle to convert
  33349. * @returns the angle in degrees
  33350. */
  33351. static ToDegrees(angle: number): number;
  33352. /**
  33353. * Convert an angle in degrees to radians
  33354. * @param angle defines the angle to convert
  33355. * @returns the angle in radians
  33356. */
  33357. static ToRadians(angle: number): number;
  33358. /**
  33359. * Returns an array if obj is not an array
  33360. * @param obj defines the object to evaluate as an array
  33361. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33362. * @returns either obj directly if obj is an array or a new array containing obj
  33363. */
  33364. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33365. /**
  33366. * Gets the pointer prefix to use
  33367. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33368. */
  33369. static GetPointerPrefix(): string;
  33370. /**
  33371. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33372. * @param url define the url we are trying
  33373. * @param element define the dom element where to configure the cors policy
  33374. */
  33375. static SetCorsBehavior(url: string | string[], element: {
  33376. crossOrigin: string | null;
  33377. }): void;
  33378. /**
  33379. * Removes unwanted characters from an url
  33380. * @param url defines the url to clean
  33381. * @returns the cleaned url
  33382. */
  33383. static CleanUrl(url: string): string;
  33384. /**
  33385. * Gets or sets a function used to pre-process url before using them to load assets
  33386. */
  33387. static PreprocessUrl: (url: string) => string;
  33388. /**
  33389. * Loads an image as an HTMLImageElement.
  33390. * @param input url string, ArrayBuffer, or Blob to load
  33391. * @param onLoad callback called when the image successfully loads
  33392. * @param onError callback called when the image fails to load
  33393. * @param offlineProvider offline provider for caching
  33394. * @param mimeType optional mime type
  33395. * @returns the HTMLImageElement of the loaded image
  33396. */
  33397. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33398. /**
  33399. * Loads a file from a url
  33400. * @param url url string, ArrayBuffer, or Blob to load
  33401. * @param onSuccess callback called when the file successfully loads
  33402. * @param onProgress callback called while file is loading (if the server supports this mode)
  33403. * @param offlineProvider defines the offline provider for caching
  33404. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33405. * @param onError callback called when the file fails to load
  33406. * @returns a file request object
  33407. */
  33408. 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;
  33409. /**
  33410. * Loads a file from a url
  33411. * @param url the file url to load
  33412. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33413. */
  33414. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33415. /**
  33416. * Load a script (identified by an url). When the url returns, the
  33417. * content of this file is added into a new script element, attached to the DOM (body element)
  33418. * @param scriptUrl defines the url of the script to laod
  33419. * @param onSuccess defines the callback called when the script is loaded
  33420. * @param onError defines the callback to call if an error occurs
  33421. * @param scriptId defines the id of the script element
  33422. */
  33423. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33424. /**
  33425. * Load an asynchronous script (identified by an url). When the url returns, the
  33426. * content of this file is added into a new script element, attached to the DOM (body element)
  33427. * @param scriptUrl defines the url of the script to laod
  33428. * @param scriptId defines the id of the script element
  33429. * @returns a promise request object
  33430. */
  33431. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33432. /**
  33433. * Loads a file from a blob
  33434. * @param fileToLoad defines the blob to use
  33435. * @param callback defines the callback to call when data is loaded
  33436. * @param progressCallback defines the callback to call during loading process
  33437. * @returns a file request object
  33438. */
  33439. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33440. /**
  33441. * Reads a file from a File object
  33442. * @param file defines the file to load
  33443. * @param onSuccess defines the callback to call when data is loaded
  33444. * @param onProgress defines the callback to call during loading process
  33445. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33446. * @param onError defines the callback to call when an error occurs
  33447. * @returns a file request object
  33448. */
  33449. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33450. /**
  33451. * Creates a data url from a given string content
  33452. * @param content defines the content to convert
  33453. * @returns the new data url link
  33454. */
  33455. static FileAsURL(content: string): string;
  33456. /**
  33457. * Format the given number to a specific decimal format
  33458. * @param value defines the number to format
  33459. * @param decimals defines the number of decimals to use
  33460. * @returns the formatted string
  33461. */
  33462. static Format(value: number, decimals?: number): string;
  33463. /**
  33464. * Tries to copy an object by duplicating every property
  33465. * @param source defines the source object
  33466. * @param destination defines the target object
  33467. * @param doNotCopyList defines a list of properties to avoid
  33468. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33469. */
  33470. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33471. /**
  33472. * Gets a boolean indicating if the given object has no own property
  33473. * @param obj defines the object to test
  33474. * @returns true if object has no own property
  33475. */
  33476. static IsEmpty(obj: any): boolean;
  33477. /**
  33478. * Function used to register events at window level
  33479. * @param windowElement defines the Window object to use
  33480. * @param events defines the events to register
  33481. */
  33482. static RegisterTopRootEvents(windowElement: Window, events: {
  33483. name: string;
  33484. handler: Nullable<(e: FocusEvent) => any>;
  33485. }[]): void;
  33486. /**
  33487. * Function used to unregister events from window level
  33488. * @param windowElement defines the Window object to use
  33489. * @param events defines the events to unregister
  33490. */
  33491. static UnregisterTopRootEvents(windowElement: Window, events: {
  33492. name: string;
  33493. handler: Nullable<(e: FocusEvent) => any>;
  33494. }[]): void;
  33495. /**
  33496. * @ignore
  33497. */
  33498. static _ScreenshotCanvas: HTMLCanvasElement;
  33499. /**
  33500. * Dumps the current bound framebuffer
  33501. * @param width defines the rendering width
  33502. * @param height defines the rendering height
  33503. * @param engine defines the hosting engine
  33504. * @param successCallback defines the callback triggered once the data are available
  33505. * @param mimeType defines the mime type of the result
  33506. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33507. */
  33508. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33509. /**
  33510. * Converts the canvas data to blob.
  33511. * This acts as a polyfill for browsers not supporting the to blob function.
  33512. * @param canvas Defines the canvas to extract the data from
  33513. * @param successCallback Defines the callback triggered once the data are available
  33514. * @param mimeType Defines the mime type of the result
  33515. */
  33516. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33517. /**
  33518. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33519. * @param successCallback defines the callback triggered once the data are available
  33520. * @param mimeType defines the mime type of the result
  33521. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33522. */
  33523. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33524. /**
  33525. * Downloads a blob in the browser
  33526. * @param blob defines the blob to download
  33527. * @param fileName defines the name of the downloaded file
  33528. */
  33529. static Download(blob: Blob, fileName: string): void;
  33530. /**
  33531. * Captures a screenshot of the current rendering
  33532. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33533. * @param engine defines the rendering engine
  33534. * @param camera defines the source camera
  33535. * @param size This parameter can be set to a single number or to an object with the
  33536. * following (optional) properties: precision, width, height. If a single number is passed,
  33537. * it will be used for both width and height. If an object is passed, the screenshot size
  33538. * will be derived from the parameters. The precision property is a multiplier allowing
  33539. * rendering at a higher or lower resolution
  33540. * @param successCallback defines the callback receives a single parameter which contains the
  33541. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33542. * src parameter of an <img> to display it
  33543. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33544. * Check your browser for supported MIME types
  33545. */
  33546. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33547. /**
  33548. * Captures a screenshot of the current rendering
  33549. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33550. * @param engine defines the rendering engine
  33551. * @param camera defines the source camera
  33552. * @param size This parameter can be set to a single number or to an object with the
  33553. * following (optional) properties: precision, width, height. If a single number is passed,
  33554. * it will be used for both width and height. If an object is passed, the screenshot size
  33555. * will be derived from the parameters. The precision property is a multiplier allowing
  33556. * rendering at a higher or lower resolution
  33557. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33558. * Check your browser for supported MIME types
  33559. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33560. * to the src parameter of an <img> to display it
  33561. */
  33562. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33563. /**
  33564. * Generates an image screenshot from the specified camera.
  33565. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33566. * @param engine The engine to use for rendering
  33567. * @param camera The camera to use for rendering
  33568. * @param size This parameter can be set to a single number or to an object with the
  33569. * following (optional) properties: precision, width, height. If a single number is passed,
  33570. * it will be used for both width and height. If an object is passed, the screenshot size
  33571. * will be derived from the parameters. The precision property is a multiplier allowing
  33572. * rendering at a higher or lower resolution
  33573. * @param successCallback The callback receives a single parameter which contains the
  33574. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33575. * src parameter of an <img> to display it
  33576. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33577. * Check your browser for supported MIME types
  33578. * @param samples Texture samples (default: 1)
  33579. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33580. * @param fileName A name for for the downloaded file.
  33581. */
  33582. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33583. /**
  33584. * Generates an image screenshot from the specified camera.
  33585. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33586. * @param engine The engine to use for rendering
  33587. * @param camera The camera to use for rendering
  33588. * @param size This parameter can be set to a single number or to an object with the
  33589. * following (optional) properties: precision, width, height. If a single number is passed,
  33590. * it will be used for both width and height. If an object is passed, the screenshot size
  33591. * will be derived from the parameters. The precision property is a multiplier allowing
  33592. * rendering at a higher or lower resolution
  33593. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33594. * Check your browser for supported MIME types
  33595. * @param samples Texture samples (default: 1)
  33596. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33597. * @param fileName A name for for the downloaded file.
  33598. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33599. * to the src parameter of an <img> to display it
  33600. */
  33601. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33602. /**
  33603. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33604. * Be aware Math.random() could cause collisions, but:
  33605. * "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"
  33606. * @returns a pseudo random id
  33607. */
  33608. static RandomId(): string;
  33609. /**
  33610. * Test if the given uri is a base64 string
  33611. * @param uri The uri to test
  33612. * @return True if the uri is a base64 string or false otherwise
  33613. */
  33614. static IsBase64(uri: string): boolean;
  33615. /**
  33616. * Decode the given base64 uri.
  33617. * @param uri The uri to decode
  33618. * @return The decoded base64 data.
  33619. */
  33620. static DecodeBase64(uri: string): ArrayBuffer;
  33621. /**
  33622. * Gets the absolute url.
  33623. * @param url the input url
  33624. * @return the absolute url
  33625. */
  33626. static GetAbsoluteUrl(url: string): string;
  33627. /**
  33628. * No log
  33629. */
  33630. static readonly NoneLogLevel: number;
  33631. /**
  33632. * Only message logs
  33633. */
  33634. static readonly MessageLogLevel: number;
  33635. /**
  33636. * Only warning logs
  33637. */
  33638. static readonly WarningLogLevel: number;
  33639. /**
  33640. * Only error logs
  33641. */
  33642. static readonly ErrorLogLevel: number;
  33643. /**
  33644. * All logs
  33645. */
  33646. static readonly AllLogLevel: number;
  33647. /**
  33648. * Gets a value indicating the number of loading errors
  33649. * @ignorenaming
  33650. */
  33651. static readonly errorsCount: number;
  33652. /**
  33653. * Callback called when a new log is added
  33654. */
  33655. static OnNewCacheEntry: (entry: string) => void;
  33656. /**
  33657. * Log a message to the console
  33658. * @param message defines the message to log
  33659. */
  33660. static Log(message: string): void;
  33661. /**
  33662. * Write a warning message to the console
  33663. * @param message defines the message to log
  33664. */
  33665. static Warn(message: string): void;
  33666. /**
  33667. * Write an error message to the console
  33668. * @param message defines the message to log
  33669. */
  33670. static Error(message: string): void;
  33671. /**
  33672. * Gets current log cache (list of logs)
  33673. */
  33674. static readonly LogCache: string;
  33675. /**
  33676. * Clears the log cache
  33677. */
  33678. static ClearLogCache(): void;
  33679. /**
  33680. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33681. */
  33682. static LogLevels: number;
  33683. /**
  33684. * Checks if the window object exists
  33685. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33686. */
  33687. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33688. /**
  33689. * No performance log
  33690. */
  33691. static readonly PerformanceNoneLogLevel: number;
  33692. /**
  33693. * Use user marks to log performance
  33694. */
  33695. static readonly PerformanceUserMarkLogLevel: number;
  33696. /**
  33697. * Log performance to the console
  33698. */
  33699. static readonly PerformanceConsoleLogLevel: number;
  33700. private static _performance;
  33701. /**
  33702. * Sets the current performance log level
  33703. */
  33704. static PerformanceLogLevel: number;
  33705. private static _StartPerformanceCounterDisabled;
  33706. private static _EndPerformanceCounterDisabled;
  33707. private static _StartUserMark;
  33708. private static _EndUserMark;
  33709. private static _StartPerformanceConsole;
  33710. private static _EndPerformanceConsole;
  33711. /**
  33712. * Starts a performance counter
  33713. */
  33714. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33715. /**
  33716. * Ends a specific performance coutner
  33717. */
  33718. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33719. /**
  33720. * Gets either window.performance.now() if supported or Date.now() else
  33721. */
  33722. static readonly Now: number;
  33723. /**
  33724. * This method will return the name of the class used to create the instance of the given object.
  33725. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33726. * @param object the object to get the class name from
  33727. * @param isType defines if the object is actually a type
  33728. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33729. */
  33730. static GetClassName(object: any, isType?: boolean): string;
  33731. /**
  33732. * Gets the first element of an array satisfying a given predicate
  33733. * @param array defines the array to browse
  33734. * @param predicate defines the predicate to use
  33735. * @returns null if not found or the element
  33736. */
  33737. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33738. /**
  33739. * This method will return the name of the full name of the class, including its owning module (if any).
  33740. * 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).
  33741. * @param object the object to get the class name from
  33742. * @param isType defines if the object is actually a type
  33743. * @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.
  33744. * @ignorenaming
  33745. */
  33746. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33747. /**
  33748. * Returns a promise that resolves after the given amount of time.
  33749. * @param delay Number of milliseconds to delay
  33750. * @returns Promise that resolves after the given amount of time
  33751. */
  33752. static DelayAsync(delay: number): Promise<void>;
  33753. }
  33754. /**
  33755. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33756. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33757. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33758. * @param name The name of the class, case should be preserved
  33759. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33760. */
  33761. export function className(name: string, module?: string): (target: Object) => void;
  33762. /**
  33763. * An implementation of a loop for asynchronous functions.
  33764. */
  33765. export class AsyncLoop {
  33766. /**
  33767. * Defines the number of iterations for the loop
  33768. */
  33769. iterations: number;
  33770. /**
  33771. * Defines the current index of the loop.
  33772. */
  33773. index: number;
  33774. private _done;
  33775. private _fn;
  33776. private _successCallback;
  33777. /**
  33778. * Constructor.
  33779. * @param iterations the number of iterations.
  33780. * @param func the function to run each iteration
  33781. * @param successCallback the callback that will be called upon succesful execution
  33782. * @param offset starting offset.
  33783. */
  33784. constructor(
  33785. /**
  33786. * Defines the number of iterations for the loop
  33787. */
  33788. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33789. /**
  33790. * Execute the next iteration. Must be called after the last iteration was finished.
  33791. */
  33792. executeNext(): void;
  33793. /**
  33794. * Break the loop and run the success callback.
  33795. */
  33796. breakLoop(): void;
  33797. /**
  33798. * Create and run an async loop.
  33799. * @param iterations the number of iterations.
  33800. * @param fn the function to run each iteration
  33801. * @param successCallback the callback that will be called upon succesful execution
  33802. * @param offset starting offset.
  33803. * @returns the created async loop object
  33804. */
  33805. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33806. /**
  33807. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33808. * @param iterations total number of iterations
  33809. * @param syncedIterations number of synchronous iterations in each async iteration.
  33810. * @param fn the function to call each iteration.
  33811. * @param callback a success call back that will be called when iterating stops.
  33812. * @param breakFunction a break condition (optional)
  33813. * @param timeout timeout settings for the setTimeout function. default - 0.
  33814. * @returns the created async loop object
  33815. */
  33816. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33817. }
  33818. }
  33819. declare module "babylonjs/Misc/stringDictionary" {
  33820. import { Nullable } from "babylonjs/types";
  33821. /**
  33822. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33823. * The underlying implementation relies on an associative array to ensure the best performances.
  33824. * The value can be anything including 'null' but except 'undefined'
  33825. */
  33826. export class StringDictionary<T> {
  33827. /**
  33828. * This will clear this dictionary and copy the content from the 'source' one.
  33829. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33830. * @param source the dictionary to take the content from and copy to this dictionary
  33831. */
  33832. copyFrom(source: StringDictionary<T>): void;
  33833. /**
  33834. * Get a value based from its key
  33835. * @param key the given key to get the matching value from
  33836. * @return the value if found, otherwise undefined is returned
  33837. */
  33838. get(key: string): T | undefined;
  33839. /**
  33840. * Get a value from its key or add it if it doesn't exist.
  33841. * This method will ensure you that a given key/data will be present in the dictionary.
  33842. * @param key the given key to get the matching value from
  33843. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33844. * The factory will only be invoked if there's no data for the given key.
  33845. * @return the value corresponding to the key.
  33846. */
  33847. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33848. /**
  33849. * Get a value from its key if present in the dictionary otherwise add it
  33850. * @param key the key to get the value from
  33851. * @param val if there's no such key/value pair in the dictionary add it with this value
  33852. * @return the value corresponding to the key
  33853. */
  33854. getOrAdd(key: string, val: T): T;
  33855. /**
  33856. * Check if there's a given key in the dictionary
  33857. * @param key the key to check for
  33858. * @return true if the key is present, false otherwise
  33859. */
  33860. contains(key: string): boolean;
  33861. /**
  33862. * Add a new key and its corresponding value
  33863. * @param key the key to add
  33864. * @param value the value corresponding to the key
  33865. * @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
  33866. */
  33867. add(key: string, value: T): boolean;
  33868. /**
  33869. * Update a specific value associated to a key
  33870. * @param key defines the key to use
  33871. * @param value defines the value to store
  33872. * @returns true if the value was updated (or false if the key was not found)
  33873. */
  33874. set(key: string, value: T): boolean;
  33875. /**
  33876. * Get the element of the given key and remove it from the dictionary
  33877. * @param key defines the key to search
  33878. * @returns the value associated with the key or null if not found
  33879. */
  33880. getAndRemove(key: string): Nullable<T>;
  33881. /**
  33882. * Remove a key/value from the dictionary.
  33883. * @param key the key to remove
  33884. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33885. */
  33886. remove(key: string): boolean;
  33887. /**
  33888. * Clear the whole content of the dictionary
  33889. */
  33890. clear(): void;
  33891. /**
  33892. * Gets the current count
  33893. */
  33894. readonly count: number;
  33895. /**
  33896. * Execute a callback on each key/val of the dictionary.
  33897. * Note that you can remove any element in this dictionary in the callback implementation
  33898. * @param callback the callback to execute on a given key/value pair
  33899. */
  33900. forEach(callback: (key: string, val: T) => void): void;
  33901. /**
  33902. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33903. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33904. * Note that you can remove any element in this dictionary in the callback implementation
  33905. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33906. * @returns the first item
  33907. */
  33908. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33909. private _count;
  33910. private _data;
  33911. }
  33912. }
  33913. declare module "babylonjs/Collisions/collisionCoordinator" {
  33914. import { Nullable } from "babylonjs/types";
  33915. import { Scene } from "babylonjs/scene";
  33916. import { Vector3 } from "babylonjs/Maths/math.vector";
  33917. import { Collider } from "babylonjs/Collisions/collider";
  33918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33919. /** @hidden */
  33920. export interface ICollisionCoordinator {
  33921. createCollider(): Collider;
  33922. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33923. init(scene: Scene): void;
  33924. }
  33925. /** @hidden */
  33926. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33927. private _scene;
  33928. private _scaledPosition;
  33929. private _scaledVelocity;
  33930. private _finalPosition;
  33931. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33932. createCollider(): Collider;
  33933. init(scene: Scene): void;
  33934. private _collideWithWorld;
  33935. }
  33936. }
  33937. declare module "babylonjs/Inputs/scene.inputManager" {
  33938. import { Nullable } from "babylonjs/types";
  33939. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33940. import { Vector2 } from "babylonjs/Maths/math.vector";
  33941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33942. import { Scene } from "babylonjs/scene";
  33943. /**
  33944. * Class used to manage all inputs for the scene.
  33945. */
  33946. export class InputManager {
  33947. /** The distance in pixel that you have to move to prevent some events */
  33948. static DragMovementThreshold: number;
  33949. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33950. static LongPressDelay: number;
  33951. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33952. static DoubleClickDelay: number;
  33953. /** If you need to check double click without raising a single click at first click, enable this flag */
  33954. static ExclusiveDoubleClickMode: boolean;
  33955. private _wheelEventName;
  33956. private _onPointerMove;
  33957. private _onPointerDown;
  33958. private _onPointerUp;
  33959. private _initClickEvent;
  33960. private _initActionManager;
  33961. private _delayedSimpleClick;
  33962. private _delayedSimpleClickTimeout;
  33963. private _previousDelayedSimpleClickTimeout;
  33964. private _meshPickProceed;
  33965. private _previousButtonPressed;
  33966. private _currentPickResult;
  33967. private _previousPickResult;
  33968. private _totalPointersPressed;
  33969. private _doubleClickOccured;
  33970. private _pointerOverMesh;
  33971. private _pickedDownMesh;
  33972. private _pickedUpMesh;
  33973. private _pointerX;
  33974. private _pointerY;
  33975. private _unTranslatedPointerX;
  33976. private _unTranslatedPointerY;
  33977. private _startingPointerPosition;
  33978. private _previousStartingPointerPosition;
  33979. private _startingPointerTime;
  33980. private _previousStartingPointerTime;
  33981. private _pointerCaptures;
  33982. private _onKeyDown;
  33983. private _onKeyUp;
  33984. private _onCanvasFocusObserver;
  33985. private _onCanvasBlurObserver;
  33986. private _scene;
  33987. /**
  33988. * Creates a new InputManager
  33989. * @param scene defines the hosting scene
  33990. */
  33991. constructor(scene: Scene);
  33992. /**
  33993. * Gets the mesh that is currently under the pointer
  33994. */
  33995. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33996. /**
  33997. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33998. */
  33999. readonly unTranslatedPointer: Vector2;
  34000. /**
  34001. * Gets or sets the current on-screen X position of the pointer
  34002. */
  34003. pointerX: number;
  34004. /**
  34005. * Gets or sets the current on-screen Y position of the pointer
  34006. */
  34007. pointerY: number;
  34008. private _updatePointerPosition;
  34009. private _processPointerMove;
  34010. private _setRayOnPointerInfo;
  34011. private _checkPrePointerObservable;
  34012. /**
  34013. * Use this method to simulate a pointer move on a mesh
  34014. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34015. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34016. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34017. */
  34018. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34019. /**
  34020. * Use this method to simulate a pointer down on a mesh
  34021. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34022. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34023. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34024. */
  34025. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34026. private _processPointerDown;
  34027. /** @hidden */
  34028. _isPointerSwiping(): boolean;
  34029. /**
  34030. * Use this method to simulate a pointer up on a mesh
  34031. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34032. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34033. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34034. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34035. */
  34036. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34037. private _processPointerUp;
  34038. /**
  34039. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34040. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34041. * @returns true if the pointer was captured
  34042. */
  34043. isPointerCaptured(pointerId?: number): boolean;
  34044. /**
  34045. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34046. * @param attachUp defines if you want to attach events to pointerup
  34047. * @param attachDown defines if you want to attach events to pointerdown
  34048. * @param attachMove defines if you want to attach events to pointermove
  34049. */
  34050. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34051. /**
  34052. * Detaches all event handlers
  34053. */
  34054. detachControl(): void;
  34055. /**
  34056. * Force the value of meshUnderPointer
  34057. * @param mesh defines the mesh to use
  34058. */
  34059. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34060. /**
  34061. * Gets the mesh under the pointer
  34062. * @returns a Mesh or null if no mesh is under the pointer
  34063. */
  34064. getPointerOverMesh(): Nullable<AbstractMesh>;
  34065. }
  34066. }
  34067. declare module "babylonjs/Misc/uniqueIdGenerator" {
  34068. /**
  34069. * Helper class used to generate session unique ID
  34070. */
  34071. export class UniqueIdGenerator {
  34072. private static _UniqueIdCounter;
  34073. /**
  34074. * Gets an unique (relatively to the current scene) Id
  34075. */
  34076. static readonly UniqueId: number;
  34077. }
  34078. }
  34079. declare module "babylonjs/Animations/animationGroup" {
  34080. import { Animatable } from "babylonjs/Animations/animatable";
  34081. import { Animation } from "babylonjs/Animations/animation";
  34082. import { Scene, IDisposable } from "babylonjs/scene";
  34083. import { Observable } from "babylonjs/Misc/observable";
  34084. import { Nullable } from "babylonjs/types";
  34085. import "babylonjs/Animations/animatable";
  34086. /**
  34087. * This class defines the direct association between an animation and a target
  34088. */
  34089. export class TargetedAnimation {
  34090. /**
  34091. * Animation to perform
  34092. */
  34093. animation: Animation;
  34094. /**
  34095. * Target to animate
  34096. */
  34097. target: any;
  34098. /**
  34099. * Serialize the object
  34100. * @returns the JSON object representing the current entity
  34101. */
  34102. serialize(): any;
  34103. }
  34104. /**
  34105. * Use this class to create coordinated animations on multiple targets
  34106. */
  34107. export class AnimationGroup implements IDisposable {
  34108. /** The name of the animation group */
  34109. name: string;
  34110. private _scene;
  34111. private _targetedAnimations;
  34112. private _animatables;
  34113. private _from;
  34114. private _to;
  34115. private _isStarted;
  34116. private _isPaused;
  34117. private _speedRatio;
  34118. private _loopAnimation;
  34119. /**
  34120. * Gets or sets the unique id of the node
  34121. */
  34122. uniqueId: number;
  34123. /**
  34124. * This observable will notify when one animation have ended
  34125. */
  34126. onAnimationEndObservable: Observable<TargetedAnimation>;
  34127. /**
  34128. * Observer raised when one animation loops
  34129. */
  34130. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34131. /**
  34132. * Observer raised when all animations have looped
  34133. */
  34134. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34135. /**
  34136. * This observable will notify when all animations have ended.
  34137. */
  34138. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34139. /**
  34140. * This observable will notify when all animations have paused.
  34141. */
  34142. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34143. /**
  34144. * This observable will notify when all animations are playing.
  34145. */
  34146. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34147. /**
  34148. * Gets the first frame
  34149. */
  34150. readonly from: number;
  34151. /**
  34152. * Gets the last frame
  34153. */
  34154. readonly to: number;
  34155. /**
  34156. * Define if the animations are started
  34157. */
  34158. readonly isStarted: boolean;
  34159. /**
  34160. * Gets a value indicating that the current group is playing
  34161. */
  34162. readonly isPlaying: boolean;
  34163. /**
  34164. * Gets or sets the speed ratio to use for all animations
  34165. */
  34166. /**
  34167. * Gets or sets the speed ratio to use for all animations
  34168. */
  34169. speedRatio: number;
  34170. /**
  34171. * Gets or sets if all animations should loop or not
  34172. */
  34173. loopAnimation: boolean;
  34174. /**
  34175. * Gets the targeted animations for this animation group
  34176. */
  34177. readonly targetedAnimations: Array<TargetedAnimation>;
  34178. /**
  34179. * returning the list of animatables controlled by this animation group.
  34180. */
  34181. readonly animatables: Array<Animatable>;
  34182. /**
  34183. * Instantiates a new Animation Group.
  34184. * This helps managing several animations at once.
  34185. * @see http://doc.babylonjs.com/how_to/group
  34186. * @param name Defines the name of the group
  34187. * @param scene Defines the scene the group belongs to
  34188. */
  34189. constructor(
  34190. /** The name of the animation group */
  34191. name: string, scene?: Nullable<Scene>);
  34192. /**
  34193. * Add an animation (with its target) in the group
  34194. * @param animation defines the animation we want to add
  34195. * @param target defines the target of the animation
  34196. * @returns the TargetedAnimation object
  34197. */
  34198. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34199. /**
  34200. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34201. * It can add constant keys at begin or end
  34202. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34203. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34204. * @returns the animation group
  34205. */
  34206. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34207. private _animationLoopCount;
  34208. private _animationLoopFlags;
  34209. private _processLoop;
  34210. /**
  34211. * Start all animations on given targets
  34212. * @param loop defines if animations must loop
  34213. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34214. * @param from defines the from key (optional)
  34215. * @param to defines the to key (optional)
  34216. * @returns the current animation group
  34217. */
  34218. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34219. /**
  34220. * Pause all animations
  34221. * @returns the animation group
  34222. */
  34223. pause(): AnimationGroup;
  34224. /**
  34225. * Play all animations to initial state
  34226. * This function will start() the animations if they were not started or will restart() them if they were paused
  34227. * @param loop defines if animations must loop
  34228. * @returns the animation group
  34229. */
  34230. play(loop?: boolean): AnimationGroup;
  34231. /**
  34232. * Reset all animations to initial state
  34233. * @returns the animation group
  34234. */
  34235. reset(): AnimationGroup;
  34236. /**
  34237. * Restart animations from key 0
  34238. * @returns the animation group
  34239. */
  34240. restart(): AnimationGroup;
  34241. /**
  34242. * Stop all animations
  34243. * @returns the animation group
  34244. */
  34245. stop(): AnimationGroup;
  34246. /**
  34247. * Set animation weight for all animatables
  34248. * @param weight defines the weight to use
  34249. * @return the animationGroup
  34250. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34251. */
  34252. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34253. /**
  34254. * Synchronize and normalize all animatables with a source animatable
  34255. * @param root defines the root animatable to synchronize with
  34256. * @return the animationGroup
  34257. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34258. */
  34259. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34260. /**
  34261. * Goes to a specific frame in this animation group
  34262. * @param frame the frame number to go to
  34263. * @return the animationGroup
  34264. */
  34265. goToFrame(frame: number): AnimationGroup;
  34266. /**
  34267. * Dispose all associated resources
  34268. */
  34269. dispose(): void;
  34270. private _checkAnimationGroupEnded;
  34271. /**
  34272. * Clone the current animation group and returns a copy
  34273. * @param newName defines the name of the new group
  34274. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34275. * @returns the new aniamtion group
  34276. */
  34277. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34278. /**
  34279. * Serializes the animationGroup to an object
  34280. * @returns Serialized object
  34281. */
  34282. serialize(): any;
  34283. /**
  34284. * Returns a new AnimationGroup object parsed from the source provided.
  34285. * @param parsedAnimationGroup defines the source
  34286. * @param scene defines the scene that will receive the animationGroup
  34287. * @returns a new AnimationGroup
  34288. */
  34289. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34290. /**
  34291. * Returns the string "AnimationGroup"
  34292. * @returns "AnimationGroup"
  34293. */
  34294. getClassName(): string;
  34295. /**
  34296. * Creates a detailled string about the object
  34297. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34298. * @returns a string representing the object
  34299. */
  34300. toString(fullDetails?: boolean): string;
  34301. }
  34302. }
  34303. declare module "babylonjs/scene" {
  34304. import { Nullable } from "babylonjs/types";
  34305. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34306. import { Observable } from "babylonjs/Misc/observable";
  34307. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  34308. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  34309. import { Geometry } from "babylonjs/Meshes/geometry";
  34310. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34311. import { SubMesh } from "babylonjs/Meshes/subMesh";
  34312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34313. import { Mesh } from "babylonjs/Meshes/mesh";
  34314. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34315. import { Bone } from "babylonjs/Bones/bone";
  34316. import { Skeleton } from "babylonjs/Bones/skeleton";
  34317. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34318. import { Camera } from "babylonjs/Cameras/camera";
  34319. import { AbstractScene } from "babylonjs/abstractScene";
  34320. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34321. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34322. import { Material } from "babylonjs/Materials/material";
  34323. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34324. import { Effect } from "babylonjs/Materials/effect";
  34325. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  34326. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34327. import { Light } from "babylonjs/Lights/light";
  34328. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  34329. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  34330. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  34331. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  34332. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34333. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  34334. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34335. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  34336. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  34337. import { Engine } from "babylonjs/Engines/engine";
  34338. import { Node } from "babylonjs/node";
  34339. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  34340. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34341. import { WebRequest } from "babylonjs/Misc/webRequest";
  34342. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  34343. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34344. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34345. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34346. import { Plane } from "babylonjs/Maths/math.plane";
  34347. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  34348. import { Ray } from "babylonjs/Culling/ray";
  34349. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  34350. import { Animation } from "babylonjs/Animations/animation";
  34351. import { Animatable } from "babylonjs/Animations/animatable";
  34352. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34353. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34354. import { Collider } from "babylonjs/Collisions/collider";
  34355. /**
  34356. * Define an interface for all classes that will hold resources
  34357. */
  34358. export interface IDisposable {
  34359. /**
  34360. * Releases all held resources
  34361. */
  34362. dispose(): void;
  34363. }
  34364. /** Interface defining initialization parameters for Scene class */
  34365. export interface SceneOptions {
  34366. /**
  34367. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34368. * It will improve performance when the number of geometries becomes important.
  34369. */
  34370. useGeometryUniqueIdsMap?: boolean;
  34371. /**
  34372. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34373. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34374. */
  34375. useMaterialMeshMap?: boolean;
  34376. /**
  34377. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34378. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34379. */
  34380. useClonedMeshhMap?: boolean;
  34381. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34382. virtual?: boolean;
  34383. }
  34384. /**
  34385. * Represents a scene to be rendered by the engine.
  34386. * @see http://doc.babylonjs.com/features/scene
  34387. */
  34388. export class Scene extends AbstractScene implements IAnimatable {
  34389. /** The fog is deactivated */
  34390. static readonly FOGMODE_NONE: number;
  34391. /** The fog density is following an exponential function */
  34392. static readonly FOGMODE_EXP: number;
  34393. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34394. static readonly FOGMODE_EXP2: number;
  34395. /** The fog density is following a linear function. */
  34396. static readonly FOGMODE_LINEAR: number;
  34397. /**
  34398. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34399. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34400. */
  34401. static MinDeltaTime: number;
  34402. /**
  34403. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34404. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34405. */
  34406. static MaxDeltaTime: number;
  34407. /**
  34408. * Factory used to create the default material.
  34409. * @param name The name of the material to create
  34410. * @param scene The scene to create the material for
  34411. * @returns The default material
  34412. */
  34413. static DefaultMaterialFactory(scene: Scene): Material;
  34414. /**
  34415. * Factory used to create the a collision coordinator.
  34416. * @returns The collision coordinator
  34417. */
  34418. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34419. /** @hidden */
  34420. _inputManager: InputManager;
  34421. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34422. cameraToUseForPointers: Nullable<Camera>;
  34423. /** @hidden */
  34424. readonly _isScene: boolean;
  34425. /**
  34426. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34427. */
  34428. autoClear: boolean;
  34429. /**
  34430. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34431. */
  34432. autoClearDepthAndStencil: boolean;
  34433. /**
  34434. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34435. */
  34436. clearColor: Color4;
  34437. /**
  34438. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34439. */
  34440. ambientColor: Color3;
  34441. /**
  34442. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34443. * It should only be one of the following (if not the default embedded one):
  34444. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34445. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34446. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34447. * The material properties need to be setup according to the type of texture in use.
  34448. */
  34449. environmentBRDFTexture: BaseTexture;
  34450. /** @hidden */
  34451. protected _environmentTexture: Nullable<BaseTexture>;
  34452. /**
  34453. * Texture used in all pbr material as the reflection texture.
  34454. * As in the majority of the scene they are the same (exception for multi room and so on),
  34455. * this is easier to reference from here than from all the materials.
  34456. */
  34457. /**
  34458. * Texture used in all pbr material as the reflection texture.
  34459. * As in the majority of the scene they are the same (exception for multi room and so on),
  34460. * this is easier to set here than in all the materials.
  34461. */
  34462. environmentTexture: Nullable<BaseTexture>;
  34463. /** @hidden */
  34464. protected _environmentIntensity: number;
  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 reference from here than from all the materials.
  34470. */
  34471. /**
  34472. * Intensity of the environment in all pbr material.
  34473. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34474. * As in the majority of the scene they are the same (exception for multi room and so on),
  34475. * this is easier to set here than in all the materials.
  34476. */
  34477. environmentIntensity: number;
  34478. /** @hidden */
  34479. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34480. /**
  34481. * Default image processing configuration used either in the rendering
  34482. * Forward main pass or through the imageProcessingPostProcess if present.
  34483. * As in the majority of the scene they are the same (exception for multi camera),
  34484. * this is easier to reference from here than from all the materials and post process.
  34485. *
  34486. * No setter as we it is a shared configuration, you can set the values instead.
  34487. */
  34488. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34489. private _forceWireframe;
  34490. /**
  34491. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34492. */
  34493. forceWireframe: boolean;
  34494. private _forcePointsCloud;
  34495. /**
  34496. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34497. */
  34498. forcePointsCloud: boolean;
  34499. /**
  34500. * Gets or sets the active clipplane 1
  34501. */
  34502. clipPlane: Nullable<Plane>;
  34503. /**
  34504. * Gets or sets the active clipplane 2
  34505. */
  34506. clipPlane2: Nullable<Plane>;
  34507. /**
  34508. * Gets or sets the active clipplane 3
  34509. */
  34510. clipPlane3: Nullable<Plane>;
  34511. /**
  34512. * Gets or sets the active clipplane 4
  34513. */
  34514. clipPlane4: Nullable<Plane>;
  34515. /**
  34516. * Gets or sets a boolean indicating if animations are enabled
  34517. */
  34518. animationsEnabled: boolean;
  34519. private _animationPropertiesOverride;
  34520. /**
  34521. * Gets or sets the animation properties override
  34522. */
  34523. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34524. /**
  34525. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34526. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34527. */
  34528. useConstantAnimationDeltaTime: boolean;
  34529. /**
  34530. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34531. * Please note that it requires to run a ray cast through the scene on every frame
  34532. */
  34533. constantlyUpdateMeshUnderPointer: boolean;
  34534. /**
  34535. * Defines the HTML cursor to use when hovering over interactive elements
  34536. */
  34537. hoverCursor: string;
  34538. /**
  34539. * Defines the HTML default cursor to use (empty by default)
  34540. */
  34541. defaultCursor: string;
  34542. /**
  34543. * Defines wether cursors are handled by the scene.
  34544. */
  34545. doNotHandleCursors: boolean;
  34546. /**
  34547. * This is used to call preventDefault() on pointer down
  34548. * in order to block unwanted artifacts like system double clicks
  34549. */
  34550. preventDefaultOnPointerDown: boolean;
  34551. /**
  34552. * This is used to call preventDefault() on pointer up
  34553. * in order to block unwanted artifacts like system double clicks
  34554. */
  34555. preventDefaultOnPointerUp: boolean;
  34556. /**
  34557. * Gets or sets user defined metadata
  34558. */
  34559. metadata: any;
  34560. /**
  34561. * For internal use only. Please do not use.
  34562. */
  34563. reservedDataStore: any;
  34564. /**
  34565. * Gets the name of the plugin used to load this scene (null by default)
  34566. */
  34567. loadingPluginName: string;
  34568. /**
  34569. * Use this array to add regular expressions used to disable offline support for specific urls
  34570. */
  34571. disableOfflineSupportExceptionRules: RegExp[];
  34572. /**
  34573. * An event triggered when the scene is disposed.
  34574. */
  34575. onDisposeObservable: Observable<Scene>;
  34576. private _onDisposeObserver;
  34577. /** Sets a function to be executed when this scene is disposed. */
  34578. onDispose: () => void;
  34579. /**
  34580. * An event triggered before rendering the scene (right after animations and physics)
  34581. */
  34582. onBeforeRenderObservable: Observable<Scene>;
  34583. private _onBeforeRenderObserver;
  34584. /** Sets a function to be executed before rendering this scene */
  34585. beforeRender: Nullable<() => void>;
  34586. /**
  34587. * An event triggered after rendering the scene
  34588. */
  34589. onAfterRenderObservable: Observable<Scene>;
  34590. /**
  34591. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34592. */
  34593. onAfterRenderCameraObservable: Observable<Camera>;
  34594. private _onAfterRenderObserver;
  34595. /** Sets a function to be executed after rendering this scene */
  34596. afterRender: Nullable<() => void>;
  34597. /**
  34598. * An event triggered before animating the scene
  34599. */
  34600. onBeforeAnimationsObservable: Observable<Scene>;
  34601. /**
  34602. * An event triggered after animations processing
  34603. */
  34604. onAfterAnimationsObservable: Observable<Scene>;
  34605. /**
  34606. * An event triggered before draw calls are ready to be sent
  34607. */
  34608. onBeforeDrawPhaseObservable: Observable<Scene>;
  34609. /**
  34610. * An event triggered after draw calls have been sent
  34611. */
  34612. onAfterDrawPhaseObservable: Observable<Scene>;
  34613. /**
  34614. * An event triggered when the scene is ready
  34615. */
  34616. onReadyObservable: Observable<Scene>;
  34617. /**
  34618. * An event triggered before rendering a camera
  34619. */
  34620. onBeforeCameraRenderObservable: Observable<Camera>;
  34621. private _onBeforeCameraRenderObserver;
  34622. /** Sets a function to be executed before rendering a camera*/
  34623. beforeCameraRender: () => void;
  34624. /**
  34625. * An event triggered after rendering a camera
  34626. */
  34627. onAfterCameraRenderObservable: Observable<Camera>;
  34628. private _onAfterCameraRenderObserver;
  34629. /** Sets a function to be executed after rendering a camera*/
  34630. afterCameraRender: () => void;
  34631. /**
  34632. * An event triggered when active meshes evaluation is about to start
  34633. */
  34634. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34635. /**
  34636. * An event triggered when active meshes evaluation is done
  34637. */
  34638. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34639. /**
  34640. * An event triggered when particles rendering is about to start
  34641. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34642. */
  34643. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34644. /**
  34645. * An event triggered when particles rendering is done
  34646. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34647. */
  34648. onAfterParticlesRenderingObservable: Observable<Scene>;
  34649. /**
  34650. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34651. */
  34652. onDataLoadedObservable: Observable<Scene>;
  34653. /**
  34654. * An event triggered when a camera is created
  34655. */
  34656. onNewCameraAddedObservable: Observable<Camera>;
  34657. /**
  34658. * An event triggered when a camera is removed
  34659. */
  34660. onCameraRemovedObservable: Observable<Camera>;
  34661. /**
  34662. * An event triggered when a light is created
  34663. */
  34664. onNewLightAddedObservable: Observable<Light>;
  34665. /**
  34666. * An event triggered when a light is removed
  34667. */
  34668. onLightRemovedObservable: Observable<Light>;
  34669. /**
  34670. * An event triggered when a geometry is created
  34671. */
  34672. onNewGeometryAddedObservable: Observable<Geometry>;
  34673. /**
  34674. * An event triggered when a geometry is removed
  34675. */
  34676. onGeometryRemovedObservable: Observable<Geometry>;
  34677. /**
  34678. * An event triggered when a transform node is created
  34679. */
  34680. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34681. /**
  34682. * An event triggered when a transform node is removed
  34683. */
  34684. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34685. /**
  34686. * An event triggered when a mesh is created
  34687. */
  34688. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34689. /**
  34690. * An event triggered when a mesh is removed
  34691. */
  34692. onMeshRemovedObservable: Observable<AbstractMesh>;
  34693. /**
  34694. * An event triggered when a skeleton is created
  34695. */
  34696. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34697. /**
  34698. * An event triggered when a skeleton is removed
  34699. */
  34700. onSkeletonRemovedObservable: Observable<Skeleton>;
  34701. /**
  34702. * An event triggered when a material is created
  34703. */
  34704. onNewMaterialAddedObservable: Observable<Material>;
  34705. /**
  34706. * An event triggered when a material is removed
  34707. */
  34708. onMaterialRemovedObservable: Observable<Material>;
  34709. /**
  34710. * An event triggered when a texture is created
  34711. */
  34712. onNewTextureAddedObservable: Observable<BaseTexture>;
  34713. /**
  34714. * An event triggered when a texture is removed
  34715. */
  34716. onTextureRemovedObservable: Observable<BaseTexture>;
  34717. /**
  34718. * An event triggered when render targets are about to be rendered
  34719. * Can happen multiple times per frame.
  34720. */
  34721. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34722. /**
  34723. * An event triggered when render targets were rendered.
  34724. * Can happen multiple times per frame.
  34725. */
  34726. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34727. /**
  34728. * An event triggered before calculating deterministic simulation step
  34729. */
  34730. onBeforeStepObservable: Observable<Scene>;
  34731. /**
  34732. * An event triggered after calculating deterministic simulation step
  34733. */
  34734. onAfterStepObservable: Observable<Scene>;
  34735. /**
  34736. * An event triggered when the activeCamera property is updated
  34737. */
  34738. onActiveCameraChanged: Observable<Scene>;
  34739. /**
  34740. * This Observable will be triggered before 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. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34745. /**
  34746. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34747. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34748. * 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)
  34749. */
  34750. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34751. /**
  34752. * This Observable will when a mesh has been imported into the scene.
  34753. */
  34754. onMeshImportedObservable: Observable<AbstractMesh>;
  34755. /**
  34756. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34757. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34758. */
  34759. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34760. /** @hidden */
  34761. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34762. /**
  34763. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34764. */
  34765. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34766. /**
  34767. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34768. */
  34769. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34770. /**
  34771. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34772. */
  34773. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34774. /** Callback called when a pointer move is detected */
  34775. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34776. /** Callback called when a pointer down is detected */
  34777. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34778. /** Callback called when a pointer up is detected */
  34779. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34780. /** Callback called when a pointer pick is detected */
  34781. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34782. /**
  34783. * 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).
  34784. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34785. */
  34786. onPrePointerObservable: Observable<PointerInfoPre>;
  34787. /**
  34788. * Observable event triggered each time an input event is received from the rendering canvas
  34789. */
  34790. onPointerObservable: Observable<PointerInfo>;
  34791. /**
  34792. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34793. */
  34794. readonly unTranslatedPointer: Vector2;
  34795. /**
  34796. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34797. */
  34798. static DragMovementThreshold: number;
  34799. /**
  34800. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34801. */
  34802. static LongPressDelay: number;
  34803. /**
  34804. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34805. */
  34806. static DoubleClickDelay: number;
  34807. /** If you need to check double click without raising a single click at first click, enable this flag */
  34808. static ExclusiveDoubleClickMode: boolean;
  34809. /** @hidden */
  34810. _mirroredCameraPosition: Nullable<Vector3>;
  34811. /**
  34812. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34813. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34814. */
  34815. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34816. /**
  34817. * Observable event triggered each time an keyboard event is received from the hosting window
  34818. */
  34819. onKeyboardObservable: Observable<KeyboardInfo>;
  34820. private _useRightHandedSystem;
  34821. /**
  34822. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34823. */
  34824. useRightHandedSystem: boolean;
  34825. private _timeAccumulator;
  34826. private _currentStepId;
  34827. private _currentInternalStep;
  34828. /**
  34829. * Sets the step Id used by deterministic lock step
  34830. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34831. * @param newStepId defines the step Id
  34832. */
  34833. setStepId(newStepId: number): void;
  34834. /**
  34835. * Gets the step Id used by deterministic lock step
  34836. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34837. * @returns the step Id
  34838. */
  34839. getStepId(): number;
  34840. /**
  34841. * Gets the internal step used by deterministic lock step
  34842. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34843. * @returns the internal step
  34844. */
  34845. getInternalStep(): number;
  34846. private _fogEnabled;
  34847. /**
  34848. * Gets or sets a boolean indicating if fog is enabled on this scene
  34849. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34850. * (Default is true)
  34851. */
  34852. fogEnabled: boolean;
  34853. private _fogMode;
  34854. /**
  34855. * Gets or sets the fog mode to use
  34856. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34857. * | mode | value |
  34858. * | --- | --- |
  34859. * | FOGMODE_NONE | 0 |
  34860. * | FOGMODE_EXP | 1 |
  34861. * | FOGMODE_EXP2 | 2 |
  34862. * | FOGMODE_LINEAR | 3 |
  34863. */
  34864. fogMode: number;
  34865. /**
  34866. * Gets or sets the fog color to use
  34867. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34868. * (Default is Color3(0.2, 0.2, 0.3))
  34869. */
  34870. fogColor: Color3;
  34871. /**
  34872. * Gets or sets the fog density to use
  34873. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34874. * (Default is 0.1)
  34875. */
  34876. fogDensity: number;
  34877. /**
  34878. * Gets or sets the fog start distance to use
  34879. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34880. * (Default is 0)
  34881. */
  34882. fogStart: number;
  34883. /**
  34884. * Gets or sets the fog end distance to use
  34885. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34886. * (Default is 1000)
  34887. */
  34888. fogEnd: number;
  34889. private _shadowsEnabled;
  34890. /**
  34891. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34892. */
  34893. shadowsEnabled: boolean;
  34894. private _lightsEnabled;
  34895. /**
  34896. * Gets or sets a boolean indicating if lights are enabled on this scene
  34897. */
  34898. lightsEnabled: boolean;
  34899. /** All of the active cameras added to this scene. */
  34900. activeCameras: Camera[];
  34901. /** @hidden */
  34902. _activeCamera: Nullable<Camera>;
  34903. /** Gets or sets the current active camera */
  34904. activeCamera: Nullable<Camera>;
  34905. private _defaultMaterial;
  34906. /** The default material used on meshes when no material is affected */
  34907. /** The default material used on meshes when no material is affected */
  34908. defaultMaterial: Material;
  34909. private _texturesEnabled;
  34910. /**
  34911. * Gets or sets a boolean indicating if textures are enabled on this scene
  34912. */
  34913. texturesEnabled: boolean;
  34914. /**
  34915. * Gets or sets a boolean indicating if particles are enabled on this scene
  34916. */
  34917. particlesEnabled: boolean;
  34918. /**
  34919. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34920. */
  34921. spritesEnabled: boolean;
  34922. private _skeletonsEnabled;
  34923. /**
  34924. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34925. */
  34926. skeletonsEnabled: boolean;
  34927. /**
  34928. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34929. */
  34930. lensFlaresEnabled: boolean;
  34931. /**
  34932. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34933. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34934. */
  34935. collisionsEnabled: boolean;
  34936. private _collisionCoordinator;
  34937. /** @hidden */
  34938. readonly collisionCoordinator: ICollisionCoordinator;
  34939. /**
  34940. * Defines the gravity applied to this scene (used only for collisions)
  34941. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34942. */
  34943. gravity: Vector3;
  34944. /**
  34945. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34946. */
  34947. postProcessesEnabled: boolean;
  34948. /**
  34949. * The list of postprocesses added to the scene
  34950. */
  34951. postProcesses: PostProcess[];
  34952. /**
  34953. * Gets the current postprocess manager
  34954. */
  34955. postProcessManager: PostProcessManager;
  34956. /**
  34957. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34958. */
  34959. renderTargetsEnabled: boolean;
  34960. /**
  34961. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34962. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34963. */
  34964. dumpNextRenderTargets: boolean;
  34965. /**
  34966. * The list of user defined render targets added to the scene
  34967. */
  34968. customRenderTargets: RenderTargetTexture[];
  34969. /**
  34970. * Defines if texture loading must be delayed
  34971. * If true, textures will only be loaded when they need to be rendered
  34972. */
  34973. useDelayedTextureLoading: boolean;
  34974. /**
  34975. * Gets the list of meshes imported to the scene through SceneLoader
  34976. */
  34977. importedMeshesFiles: String[];
  34978. /**
  34979. * Gets or sets a boolean indicating if probes are enabled on this scene
  34980. */
  34981. probesEnabled: boolean;
  34982. /**
  34983. * Gets or sets the current offline provider to use to store scene data
  34984. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34985. */
  34986. offlineProvider: IOfflineProvider;
  34987. /**
  34988. * Gets or sets the action manager associated with the scene
  34989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34990. */
  34991. actionManager: AbstractActionManager;
  34992. private _meshesForIntersections;
  34993. /**
  34994. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34995. */
  34996. proceduralTexturesEnabled: boolean;
  34997. private _engine;
  34998. private _totalVertices;
  34999. /** @hidden */
  35000. _activeIndices: PerfCounter;
  35001. /** @hidden */
  35002. _activeParticles: PerfCounter;
  35003. /** @hidden */
  35004. _activeBones: PerfCounter;
  35005. private _animationRatio;
  35006. /** @hidden */
  35007. _animationTimeLast: number;
  35008. /** @hidden */
  35009. _animationTime: number;
  35010. /**
  35011. * Gets or sets a general scale for animation speed
  35012. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35013. */
  35014. animationTimeScale: number;
  35015. /** @hidden */
  35016. _cachedMaterial: Nullable<Material>;
  35017. /** @hidden */
  35018. _cachedEffect: Nullable<Effect>;
  35019. /** @hidden */
  35020. _cachedVisibility: Nullable<number>;
  35021. private _renderId;
  35022. private _frameId;
  35023. private _executeWhenReadyTimeoutId;
  35024. private _intermediateRendering;
  35025. private _viewUpdateFlag;
  35026. private _projectionUpdateFlag;
  35027. /** @hidden */
  35028. _toBeDisposed: Nullable<IDisposable>[];
  35029. private _activeRequests;
  35030. /** @hidden */
  35031. _pendingData: any[];
  35032. private _isDisposed;
  35033. /**
  35034. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35035. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35036. */
  35037. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35038. private _activeMeshes;
  35039. private _processedMaterials;
  35040. private _renderTargets;
  35041. /** @hidden */
  35042. _activeParticleSystems: SmartArray<IParticleSystem>;
  35043. private _activeSkeletons;
  35044. private _softwareSkinnedMeshes;
  35045. private _renderingManager;
  35046. /** @hidden */
  35047. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  35048. private _transformMatrix;
  35049. private _sceneUbo;
  35050. /** @hidden */
  35051. _viewMatrix: Matrix;
  35052. private _projectionMatrix;
  35053. /** @hidden */
  35054. _forcedViewPosition: Nullable<Vector3>;
  35055. /** @hidden */
  35056. _frustumPlanes: Plane[];
  35057. /**
  35058. * Gets the list of frustum planes (built from the active camera)
  35059. */
  35060. readonly frustumPlanes: Plane[];
  35061. /**
  35062. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35063. * This is useful if there are more lights that the maximum simulteanous authorized
  35064. */
  35065. requireLightSorting: boolean;
  35066. /** @hidden */
  35067. readonly useMaterialMeshMap: boolean;
  35068. /** @hidden */
  35069. readonly useClonedMeshhMap: boolean;
  35070. private _externalData;
  35071. private _uid;
  35072. /**
  35073. * @hidden
  35074. * Backing store of defined scene components.
  35075. */
  35076. _components: ISceneComponent[];
  35077. /**
  35078. * @hidden
  35079. * Backing store of defined scene components.
  35080. */
  35081. _serializableComponents: ISceneSerializableComponent[];
  35082. /**
  35083. * List of components to register on the next registration step.
  35084. */
  35085. private _transientComponents;
  35086. /**
  35087. * Registers the transient components if needed.
  35088. */
  35089. private _registerTransientComponents;
  35090. /**
  35091. * @hidden
  35092. * Add a component to the scene.
  35093. * Note that the ccomponent could be registered on th next frame if this is called after
  35094. * the register component stage.
  35095. * @param component Defines the component to add to the scene
  35096. */
  35097. _addComponent(component: ISceneComponent): void;
  35098. /**
  35099. * @hidden
  35100. * Gets a component from the scene.
  35101. * @param name defines the name of the component to retrieve
  35102. * @returns the component or null if not present
  35103. */
  35104. _getComponent(name: string): Nullable<ISceneComponent>;
  35105. /**
  35106. * @hidden
  35107. * Defines the actions happening before camera updates.
  35108. */
  35109. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35110. /**
  35111. * @hidden
  35112. * Defines the actions happening before clear the canvas.
  35113. */
  35114. _beforeClearStage: Stage<SimpleStageAction>;
  35115. /**
  35116. * @hidden
  35117. * Defines the actions when collecting render targets for the frame.
  35118. */
  35119. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35120. /**
  35121. * @hidden
  35122. * Defines the actions happening for one camera in the frame.
  35123. */
  35124. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35125. /**
  35126. * @hidden
  35127. * Defines the actions happening during the per mesh ready checks.
  35128. */
  35129. _isReadyForMeshStage: Stage<MeshStageAction>;
  35130. /**
  35131. * @hidden
  35132. * Defines the actions happening before evaluate active mesh checks.
  35133. */
  35134. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35135. /**
  35136. * @hidden
  35137. * Defines the actions happening during the evaluate sub mesh checks.
  35138. */
  35139. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35140. /**
  35141. * @hidden
  35142. * Defines the actions happening during the active mesh stage.
  35143. */
  35144. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35145. /**
  35146. * @hidden
  35147. * Defines the actions happening during the per camera render target step.
  35148. */
  35149. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35150. /**
  35151. * @hidden
  35152. * Defines the actions happening just before the active camera is drawing.
  35153. */
  35154. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35155. /**
  35156. * @hidden
  35157. * Defines the actions happening just before a render target is drawing.
  35158. */
  35159. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35160. /**
  35161. * @hidden
  35162. * Defines the actions happening just before a rendering group is drawing.
  35163. */
  35164. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35165. /**
  35166. * @hidden
  35167. * Defines the actions happening just before a mesh is drawing.
  35168. */
  35169. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35170. /**
  35171. * @hidden
  35172. * Defines the actions happening just after a mesh has been drawn.
  35173. */
  35174. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35175. /**
  35176. * @hidden
  35177. * Defines the actions happening just after a rendering group has been drawn.
  35178. */
  35179. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35180. /**
  35181. * @hidden
  35182. * Defines the actions happening just after the active camera has been drawn.
  35183. */
  35184. _afterCameraDrawStage: Stage<CameraStageAction>;
  35185. /**
  35186. * @hidden
  35187. * Defines the actions happening just after a render target has been drawn.
  35188. */
  35189. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35190. /**
  35191. * @hidden
  35192. * Defines the actions happening just after rendering all cameras and computing intersections.
  35193. */
  35194. _afterRenderStage: Stage<SimpleStageAction>;
  35195. /**
  35196. * @hidden
  35197. * Defines the actions happening when a pointer move event happens.
  35198. */
  35199. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35200. /**
  35201. * @hidden
  35202. * Defines the actions happening when a pointer down event happens.
  35203. */
  35204. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35205. /**
  35206. * @hidden
  35207. * Defines the actions happening when a pointer up event happens.
  35208. */
  35209. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35210. /**
  35211. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35212. */
  35213. private geometriesByUniqueId;
  35214. /**
  35215. * Creates a new Scene
  35216. * @param engine defines the engine to use to render this scene
  35217. * @param options defines the scene options
  35218. */
  35219. constructor(engine: Engine, options?: SceneOptions);
  35220. /**
  35221. * Gets a string idenfifying the name of the class
  35222. * @returns "Scene" string
  35223. */
  35224. getClassName(): string;
  35225. private _defaultMeshCandidates;
  35226. /**
  35227. * @hidden
  35228. */
  35229. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35230. private _defaultSubMeshCandidates;
  35231. /**
  35232. * @hidden
  35233. */
  35234. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35235. /**
  35236. * Sets the default candidate providers for the scene.
  35237. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35238. * and getCollidingSubMeshCandidates to their default function
  35239. */
  35240. setDefaultCandidateProviders(): void;
  35241. /**
  35242. * Gets the mesh that is currently under the pointer
  35243. */
  35244. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35245. /**
  35246. * Gets or sets the current on-screen X position of the pointer
  35247. */
  35248. pointerX: number;
  35249. /**
  35250. * Gets or sets the current on-screen Y position of the pointer
  35251. */
  35252. pointerY: number;
  35253. /**
  35254. * Gets the cached material (ie. the latest rendered one)
  35255. * @returns the cached material
  35256. */
  35257. getCachedMaterial(): Nullable<Material>;
  35258. /**
  35259. * Gets the cached effect (ie. the latest rendered one)
  35260. * @returns the cached effect
  35261. */
  35262. getCachedEffect(): Nullable<Effect>;
  35263. /**
  35264. * Gets the cached visibility state (ie. the latest rendered one)
  35265. * @returns the cached visibility state
  35266. */
  35267. getCachedVisibility(): Nullable<number>;
  35268. /**
  35269. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35270. * @param material defines the current material
  35271. * @param effect defines the current effect
  35272. * @param visibility defines the current visibility state
  35273. * @returns true if one parameter is not cached
  35274. */
  35275. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35276. /**
  35277. * Gets the engine associated with the scene
  35278. * @returns an Engine
  35279. */
  35280. getEngine(): Engine;
  35281. /**
  35282. * Gets the total number of vertices rendered per frame
  35283. * @returns the total number of vertices rendered per frame
  35284. */
  35285. getTotalVertices(): number;
  35286. /**
  35287. * Gets the performance counter for total vertices
  35288. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35289. */
  35290. readonly totalVerticesPerfCounter: PerfCounter;
  35291. /**
  35292. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35293. * @returns the total number of active indices rendered per frame
  35294. */
  35295. getActiveIndices(): number;
  35296. /**
  35297. * Gets the performance counter for active indices
  35298. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35299. */
  35300. readonly totalActiveIndicesPerfCounter: PerfCounter;
  35301. /**
  35302. * Gets the total number of active particles rendered per frame
  35303. * @returns the total number of active particles rendered per frame
  35304. */
  35305. getActiveParticles(): number;
  35306. /**
  35307. * Gets the performance counter for active particles
  35308. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35309. */
  35310. readonly activeParticlesPerfCounter: PerfCounter;
  35311. /**
  35312. * Gets the total number of active bones rendered per frame
  35313. * @returns the total number of active bones rendered per frame
  35314. */
  35315. getActiveBones(): number;
  35316. /**
  35317. * Gets the performance counter for active bones
  35318. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35319. */
  35320. readonly activeBonesPerfCounter: PerfCounter;
  35321. /**
  35322. * Gets the array of active meshes
  35323. * @returns an array of AbstractMesh
  35324. */
  35325. getActiveMeshes(): SmartArray<AbstractMesh>;
  35326. /**
  35327. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35328. * @returns a number
  35329. */
  35330. getAnimationRatio(): number;
  35331. /**
  35332. * Gets an unique Id for the current render phase
  35333. * @returns a number
  35334. */
  35335. getRenderId(): number;
  35336. /**
  35337. * Gets an unique Id for the current frame
  35338. * @returns a number
  35339. */
  35340. getFrameId(): number;
  35341. /** Call this function if you want to manually increment the render Id*/
  35342. incrementRenderId(): void;
  35343. private _createUbo;
  35344. /**
  35345. * Use this method to simulate a pointer move on a mesh
  35346. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35347. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35348. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35349. * @returns the current scene
  35350. */
  35351. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35352. /**
  35353. * Use this method to simulate a pointer down on a mesh
  35354. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35355. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35356. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35357. * @returns the current scene
  35358. */
  35359. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35360. /**
  35361. * Use this method to simulate a pointer up on a mesh
  35362. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35363. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35364. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35365. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35366. * @returns the current scene
  35367. */
  35368. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35369. /**
  35370. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35371. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35372. * @returns true if the pointer was captured
  35373. */
  35374. isPointerCaptured(pointerId?: number): boolean;
  35375. /**
  35376. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35377. * @param attachUp defines if you want to attach events to pointerup
  35378. * @param attachDown defines if you want to attach events to pointerdown
  35379. * @param attachMove defines if you want to attach events to pointermove
  35380. */
  35381. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35382. /** Detaches all event handlers*/
  35383. detachControl(): void;
  35384. /**
  35385. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35386. * Delay loaded resources are not taking in account
  35387. * @return true if all required resources are ready
  35388. */
  35389. isReady(): boolean;
  35390. /** Resets all cached information relative to material (including effect and visibility) */
  35391. resetCachedMaterial(): void;
  35392. /**
  35393. * Registers a function to be called before every frame render
  35394. * @param func defines the function to register
  35395. */
  35396. registerBeforeRender(func: () => void): void;
  35397. /**
  35398. * Unregisters a function called before every frame render
  35399. * @param func defines the function to unregister
  35400. */
  35401. unregisterBeforeRender(func: () => void): void;
  35402. /**
  35403. * Registers a function to be called after every frame render
  35404. * @param func defines the function to register
  35405. */
  35406. registerAfterRender(func: () => void): void;
  35407. /**
  35408. * Unregisters a function called after every frame render
  35409. * @param func defines the function to unregister
  35410. */
  35411. unregisterAfterRender(func: () => void): void;
  35412. private _executeOnceBeforeRender;
  35413. /**
  35414. * The provided function will run before render once and will be disposed afterwards.
  35415. * A timeout delay can be provided so that the function will be executed in N ms.
  35416. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35417. * @param func The function to be executed.
  35418. * @param timeout optional delay in ms
  35419. */
  35420. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35421. /** @hidden */
  35422. _addPendingData(data: any): void;
  35423. /** @hidden */
  35424. _removePendingData(data: any): void;
  35425. /**
  35426. * Returns the number of items waiting to be loaded
  35427. * @returns the number of items waiting to be loaded
  35428. */
  35429. getWaitingItemsCount(): number;
  35430. /**
  35431. * Returns a boolean indicating if the scene is still loading data
  35432. */
  35433. readonly isLoading: boolean;
  35434. /**
  35435. * Registers a function to be executed when the scene is ready
  35436. * @param {Function} func - the function to be executed
  35437. */
  35438. executeWhenReady(func: () => void): void;
  35439. /**
  35440. * Returns a promise that resolves when the scene is ready
  35441. * @returns A promise that resolves when the scene is ready
  35442. */
  35443. whenReadyAsync(): Promise<void>;
  35444. /** @hidden */
  35445. _checkIsReady(): void;
  35446. /**
  35447. * Gets all animatable attached to the scene
  35448. */
  35449. readonly animatables: Animatable[];
  35450. /**
  35451. * Resets the last animation time frame.
  35452. * Useful to override when animations start running when loading a scene for the first time.
  35453. */
  35454. resetLastAnimationTimeFrame(): void;
  35455. /**
  35456. * Gets the current view matrix
  35457. * @returns a Matrix
  35458. */
  35459. getViewMatrix(): Matrix;
  35460. /**
  35461. * Gets the current projection matrix
  35462. * @returns a Matrix
  35463. */
  35464. getProjectionMatrix(): Matrix;
  35465. /**
  35466. * Gets the current transform matrix
  35467. * @returns a Matrix made of View * Projection
  35468. */
  35469. getTransformMatrix(): Matrix;
  35470. /**
  35471. * Sets the current transform matrix
  35472. * @param viewL defines the View matrix to use
  35473. * @param projectionL defines the Projection matrix to use
  35474. * @param viewR defines the right View matrix to use (if provided)
  35475. * @param projectionR defines the right Projection matrix to use (if provided)
  35476. */
  35477. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35478. /**
  35479. * Gets the uniform buffer used to store scene data
  35480. * @returns a UniformBuffer
  35481. */
  35482. getSceneUniformBuffer(): UniformBuffer;
  35483. /**
  35484. * Gets an unique (relatively to the current scene) Id
  35485. * @returns an unique number for the scene
  35486. */
  35487. getUniqueId(): number;
  35488. /**
  35489. * Add a mesh to the list of scene's meshes
  35490. * @param newMesh defines the mesh to add
  35491. * @param recursive if all child meshes should also be added to the scene
  35492. */
  35493. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35494. /**
  35495. * Remove a mesh for the list of scene's meshes
  35496. * @param toRemove defines the mesh to remove
  35497. * @param recursive if all child meshes should also be removed from the scene
  35498. * @returns the index where the mesh was in the mesh list
  35499. */
  35500. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35501. /**
  35502. * Add a transform node to the list of scene's transform nodes
  35503. * @param newTransformNode defines the transform node to add
  35504. */
  35505. addTransformNode(newTransformNode: TransformNode): void;
  35506. /**
  35507. * Remove a transform node for the list of scene's transform nodes
  35508. * @param toRemove defines the transform node to remove
  35509. * @returns the index where the transform node was in the transform node list
  35510. */
  35511. removeTransformNode(toRemove: TransformNode): number;
  35512. /**
  35513. * Remove a skeleton for the list of scene's skeletons
  35514. * @param toRemove defines the skeleton to remove
  35515. * @returns the index where the skeleton was in the skeleton list
  35516. */
  35517. removeSkeleton(toRemove: Skeleton): number;
  35518. /**
  35519. * Remove a morph target for the list of scene's morph targets
  35520. * @param toRemove defines the morph target to remove
  35521. * @returns the index where the morph target was in the morph target list
  35522. */
  35523. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35524. /**
  35525. * Remove a light for the list of scene's lights
  35526. * @param toRemove defines the light to remove
  35527. * @returns the index where the light was in the light list
  35528. */
  35529. removeLight(toRemove: Light): number;
  35530. /**
  35531. * Remove a camera for the list of scene's cameras
  35532. * @param toRemove defines the camera to remove
  35533. * @returns the index where the camera was in the camera list
  35534. */
  35535. removeCamera(toRemove: Camera): number;
  35536. /**
  35537. * Remove a particle system for the list of scene's particle systems
  35538. * @param toRemove defines the particle system to remove
  35539. * @returns the index where the particle system was in the particle system list
  35540. */
  35541. removeParticleSystem(toRemove: IParticleSystem): number;
  35542. /**
  35543. * Remove a animation for the list of scene's animations
  35544. * @param toRemove defines the animation to remove
  35545. * @returns the index where the animation was in the animation list
  35546. */
  35547. removeAnimation(toRemove: Animation): number;
  35548. /**
  35549. * Will stop the animation of the given target
  35550. * @param target - the target
  35551. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35552. * @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)
  35553. */
  35554. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35555. /**
  35556. * Removes the given animation group from this scene.
  35557. * @param toRemove The animation group to remove
  35558. * @returns The index of the removed animation group
  35559. */
  35560. removeAnimationGroup(toRemove: AnimationGroup): number;
  35561. /**
  35562. * Removes the given multi-material from this scene.
  35563. * @param toRemove The multi-material to remove
  35564. * @returns The index of the removed multi-material
  35565. */
  35566. removeMultiMaterial(toRemove: MultiMaterial): number;
  35567. /**
  35568. * Removes the given material from this scene.
  35569. * @param toRemove The material to remove
  35570. * @returns The index of the removed material
  35571. */
  35572. removeMaterial(toRemove: Material): number;
  35573. /**
  35574. * Removes the given action manager from this scene.
  35575. * @param toRemove The action manager to remove
  35576. * @returns The index of the removed action manager
  35577. */
  35578. removeActionManager(toRemove: AbstractActionManager): number;
  35579. /**
  35580. * Removes the given texture from this scene.
  35581. * @param toRemove The texture to remove
  35582. * @returns The index of the removed texture
  35583. */
  35584. removeTexture(toRemove: BaseTexture): number;
  35585. /**
  35586. * Adds the given light to this scene
  35587. * @param newLight The light to add
  35588. */
  35589. addLight(newLight: Light): void;
  35590. /**
  35591. * Sorts the list list based on light priorities
  35592. */
  35593. sortLightsByPriority(): void;
  35594. /**
  35595. * Adds the given camera to this scene
  35596. * @param newCamera The camera to add
  35597. */
  35598. addCamera(newCamera: Camera): void;
  35599. /**
  35600. * Adds the given skeleton to this scene
  35601. * @param newSkeleton The skeleton to add
  35602. */
  35603. addSkeleton(newSkeleton: Skeleton): void;
  35604. /**
  35605. * Adds the given particle system to this scene
  35606. * @param newParticleSystem The particle system to add
  35607. */
  35608. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35609. /**
  35610. * Adds the given animation to this scene
  35611. * @param newAnimation The animation to add
  35612. */
  35613. addAnimation(newAnimation: Animation): void;
  35614. /**
  35615. * Adds the given animation group to this scene.
  35616. * @param newAnimationGroup The animation group to add
  35617. */
  35618. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35619. /**
  35620. * Adds the given multi-material to this scene
  35621. * @param newMultiMaterial The multi-material to add
  35622. */
  35623. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35624. /**
  35625. * Adds the given material to this scene
  35626. * @param newMaterial The material to add
  35627. */
  35628. addMaterial(newMaterial: Material): void;
  35629. /**
  35630. * Adds the given morph target to this scene
  35631. * @param newMorphTargetManager The morph target to add
  35632. */
  35633. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35634. /**
  35635. * Adds the given geometry to this scene
  35636. * @param newGeometry The geometry to add
  35637. */
  35638. addGeometry(newGeometry: Geometry): void;
  35639. /**
  35640. * Adds the given action manager to this scene
  35641. * @param newActionManager The action manager to add
  35642. */
  35643. addActionManager(newActionManager: AbstractActionManager): void;
  35644. /**
  35645. * Adds the given texture to this scene.
  35646. * @param newTexture The texture to add
  35647. */
  35648. addTexture(newTexture: BaseTexture): void;
  35649. /**
  35650. * Switch active camera
  35651. * @param newCamera defines the new active camera
  35652. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35653. */
  35654. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35655. /**
  35656. * sets the active camera of the scene using its ID
  35657. * @param id defines the camera's ID
  35658. * @return the new active camera or null if none found.
  35659. */
  35660. setActiveCameraByID(id: string): Nullable<Camera>;
  35661. /**
  35662. * sets the active camera of the scene using its name
  35663. * @param name defines the camera's name
  35664. * @returns the new active camera or null if none found.
  35665. */
  35666. setActiveCameraByName(name: string): Nullable<Camera>;
  35667. /**
  35668. * get an animation group using its name
  35669. * @param name defines the material's name
  35670. * @return the animation group or null if none found.
  35671. */
  35672. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35673. /**
  35674. * Get a material using its unique id
  35675. * @param uniqueId defines the material's unique id
  35676. * @return the material or null if none found.
  35677. */
  35678. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35679. /**
  35680. * get a material using its id
  35681. * @param id defines the material's ID
  35682. * @return the material or null if none found.
  35683. */
  35684. getMaterialByID(id: string): Nullable<Material>;
  35685. /**
  35686. * Gets a the last added material using a given id
  35687. * @param id defines the material's ID
  35688. * @return the last material with the given id or null if none found.
  35689. */
  35690. getLastMaterialByID(id: string): Nullable<Material>;
  35691. /**
  35692. * Gets a material using its name
  35693. * @param name defines the material's name
  35694. * @return the material or null if none found.
  35695. */
  35696. getMaterialByName(name: string): Nullable<Material>;
  35697. /**
  35698. * Get a texture using its unique id
  35699. * @param uniqueId defines the texture's unique id
  35700. * @return the texture or null if none found.
  35701. */
  35702. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35703. /**
  35704. * Gets a camera using its id
  35705. * @param id defines the id to look for
  35706. * @returns the camera or null if not found
  35707. */
  35708. getCameraByID(id: string): Nullable<Camera>;
  35709. /**
  35710. * Gets a camera using its unique id
  35711. * @param uniqueId defines the unique id to look for
  35712. * @returns the camera or null if not found
  35713. */
  35714. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35715. /**
  35716. * Gets a camera using its name
  35717. * @param name defines the camera's name
  35718. * @return the camera or null if none found.
  35719. */
  35720. getCameraByName(name: string): Nullable<Camera>;
  35721. /**
  35722. * Gets a bone using its id
  35723. * @param id defines the bone's id
  35724. * @return the bone or null if not found
  35725. */
  35726. getBoneByID(id: string): Nullable<Bone>;
  35727. /**
  35728. * Gets a bone using its id
  35729. * @param name defines the bone's name
  35730. * @return the bone or null if not found
  35731. */
  35732. getBoneByName(name: string): Nullable<Bone>;
  35733. /**
  35734. * Gets a light node using its name
  35735. * @param name defines the the light's name
  35736. * @return the light or null if none found.
  35737. */
  35738. getLightByName(name: string): Nullable<Light>;
  35739. /**
  35740. * Gets a light node using its id
  35741. * @param id defines the light's id
  35742. * @return the light or null if none found.
  35743. */
  35744. getLightByID(id: string): Nullable<Light>;
  35745. /**
  35746. * Gets a light node using its scene-generated unique ID
  35747. * @param uniqueId defines the light's unique id
  35748. * @return the light or null if none found.
  35749. */
  35750. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35751. /**
  35752. * Gets a particle system by id
  35753. * @param id defines the particle system id
  35754. * @return the corresponding system or null if none found
  35755. */
  35756. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35757. /**
  35758. * Gets a geometry using its ID
  35759. * @param id defines the geometry's id
  35760. * @return the geometry or null if none found.
  35761. */
  35762. getGeometryByID(id: string): Nullable<Geometry>;
  35763. private _getGeometryByUniqueID;
  35764. /**
  35765. * Add a new geometry to this scene
  35766. * @param geometry defines the geometry to be added to the scene.
  35767. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35768. * @return a boolean defining if the geometry was added or not
  35769. */
  35770. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35771. /**
  35772. * Removes an existing geometry
  35773. * @param geometry defines the geometry to be removed from the scene
  35774. * @return a boolean defining if the geometry was removed or not
  35775. */
  35776. removeGeometry(geometry: Geometry): boolean;
  35777. /**
  35778. * Gets the list of geometries attached to the scene
  35779. * @returns an array of Geometry
  35780. */
  35781. getGeometries(): Geometry[];
  35782. /**
  35783. * Gets the first added mesh found of a given ID
  35784. * @param id defines the id to search for
  35785. * @return the mesh found or null if not found at all
  35786. */
  35787. getMeshByID(id: string): Nullable<AbstractMesh>;
  35788. /**
  35789. * Gets a list of meshes using their id
  35790. * @param id defines the id to search for
  35791. * @returns a list of meshes
  35792. */
  35793. getMeshesByID(id: string): Array<AbstractMesh>;
  35794. /**
  35795. * Gets the first added transform node found of a given ID
  35796. * @param id defines the id to search for
  35797. * @return the found transform node or null if not found at all.
  35798. */
  35799. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35800. /**
  35801. * Gets a transform node with its auto-generated unique id
  35802. * @param uniqueId efines the unique id to search for
  35803. * @return the found transform node or null if not found at all.
  35804. */
  35805. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35806. /**
  35807. * Gets a list of transform nodes using their id
  35808. * @param id defines the id to search for
  35809. * @returns a list of transform nodes
  35810. */
  35811. getTransformNodesByID(id: string): Array<TransformNode>;
  35812. /**
  35813. * Gets a mesh with its auto-generated unique id
  35814. * @param uniqueId defines the unique id to search for
  35815. * @return the found mesh or null if not found at all.
  35816. */
  35817. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35818. /**
  35819. * Gets a the last added mesh using a given id
  35820. * @param id defines the id to search for
  35821. * @return the found mesh or null if not found at all.
  35822. */
  35823. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35824. /**
  35825. * Gets a the last added 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. getLastEntryByID(id: string): Nullable<Node>;
  35830. /**
  35831. * Gets a node (Mesh, Camera, Light) using a given id
  35832. * @param id defines the id to search for
  35833. * @return the found node or null if not found at all
  35834. */
  35835. getNodeByID(id: string): Nullable<Node>;
  35836. /**
  35837. * Gets a node (Mesh, Camera, Light) using a given name
  35838. * @param name defines the name to search for
  35839. * @return the found node or null if not found at all.
  35840. */
  35841. getNodeByName(name: string): Nullable<Node>;
  35842. /**
  35843. * Gets a mesh using a given name
  35844. * @param name defines the name to search for
  35845. * @return the found mesh or null if not found at all.
  35846. */
  35847. getMeshByName(name: string): Nullable<AbstractMesh>;
  35848. /**
  35849. * Gets a transform node using a given name
  35850. * @param name defines the name to search for
  35851. * @return the found transform node or null if not found at all.
  35852. */
  35853. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35854. /**
  35855. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35856. * @param id defines the id to search for
  35857. * @return the found skeleton or null if not found at all.
  35858. */
  35859. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35860. /**
  35861. * Gets a skeleton using a given auto generated unique id
  35862. * @param uniqueId defines the unique id to search for
  35863. * @return the found skeleton or null if not found at all.
  35864. */
  35865. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35866. /**
  35867. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35868. * @param id defines the id to search for
  35869. * @return the found skeleton or null if not found at all.
  35870. */
  35871. getSkeletonById(id: string): Nullable<Skeleton>;
  35872. /**
  35873. * Gets a skeleton using a given name
  35874. * @param name defines the name to search for
  35875. * @return the found skeleton or null if not found at all.
  35876. */
  35877. getSkeletonByName(name: string): Nullable<Skeleton>;
  35878. /**
  35879. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35880. * @param id defines the id to search for
  35881. * @return the found morph target manager or null if not found at all.
  35882. */
  35883. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35884. /**
  35885. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35886. * @param id defines the id to search for
  35887. * @return the found morph target or null if not found at all.
  35888. */
  35889. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35890. /**
  35891. * Gets a boolean indicating if the given mesh is active
  35892. * @param mesh defines the mesh to look for
  35893. * @returns true if the mesh is in the active list
  35894. */
  35895. isActiveMesh(mesh: AbstractMesh): boolean;
  35896. /**
  35897. * Return a unique id as a string which can serve as an identifier for the scene
  35898. */
  35899. readonly uid: string;
  35900. /**
  35901. * Add an externaly attached data from its key.
  35902. * This method call will fail and return false, if such key already exists.
  35903. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35904. * @param key the unique key that identifies the data
  35905. * @param data the data object to associate to the key for this Engine instance
  35906. * @return true if no such key were already present and the data was added successfully, false otherwise
  35907. */
  35908. addExternalData<T>(key: string, data: T): boolean;
  35909. /**
  35910. * Get an externaly attached data from its key
  35911. * @param key the unique key that identifies the data
  35912. * @return the associated data, if present (can be null), or undefined if not present
  35913. */
  35914. getExternalData<T>(key: string): Nullable<T>;
  35915. /**
  35916. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35917. * @param key the unique key that identifies the data
  35918. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35919. * @return the associated data, can be null if the factory returned null.
  35920. */
  35921. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35922. /**
  35923. * Remove an externaly attached data from the Engine instance
  35924. * @param key the unique key that identifies the data
  35925. * @return true if the data was successfully removed, false if it doesn't exist
  35926. */
  35927. removeExternalData(key: string): boolean;
  35928. private _evaluateSubMesh;
  35929. /**
  35930. * Clear the processed materials smart array preventing retention point in material dispose.
  35931. */
  35932. freeProcessedMaterials(): void;
  35933. private _preventFreeActiveMeshesAndRenderingGroups;
  35934. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35935. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35936. * when disposing several meshes in a row or a hierarchy of meshes.
  35937. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35938. */
  35939. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35940. /**
  35941. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35942. */
  35943. freeActiveMeshes(): void;
  35944. /**
  35945. * Clear the info related to rendering groups preventing retention points during dispose.
  35946. */
  35947. freeRenderingGroups(): void;
  35948. /** @hidden */
  35949. _isInIntermediateRendering(): boolean;
  35950. /**
  35951. * Lambda returning the list of potentially active meshes.
  35952. */
  35953. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35954. /**
  35955. * Lambda returning the list of potentially active sub meshes.
  35956. */
  35957. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35958. /**
  35959. * Lambda returning the list of potentially intersecting sub meshes.
  35960. */
  35961. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35962. /**
  35963. * Lambda returning the list of potentially colliding sub meshes.
  35964. */
  35965. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35966. private _activeMeshesFrozen;
  35967. private _skipEvaluateActiveMeshesCompletely;
  35968. /**
  35969. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35970. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  35971. * @returns the current scene
  35972. */
  35973. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  35974. /**
  35975. * Use this function to restart evaluating active meshes on every frame
  35976. * @returns the current scene
  35977. */
  35978. unfreezeActiveMeshes(): Scene;
  35979. private _evaluateActiveMeshes;
  35980. private _activeMesh;
  35981. /**
  35982. * Update the transform matrix to update from the current active camera
  35983. * @param force defines a boolean used to force the update even if cache is up to date
  35984. */
  35985. updateTransformMatrix(force?: boolean): void;
  35986. private _bindFrameBuffer;
  35987. /** @hidden */
  35988. _allowPostProcessClearColor: boolean;
  35989. /** @hidden */
  35990. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35991. private _processSubCameras;
  35992. private _checkIntersections;
  35993. /** @hidden */
  35994. _advancePhysicsEngineStep(step: number): void;
  35995. /**
  35996. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35997. */
  35998. getDeterministicFrameTime: () => number;
  35999. /** @hidden */
  36000. _animate(): void;
  36001. /** Execute all animations (for a frame) */
  36002. animate(): void;
  36003. /**
  36004. * Render the scene
  36005. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36006. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36007. */
  36008. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36009. /**
  36010. * Freeze all materials
  36011. * A frozen material will not be updatable but should be faster to render
  36012. */
  36013. freezeMaterials(): void;
  36014. /**
  36015. * Unfreeze all materials
  36016. * A frozen material will not be updatable but should be faster to render
  36017. */
  36018. unfreezeMaterials(): void;
  36019. /**
  36020. * Releases all held ressources
  36021. */
  36022. dispose(): void;
  36023. /**
  36024. * Gets if the scene is already disposed
  36025. */
  36026. readonly isDisposed: boolean;
  36027. /**
  36028. * Call this function to reduce memory footprint of the scene.
  36029. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36030. */
  36031. clearCachedVertexData(): void;
  36032. /**
  36033. * This function will remove the local cached buffer data from texture.
  36034. * It will save memory but will prevent the texture from being rebuilt
  36035. */
  36036. cleanCachedTextureBuffer(): void;
  36037. /**
  36038. * Get the world extend vectors with an optional filter
  36039. *
  36040. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36041. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36042. */
  36043. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36044. min: Vector3;
  36045. max: Vector3;
  36046. };
  36047. /**
  36048. * Creates a ray that can be used to pick in the scene
  36049. * @param x defines the x coordinate of the origin (on-screen)
  36050. * @param y defines the y coordinate of the origin (on-screen)
  36051. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36052. * @param camera defines the camera to use for the picking
  36053. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36054. * @returns a Ray
  36055. */
  36056. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36057. /**
  36058. * Creates a ray that can be used to pick in the scene
  36059. * @param x defines the x coordinate of the origin (on-screen)
  36060. * @param y defines the y coordinate of the origin (on-screen)
  36061. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36062. * @param result defines the ray where to store the picking ray
  36063. * @param camera defines the camera to use for the picking
  36064. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36065. * @returns the current scene
  36066. */
  36067. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36068. /**
  36069. * Creates a ray that can be used to pick in the scene
  36070. * @param x defines the x coordinate of the origin (on-screen)
  36071. * @param y defines the y coordinate of the origin (on-screen)
  36072. * @param camera defines the camera to use for the picking
  36073. * @returns a Ray
  36074. */
  36075. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36076. /**
  36077. * Creates a ray that can be used to pick in the scene
  36078. * @param x defines the x coordinate of the origin (on-screen)
  36079. * @param y defines the y coordinate of the origin (on-screen)
  36080. * @param result defines the ray where to store the picking ray
  36081. * @param camera defines the camera to use for the picking
  36082. * @returns the current scene
  36083. */
  36084. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36085. /** Launch a ray to try to pick a mesh in the scene
  36086. * @param x position on screen
  36087. * @param y position on screen
  36088. * @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
  36089. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36090. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36091. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36092. * @returns a PickingInfo
  36093. */
  36094. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36095. /** Use the given ray to pick a mesh in the scene
  36096. * @param ray The ray to use to pick meshes
  36097. * @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
  36098. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36099. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36100. * @returns a PickingInfo
  36101. */
  36102. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36103. /**
  36104. * Launch a ray to try to pick a mesh in the scene
  36105. * @param x X position on screen
  36106. * @param y Y position on screen
  36107. * @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
  36108. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36109. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36110. * @returns an array of PickingInfo
  36111. */
  36112. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36113. /**
  36114. * Launch a ray to try to pick a mesh in the scene
  36115. * @param ray Ray to use
  36116. * @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
  36117. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36118. * @returns an array of PickingInfo
  36119. */
  36120. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36121. /**
  36122. * Force the value of meshUnderPointer
  36123. * @param mesh defines the mesh to use
  36124. */
  36125. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36126. /**
  36127. * Gets the mesh under the pointer
  36128. * @returns a Mesh or null if no mesh is under the pointer
  36129. */
  36130. getPointerOverMesh(): Nullable<AbstractMesh>;
  36131. /** @hidden */
  36132. _rebuildGeometries(): void;
  36133. /** @hidden */
  36134. _rebuildTextures(): void;
  36135. private _getByTags;
  36136. /**
  36137. * Get a list of meshes by tags
  36138. * @param tagsQuery defines the tags query to use
  36139. * @param forEach defines a predicate used to filter results
  36140. * @returns an array of Mesh
  36141. */
  36142. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36143. /**
  36144. * Get a list of cameras by tags
  36145. * @param tagsQuery defines the tags query to use
  36146. * @param forEach defines a predicate used to filter results
  36147. * @returns an array of Camera
  36148. */
  36149. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36150. /**
  36151. * Get a list of lights by tags
  36152. * @param tagsQuery defines the tags query to use
  36153. * @param forEach defines a predicate used to filter results
  36154. * @returns an array of Light
  36155. */
  36156. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36157. /**
  36158. * Get a list of materials by tags
  36159. * @param tagsQuery defines the tags query to use
  36160. * @param forEach defines a predicate used to filter results
  36161. * @returns an array of Material
  36162. */
  36163. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36164. /**
  36165. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36166. * This allowed control for front to back rendering or reversly depending of the special needs.
  36167. *
  36168. * @param renderingGroupId The rendering group id corresponding to its index
  36169. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36170. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36171. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36172. */
  36173. 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;
  36174. /**
  36175. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36176. *
  36177. * @param renderingGroupId The rendering group id corresponding to its index
  36178. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36179. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36180. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36181. */
  36182. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36183. /**
  36184. * Gets the current auto clear configuration for one rendering group of the rendering
  36185. * manager.
  36186. * @param index the rendering group index to get the information for
  36187. * @returns The auto clear setup for the requested rendering group
  36188. */
  36189. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36190. private _blockMaterialDirtyMechanism;
  36191. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36192. blockMaterialDirtyMechanism: boolean;
  36193. /**
  36194. * Will flag all materials as dirty to trigger new shader compilation
  36195. * @param flag defines the flag used to specify which material part must be marked as dirty
  36196. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36197. */
  36198. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36199. /** @hidden */
  36200. _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;
  36201. /** @hidden */
  36202. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36203. /** @hidden */
  36204. _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;
  36205. /** @hidden */
  36206. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36207. /** @hidden */
  36208. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36209. /** @hidden */
  36210. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36211. }
  36212. }
  36213. declare module "babylonjs/assetContainer" {
  36214. import { AbstractScene } from "babylonjs/abstractScene";
  36215. import { Scene } from "babylonjs/scene";
  36216. import { Mesh } from "babylonjs/Meshes/mesh";
  36217. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36218. import { Skeleton } from "babylonjs/Bones/skeleton";
  36219. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36220. /**
  36221. * Set of assets to keep when moving a scene into an asset container.
  36222. */
  36223. export class KeepAssets extends AbstractScene {
  36224. }
  36225. /**
  36226. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36227. */
  36228. export class InstantiatedEntries {
  36229. /**
  36230. * List of new root nodes (eg. nodes with no parent)
  36231. */
  36232. rootNodes: TransformNode[];
  36233. /**
  36234. * List of new skeletons
  36235. */
  36236. skeletons: Skeleton[];
  36237. /**
  36238. * List of new animation groups
  36239. */
  36240. animationGroups: AnimationGroup[];
  36241. }
  36242. /**
  36243. * Container with a set of assets that can be added or removed from a scene.
  36244. */
  36245. export class AssetContainer extends AbstractScene {
  36246. /**
  36247. * The scene the AssetContainer belongs to.
  36248. */
  36249. scene: Scene;
  36250. /**
  36251. * Instantiates an AssetContainer.
  36252. * @param scene The scene the AssetContainer belongs to.
  36253. */
  36254. constructor(scene: Scene);
  36255. /**
  36256. * Instantiate or clone all meshes and add the new ones to the scene.
  36257. * Skeletons and animation groups will all be cloned
  36258. * @param nameFunction defines an optional function used to get new names for clones
  36259. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36260. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36261. */
  36262. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36263. /**
  36264. * Adds all the assets from the container to the scene.
  36265. */
  36266. addAllToScene(): void;
  36267. /**
  36268. * Removes all the assets in the container from the scene
  36269. */
  36270. removeAllFromScene(): void;
  36271. /**
  36272. * Disposes all the assets in the container
  36273. */
  36274. dispose(): void;
  36275. private _moveAssets;
  36276. /**
  36277. * Removes all the assets contained in the scene and adds them to the container.
  36278. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36279. */
  36280. moveAllFromScene(keepAssets?: KeepAssets): void;
  36281. /**
  36282. * 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.
  36283. * @returns the root mesh
  36284. */
  36285. createRootMesh(): Mesh;
  36286. }
  36287. }
  36288. declare module "babylonjs/abstractScene" {
  36289. import { Scene } from "babylonjs/scene";
  36290. import { Nullable } from "babylonjs/types";
  36291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36292. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36293. import { Geometry } from "babylonjs/Meshes/geometry";
  36294. import { Skeleton } from "babylonjs/Bones/skeleton";
  36295. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36296. import { AssetContainer } from "babylonjs/assetContainer";
  36297. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36298. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36299. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36300. import { Material } from "babylonjs/Materials/material";
  36301. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36302. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36303. import { Camera } from "babylonjs/Cameras/camera";
  36304. import { Light } from "babylonjs/Lights/light";
  36305. import { Node } from "babylonjs/node";
  36306. import { Animation } from "babylonjs/Animations/animation";
  36307. /**
  36308. * Defines how the parser contract is defined.
  36309. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36310. */
  36311. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36312. /**
  36313. * Defines how the individual parser contract is defined.
  36314. * These parser can parse an individual asset
  36315. */
  36316. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36317. /**
  36318. * Base class of the scene acting as a container for the different elements composing a scene.
  36319. * This class is dynamically extended by the different components of the scene increasing
  36320. * flexibility and reducing coupling
  36321. */
  36322. export abstract class AbstractScene {
  36323. /**
  36324. * Stores the list of available parsers in the application.
  36325. */
  36326. private static _BabylonFileParsers;
  36327. /**
  36328. * Stores the list of available individual parsers in the application.
  36329. */
  36330. private static _IndividualBabylonFileParsers;
  36331. /**
  36332. * Adds a parser in the list of available ones
  36333. * @param name Defines the name of the parser
  36334. * @param parser Defines the parser to add
  36335. */
  36336. static AddParser(name: string, parser: BabylonFileParser): void;
  36337. /**
  36338. * Gets a general parser from the list of avaialble ones
  36339. * @param name Defines the name of the parser
  36340. * @returns the requested parser or null
  36341. */
  36342. static GetParser(name: string): Nullable<BabylonFileParser>;
  36343. /**
  36344. * Adds n individual parser in the list of available ones
  36345. * @param name Defines the name of the parser
  36346. * @param parser Defines the parser to add
  36347. */
  36348. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36349. /**
  36350. * Gets an individual parser from the list of avaialble ones
  36351. * @param name Defines the name of the parser
  36352. * @returns the requested parser or null
  36353. */
  36354. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36355. /**
  36356. * Parser json data and populate both a scene and its associated container object
  36357. * @param jsonData Defines the data to parse
  36358. * @param scene Defines the scene to parse the data for
  36359. * @param container Defines the container attached to the parsing sequence
  36360. * @param rootUrl Defines the root url of the data
  36361. */
  36362. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36363. /**
  36364. * Gets the list of root nodes (ie. nodes with no parent)
  36365. */
  36366. rootNodes: Node[];
  36367. /** All of the cameras added to this scene
  36368. * @see http://doc.babylonjs.com/babylon101/cameras
  36369. */
  36370. cameras: Camera[];
  36371. /**
  36372. * All of the lights added to this scene
  36373. * @see http://doc.babylonjs.com/babylon101/lights
  36374. */
  36375. lights: Light[];
  36376. /**
  36377. * All of the (abstract) meshes added to this scene
  36378. */
  36379. meshes: AbstractMesh[];
  36380. /**
  36381. * The list of skeletons added to the scene
  36382. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36383. */
  36384. skeletons: Skeleton[];
  36385. /**
  36386. * All of the particle systems added to this scene
  36387. * @see http://doc.babylonjs.com/babylon101/particles
  36388. */
  36389. particleSystems: IParticleSystem[];
  36390. /**
  36391. * Gets a list of Animations associated with the scene
  36392. */
  36393. animations: Animation[];
  36394. /**
  36395. * All of the animation groups added to this scene
  36396. * @see http://doc.babylonjs.com/how_to/group
  36397. */
  36398. animationGroups: AnimationGroup[];
  36399. /**
  36400. * All of the multi-materials added to this scene
  36401. * @see http://doc.babylonjs.com/how_to/multi_materials
  36402. */
  36403. multiMaterials: MultiMaterial[];
  36404. /**
  36405. * All of the materials added to this scene
  36406. * In the context of a Scene, it is not supposed to be modified manually.
  36407. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36408. * Note also that the order of the Material within the array is not significant and might change.
  36409. * @see http://doc.babylonjs.com/babylon101/materials
  36410. */
  36411. materials: Material[];
  36412. /**
  36413. * The list of morph target managers added to the scene
  36414. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36415. */
  36416. morphTargetManagers: MorphTargetManager[];
  36417. /**
  36418. * The list of geometries used in the scene.
  36419. */
  36420. geometries: Geometry[];
  36421. /**
  36422. * All of the tranform nodes added to this scene
  36423. * In the context of a Scene, it is not supposed to be modified manually.
  36424. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36425. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36426. * @see http://doc.babylonjs.com/how_to/transformnode
  36427. */
  36428. transformNodes: TransformNode[];
  36429. /**
  36430. * ActionManagers available on the scene.
  36431. */
  36432. actionManagers: AbstractActionManager[];
  36433. /**
  36434. * Textures to keep.
  36435. */
  36436. textures: BaseTexture[];
  36437. /**
  36438. * Environment texture for the scene
  36439. */
  36440. environmentTexture: Nullable<BaseTexture>;
  36441. }
  36442. }
  36443. declare module "babylonjs/Audio/sound" {
  36444. import { Observable } from "babylonjs/Misc/observable";
  36445. import { Vector3 } from "babylonjs/Maths/math.vector";
  36446. import { Nullable } from "babylonjs/types";
  36447. import { Scene } from "babylonjs/scene";
  36448. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36449. /**
  36450. * Interface used to define options for Sound class
  36451. */
  36452. export interface ISoundOptions {
  36453. /**
  36454. * Does the sound autoplay once loaded.
  36455. */
  36456. autoplay?: boolean;
  36457. /**
  36458. * Does the sound loop after it finishes playing once.
  36459. */
  36460. loop?: boolean;
  36461. /**
  36462. * Sound's volume
  36463. */
  36464. volume?: number;
  36465. /**
  36466. * Is it a spatial sound?
  36467. */
  36468. spatialSound?: boolean;
  36469. /**
  36470. * Maximum distance to hear that sound
  36471. */
  36472. maxDistance?: number;
  36473. /**
  36474. * Uses user defined attenuation function
  36475. */
  36476. useCustomAttenuation?: boolean;
  36477. /**
  36478. * Define the roll off factor of spatial sounds.
  36479. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36480. */
  36481. rolloffFactor?: number;
  36482. /**
  36483. * Define the reference distance the sound should be heard perfectly.
  36484. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36485. */
  36486. refDistance?: number;
  36487. /**
  36488. * Define the distance attenuation model the sound will follow.
  36489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36490. */
  36491. distanceModel?: string;
  36492. /**
  36493. * Defines the playback speed (1 by default)
  36494. */
  36495. playbackRate?: number;
  36496. /**
  36497. * Defines if the sound is from a streaming source
  36498. */
  36499. streaming?: boolean;
  36500. /**
  36501. * Defines an optional length (in seconds) inside the sound file
  36502. */
  36503. length?: number;
  36504. /**
  36505. * Defines an optional offset (in seconds) inside the sound file
  36506. */
  36507. offset?: number;
  36508. /**
  36509. * If true, URLs will not be required to state the audio file codec to use.
  36510. */
  36511. skipCodecCheck?: boolean;
  36512. }
  36513. /**
  36514. * Defines a sound that can be played in the application.
  36515. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36516. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36517. */
  36518. export class Sound {
  36519. /**
  36520. * The name of the sound in the scene.
  36521. */
  36522. name: string;
  36523. /**
  36524. * Does the sound autoplay once loaded.
  36525. */
  36526. autoplay: boolean;
  36527. /**
  36528. * Does the sound loop after it finishes playing once.
  36529. */
  36530. loop: boolean;
  36531. /**
  36532. * Does the sound use a custom attenuation curve to simulate the falloff
  36533. * happening when the source gets further away from the camera.
  36534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36535. */
  36536. useCustomAttenuation: boolean;
  36537. /**
  36538. * The sound track id this sound belongs to.
  36539. */
  36540. soundTrackId: number;
  36541. /**
  36542. * Is this sound currently played.
  36543. */
  36544. isPlaying: boolean;
  36545. /**
  36546. * Is this sound currently paused.
  36547. */
  36548. isPaused: boolean;
  36549. /**
  36550. * Does this sound enables spatial sound.
  36551. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36552. */
  36553. spatialSound: boolean;
  36554. /**
  36555. * Define the reference distance the sound should be heard perfectly.
  36556. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36557. */
  36558. refDistance: number;
  36559. /**
  36560. * Define the roll off factor of spatial sounds.
  36561. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36562. */
  36563. rolloffFactor: number;
  36564. /**
  36565. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36566. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36567. */
  36568. maxDistance: number;
  36569. /**
  36570. * Define the distance attenuation model the sound will follow.
  36571. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36572. */
  36573. distanceModel: string;
  36574. /**
  36575. * @hidden
  36576. * Back Compat
  36577. **/
  36578. onended: () => any;
  36579. /**
  36580. * Observable event when the current playing sound finishes.
  36581. */
  36582. onEndedObservable: Observable<Sound>;
  36583. private _panningModel;
  36584. private _playbackRate;
  36585. private _streaming;
  36586. private _startTime;
  36587. private _startOffset;
  36588. private _position;
  36589. /** @hidden */
  36590. _positionInEmitterSpace: boolean;
  36591. private _localDirection;
  36592. private _volume;
  36593. private _isReadyToPlay;
  36594. private _isDirectional;
  36595. private _readyToPlayCallback;
  36596. private _audioBuffer;
  36597. private _soundSource;
  36598. private _streamingSource;
  36599. private _soundPanner;
  36600. private _soundGain;
  36601. private _inputAudioNode;
  36602. private _outputAudioNode;
  36603. private _coneInnerAngle;
  36604. private _coneOuterAngle;
  36605. private _coneOuterGain;
  36606. private _scene;
  36607. private _connectedTransformNode;
  36608. private _customAttenuationFunction;
  36609. private _registerFunc;
  36610. private _isOutputConnected;
  36611. private _htmlAudioElement;
  36612. private _urlType;
  36613. private _length?;
  36614. private _offset?;
  36615. /** @hidden */
  36616. static _SceneComponentInitialization: (scene: Scene) => void;
  36617. /**
  36618. * Create a sound and attach it to a scene
  36619. * @param name Name of your sound
  36620. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36621. * @param scene defines the scene the sound belongs to
  36622. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36623. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36624. */
  36625. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36626. /**
  36627. * Release the sound and its associated resources
  36628. */
  36629. dispose(): void;
  36630. /**
  36631. * Gets if the sounds is ready to be played or not.
  36632. * @returns true if ready, otherwise false
  36633. */
  36634. isReady(): boolean;
  36635. private _soundLoaded;
  36636. /**
  36637. * Sets the data of the sound from an audiobuffer
  36638. * @param audioBuffer The audioBuffer containing the data
  36639. */
  36640. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36641. /**
  36642. * Updates the current sounds options such as maxdistance, loop...
  36643. * @param options A JSON object containing values named as the object properties
  36644. */
  36645. updateOptions(options: ISoundOptions): void;
  36646. private _createSpatialParameters;
  36647. private _updateSpatialParameters;
  36648. /**
  36649. * Switch the panning model to HRTF:
  36650. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36651. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36652. */
  36653. switchPanningModelToHRTF(): void;
  36654. /**
  36655. * Switch the panning model to Equal Power:
  36656. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36657. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36658. */
  36659. switchPanningModelToEqualPower(): void;
  36660. private _switchPanningModel;
  36661. /**
  36662. * Connect this sound to a sound track audio node like gain...
  36663. * @param soundTrackAudioNode the sound track audio node to connect to
  36664. */
  36665. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36666. /**
  36667. * Transform this sound into a directional source
  36668. * @param coneInnerAngle Size of the inner cone in degree
  36669. * @param coneOuterAngle Size of the outer cone in degree
  36670. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36671. */
  36672. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36673. /**
  36674. * Gets or sets the inner angle for the directional cone.
  36675. */
  36676. /**
  36677. * Gets or sets the inner angle for the directional cone.
  36678. */
  36679. directionalConeInnerAngle: number;
  36680. /**
  36681. * Gets or sets the outer angle for the directional cone.
  36682. */
  36683. /**
  36684. * Gets or sets the outer angle for the directional cone.
  36685. */
  36686. directionalConeOuterAngle: number;
  36687. /**
  36688. * Sets the position of the emitter if spatial sound is enabled
  36689. * @param newPosition Defines the new posisiton
  36690. */
  36691. setPosition(newPosition: Vector3): void;
  36692. /**
  36693. * Sets the local direction of the emitter if spatial sound is enabled
  36694. * @param newLocalDirection Defines the new local direction
  36695. */
  36696. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36697. private _updateDirection;
  36698. /** @hidden */
  36699. updateDistanceFromListener(): void;
  36700. /**
  36701. * Sets a new custom attenuation function for the sound.
  36702. * @param callback Defines the function used for the attenuation
  36703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36704. */
  36705. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36706. /**
  36707. * Play the sound
  36708. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36709. * @param offset (optional) Start the sound at a specific time in seconds
  36710. * @param length (optional) Sound duration (in seconds)
  36711. */
  36712. play(time?: number, offset?: number, length?: number): void;
  36713. private _onended;
  36714. /**
  36715. * Stop the sound
  36716. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36717. */
  36718. stop(time?: number): void;
  36719. /**
  36720. * Put the sound in pause
  36721. */
  36722. pause(): void;
  36723. /**
  36724. * Sets a dedicated volume for this sounds
  36725. * @param newVolume Define the new volume of the sound
  36726. * @param time Define time for gradual change to new volume
  36727. */
  36728. setVolume(newVolume: number, time?: number): void;
  36729. /**
  36730. * Set the sound play back rate
  36731. * @param newPlaybackRate Define the playback rate the sound should be played at
  36732. */
  36733. setPlaybackRate(newPlaybackRate: number): void;
  36734. /**
  36735. * Gets the volume of the sound.
  36736. * @returns the volume of the sound
  36737. */
  36738. getVolume(): number;
  36739. /**
  36740. * Attach the sound to a dedicated mesh
  36741. * @param transformNode The transform node to connect the sound with
  36742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36743. */
  36744. attachToMesh(transformNode: TransformNode): void;
  36745. /**
  36746. * Detach the sound from the previously attached mesh
  36747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36748. */
  36749. detachFromMesh(): void;
  36750. private _onRegisterAfterWorldMatrixUpdate;
  36751. /**
  36752. * Clone the current sound in the scene.
  36753. * @returns the new sound clone
  36754. */
  36755. clone(): Nullable<Sound>;
  36756. /**
  36757. * Gets the current underlying audio buffer containing the data
  36758. * @returns the audio buffer
  36759. */
  36760. getAudioBuffer(): Nullable<AudioBuffer>;
  36761. /**
  36762. * Serializes the Sound in a JSON representation
  36763. * @returns the JSON representation of the sound
  36764. */
  36765. serialize(): any;
  36766. /**
  36767. * Parse a JSON representation of a sound to innstantiate in a given scene
  36768. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36769. * @param scene Define the scene the new parsed sound should be created in
  36770. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36771. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36772. * @returns the newly parsed sound
  36773. */
  36774. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36775. }
  36776. }
  36777. declare module "babylonjs/Actions/directAudioActions" {
  36778. import { Action } from "babylonjs/Actions/action";
  36779. import { Condition } from "babylonjs/Actions/condition";
  36780. import { Sound } from "babylonjs/Audio/sound";
  36781. /**
  36782. * This defines an action helpful to play a defined sound on a triggered action.
  36783. */
  36784. export class PlaySoundAction extends Action {
  36785. private _sound;
  36786. /**
  36787. * Instantiate the action
  36788. * @param triggerOptions defines the trigger options
  36789. * @param sound defines the sound to play
  36790. * @param condition defines the trigger related conditions
  36791. */
  36792. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36793. /** @hidden */
  36794. _prepare(): void;
  36795. /**
  36796. * Execute the action and play the sound.
  36797. */
  36798. execute(): void;
  36799. /**
  36800. * Serializes the actions and its related information.
  36801. * @param parent defines the object to serialize in
  36802. * @returns the serialized object
  36803. */
  36804. serialize(parent: any): any;
  36805. }
  36806. /**
  36807. * This defines an action helpful to stop a defined sound on a triggered action.
  36808. */
  36809. export class StopSoundAction extends Action {
  36810. private _sound;
  36811. /**
  36812. * Instantiate the action
  36813. * @param triggerOptions defines the trigger options
  36814. * @param sound defines the sound to stop
  36815. * @param condition defines the trigger related conditions
  36816. */
  36817. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36818. /** @hidden */
  36819. _prepare(): void;
  36820. /**
  36821. * Execute the action and stop the sound.
  36822. */
  36823. execute(): void;
  36824. /**
  36825. * Serializes the actions and its related information.
  36826. * @param parent defines the object to serialize in
  36827. * @returns the serialized object
  36828. */
  36829. serialize(parent: any): any;
  36830. }
  36831. }
  36832. declare module "babylonjs/Actions/interpolateValueAction" {
  36833. import { Action } from "babylonjs/Actions/action";
  36834. import { Condition } from "babylonjs/Actions/condition";
  36835. import { Observable } from "babylonjs/Misc/observable";
  36836. /**
  36837. * This defines an action responsible to change the value of a property
  36838. * by interpolating between its current value and the newly set one once triggered.
  36839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36840. */
  36841. export class InterpolateValueAction extends Action {
  36842. /**
  36843. * Defines the path of the property where the value should be interpolated
  36844. */
  36845. propertyPath: string;
  36846. /**
  36847. * Defines the target value at the end of the interpolation.
  36848. */
  36849. value: any;
  36850. /**
  36851. * Defines the time it will take for the property to interpolate to the value.
  36852. */
  36853. duration: number;
  36854. /**
  36855. * Defines if the other scene animations should be stopped when the action has been triggered
  36856. */
  36857. stopOtherAnimations?: boolean;
  36858. /**
  36859. * Defines a callback raised once the interpolation animation has been done.
  36860. */
  36861. onInterpolationDone?: () => void;
  36862. /**
  36863. * Observable triggered once the interpolation animation has been done.
  36864. */
  36865. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36866. private _target;
  36867. private _effectiveTarget;
  36868. private _property;
  36869. /**
  36870. * Instantiate the action
  36871. * @param triggerOptions defines the trigger options
  36872. * @param target defines the object containing the value to interpolate
  36873. * @param propertyPath defines the path to the property in the target object
  36874. * @param value defines the target value at the end of the interpolation
  36875. * @param duration deines the time it will take for the property to interpolate to the value.
  36876. * @param condition defines the trigger related conditions
  36877. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36878. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36879. */
  36880. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36881. /** @hidden */
  36882. _prepare(): void;
  36883. /**
  36884. * Execute the action starts the value interpolation.
  36885. */
  36886. execute(): void;
  36887. /**
  36888. * Serializes the actions and its related information.
  36889. * @param parent defines the object to serialize in
  36890. * @returns the serialized object
  36891. */
  36892. serialize(parent: any): any;
  36893. }
  36894. }
  36895. declare module "babylonjs/Actions/index" {
  36896. export * from "babylonjs/Actions/abstractActionManager";
  36897. export * from "babylonjs/Actions/action";
  36898. export * from "babylonjs/Actions/actionEvent";
  36899. export * from "babylonjs/Actions/actionManager";
  36900. export * from "babylonjs/Actions/condition";
  36901. export * from "babylonjs/Actions/directActions";
  36902. export * from "babylonjs/Actions/directAudioActions";
  36903. export * from "babylonjs/Actions/interpolateValueAction";
  36904. }
  36905. declare module "babylonjs/Animations/index" {
  36906. export * from "babylonjs/Animations/animatable";
  36907. export * from "babylonjs/Animations/animation";
  36908. export * from "babylonjs/Animations/animationGroup";
  36909. export * from "babylonjs/Animations/animationPropertiesOverride";
  36910. export * from "babylonjs/Animations/easing";
  36911. export * from "babylonjs/Animations/runtimeAnimation";
  36912. export * from "babylonjs/Animations/animationEvent";
  36913. export * from "babylonjs/Animations/animationGroup";
  36914. export * from "babylonjs/Animations/animationKey";
  36915. export * from "babylonjs/Animations/animationRange";
  36916. export * from "babylonjs/Animations/animatable.interface";
  36917. }
  36918. declare module "babylonjs/Audio/soundTrack" {
  36919. import { Sound } from "babylonjs/Audio/sound";
  36920. import { Analyser } from "babylonjs/Audio/analyser";
  36921. import { Scene } from "babylonjs/scene";
  36922. /**
  36923. * Options allowed during the creation of a sound track.
  36924. */
  36925. export interface ISoundTrackOptions {
  36926. /**
  36927. * The volume the sound track should take during creation
  36928. */
  36929. volume?: number;
  36930. /**
  36931. * Define if the sound track is the main sound track of the scene
  36932. */
  36933. mainTrack?: boolean;
  36934. }
  36935. /**
  36936. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36937. * It will be also used in a future release to apply effects on a specific track.
  36938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36939. */
  36940. export class SoundTrack {
  36941. /**
  36942. * The unique identifier of the sound track in the scene.
  36943. */
  36944. id: number;
  36945. /**
  36946. * The list of sounds included in the sound track.
  36947. */
  36948. soundCollection: Array<Sound>;
  36949. private _outputAudioNode;
  36950. private _scene;
  36951. private _connectedAnalyser;
  36952. private _options;
  36953. private _isInitialized;
  36954. /**
  36955. * Creates a new sound track.
  36956. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36957. * @param scene Define the scene the sound track belongs to
  36958. * @param options
  36959. */
  36960. constructor(scene: Scene, options?: ISoundTrackOptions);
  36961. private _initializeSoundTrackAudioGraph;
  36962. /**
  36963. * Release the sound track and its associated resources
  36964. */
  36965. dispose(): void;
  36966. /**
  36967. * Adds a sound to this sound track
  36968. * @param sound define the cound to add
  36969. * @ignoreNaming
  36970. */
  36971. AddSound(sound: Sound): void;
  36972. /**
  36973. * Removes a sound to this sound track
  36974. * @param sound define the cound to remove
  36975. * @ignoreNaming
  36976. */
  36977. RemoveSound(sound: Sound): void;
  36978. /**
  36979. * Set a global volume for the full sound track.
  36980. * @param newVolume Define the new volume of the sound track
  36981. */
  36982. setVolume(newVolume: number): void;
  36983. /**
  36984. * Switch the panning model to HRTF:
  36985. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36986. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36987. */
  36988. switchPanningModelToHRTF(): void;
  36989. /**
  36990. * Switch the panning model to Equal Power:
  36991. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36993. */
  36994. switchPanningModelToEqualPower(): void;
  36995. /**
  36996. * Connect the sound track to an audio analyser allowing some amazing
  36997. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36998. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36999. * @param analyser The analyser to connect to the engine
  37000. */
  37001. connectToAnalyser(analyser: Analyser): void;
  37002. }
  37003. }
  37004. declare module "babylonjs/Audio/audioSceneComponent" {
  37005. import { Sound } from "babylonjs/Audio/sound";
  37006. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  37007. import { Nullable } from "babylonjs/types";
  37008. import { Vector3 } from "babylonjs/Maths/math.vector";
  37009. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  37010. import { Scene } from "babylonjs/scene";
  37011. import { AbstractScene } from "babylonjs/abstractScene";
  37012. import "babylonjs/Audio/audioEngine";
  37013. module "babylonjs/abstractScene" {
  37014. interface AbstractScene {
  37015. /**
  37016. * The list of sounds used in the scene.
  37017. */
  37018. sounds: Nullable<Array<Sound>>;
  37019. }
  37020. }
  37021. module "babylonjs/scene" {
  37022. interface Scene {
  37023. /**
  37024. * @hidden
  37025. * Backing field
  37026. */
  37027. _mainSoundTrack: SoundTrack;
  37028. /**
  37029. * The main sound track played by the scene.
  37030. * It cotains your primary collection of sounds.
  37031. */
  37032. mainSoundTrack: SoundTrack;
  37033. /**
  37034. * The list of sound tracks added to the scene
  37035. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37036. */
  37037. soundTracks: Nullable<Array<SoundTrack>>;
  37038. /**
  37039. * Gets a sound using a given name
  37040. * @param name defines the name to search for
  37041. * @return the found sound or null if not found at all.
  37042. */
  37043. getSoundByName(name: string): Nullable<Sound>;
  37044. /**
  37045. * Gets or sets if audio support is enabled
  37046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37047. */
  37048. audioEnabled: boolean;
  37049. /**
  37050. * Gets or sets if audio will be output to headphones
  37051. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37052. */
  37053. headphone: boolean;
  37054. /**
  37055. * Gets or sets custom audio listener position provider
  37056. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37057. */
  37058. audioListenerPositionProvider: Nullable<() => Vector3>;
  37059. /**
  37060. * Gets or sets a refresh rate when using 3D audio positioning
  37061. */
  37062. audioPositioningRefreshRate: number;
  37063. }
  37064. }
  37065. /**
  37066. * Defines the sound scene component responsible to manage any sounds
  37067. * in a given scene.
  37068. */
  37069. export class AudioSceneComponent implements ISceneSerializableComponent {
  37070. /**
  37071. * The component name helpfull to identify the component in the list of scene components.
  37072. */
  37073. readonly name: string;
  37074. /**
  37075. * The scene the component belongs to.
  37076. */
  37077. scene: Scene;
  37078. private _audioEnabled;
  37079. /**
  37080. * Gets whether audio is enabled or not.
  37081. * Please use related enable/disable method to switch state.
  37082. */
  37083. readonly audioEnabled: boolean;
  37084. private _headphone;
  37085. /**
  37086. * Gets whether audio is outputing to headphone or not.
  37087. * Please use the according Switch methods to change output.
  37088. */
  37089. readonly headphone: boolean;
  37090. /**
  37091. * Gets or sets a refresh rate when using 3D audio positioning
  37092. */
  37093. audioPositioningRefreshRate: number;
  37094. private _audioListenerPositionProvider;
  37095. /**
  37096. * Gets the current audio listener position provider
  37097. */
  37098. /**
  37099. * Sets a custom listener position for all sounds in the scene
  37100. * By default, this is the position of the first active camera
  37101. */
  37102. audioListenerPositionProvider: Nullable<() => Vector3>;
  37103. /**
  37104. * Creates a new instance of the component for the given scene
  37105. * @param scene Defines the scene to register the component in
  37106. */
  37107. constructor(scene: Scene);
  37108. /**
  37109. * Registers the component in a given scene
  37110. */
  37111. register(): void;
  37112. /**
  37113. * Rebuilds the elements related to this component in case of
  37114. * context lost for instance.
  37115. */
  37116. rebuild(): void;
  37117. /**
  37118. * Serializes the component data to the specified json object
  37119. * @param serializationObject The object to serialize to
  37120. */
  37121. serialize(serializationObject: any): void;
  37122. /**
  37123. * Adds all the elements from the container to the scene
  37124. * @param container the container holding the elements
  37125. */
  37126. addFromContainer(container: AbstractScene): void;
  37127. /**
  37128. * Removes all the elements in the container from the scene
  37129. * @param container contains the elements to remove
  37130. * @param dispose if the removed element should be disposed (default: false)
  37131. */
  37132. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37133. /**
  37134. * Disposes the component and the associated ressources.
  37135. */
  37136. dispose(): void;
  37137. /**
  37138. * Disables audio in the associated scene.
  37139. */
  37140. disableAudio(): void;
  37141. /**
  37142. * Enables audio in the associated scene.
  37143. */
  37144. enableAudio(): void;
  37145. /**
  37146. * Switch audio to headphone output.
  37147. */
  37148. switchAudioModeForHeadphones(): void;
  37149. /**
  37150. * Switch audio to normal speakers.
  37151. */
  37152. switchAudioModeForNormalSpeakers(): void;
  37153. private _cachedCameraDirection;
  37154. private _cachedCameraPosition;
  37155. private _lastCheck;
  37156. private _afterRender;
  37157. }
  37158. }
  37159. declare module "babylonjs/Audio/weightedsound" {
  37160. import { Sound } from "babylonjs/Audio/sound";
  37161. /**
  37162. * Wraps one or more Sound objects and selects one with random weight for playback.
  37163. */
  37164. export class WeightedSound {
  37165. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37166. loop: boolean;
  37167. private _coneInnerAngle;
  37168. private _coneOuterAngle;
  37169. private _volume;
  37170. /** A Sound is currently playing. */
  37171. isPlaying: boolean;
  37172. /** A Sound is currently paused. */
  37173. isPaused: boolean;
  37174. private _sounds;
  37175. private _weights;
  37176. private _currentIndex?;
  37177. /**
  37178. * Creates a new WeightedSound from the list of sounds given.
  37179. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37180. * @param sounds Array of Sounds that will be selected from.
  37181. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37182. */
  37183. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37184. /**
  37185. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37186. */
  37187. /**
  37188. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37189. */
  37190. directionalConeInnerAngle: number;
  37191. /**
  37192. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37193. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37194. */
  37195. /**
  37196. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37197. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37198. */
  37199. directionalConeOuterAngle: number;
  37200. /**
  37201. * Playback volume.
  37202. */
  37203. /**
  37204. * Playback volume.
  37205. */
  37206. volume: number;
  37207. private _onended;
  37208. /**
  37209. * Suspend playback
  37210. */
  37211. pause(): void;
  37212. /**
  37213. * Stop playback
  37214. */
  37215. stop(): void;
  37216. /**
  37217. * Start playback.
  37218. * @param startOffset Position the clip head at a specific time in seconds.
  37219. */
  37220. play(startOffset?: number): void;
  37221. }
  37222. }
  37223. declare module "babylonjs/Audio/index" {
  37224. export * from "babylonjs/Audio/analyser";
  37225. export * from "babylonjs/Audio/audioEngine";
  37226. export * from "babylonjs/Audio/audioSceneComponent";
  37227. export * from "babylonjs/Audio/sound";
  37228. export * from "babylonjs/Audio/soundTrack";
  37229. export * from "babylonjs/Audio/weightedsound";
  37230. }
  37231. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  37232. import { Behavior } from "babylonjs/Behaviors/behavior";
  37233. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37234. import { BackEase } from "babylonjs/Animations/easing";
  37235. /**
  37236. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37237. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37238. */
  37239. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37240. /**
  37241. * Gets the name of the behavior.
  37242. */
  37243. readonly name: string;
  37244. /**
  37245. * The easing function used by animations
  37246. */
  37247. static EasingFunction: BackEase;
  37248. /**
  37249. * The easing mode used by animations
  37250. */
  37251. static EasingMode: number;
  37252. /**
  37253. * The duration of the animation, in milliseconds
  37254. */
  37255. transitionDuration: number;
  37256. /**
  37257. * Length of the distance animated by the transition when lower radius is reached
  37258. */
  37259. lowerRadiusTransitionRange: number;
  37260. /**
  37261. * Length of the distance animated by the transition when upper radius is reached
  37262. */
  37263. upperRadiusTransitionRange: number;
  37264. private _autoTransitionRange;
  37265. /**
  37266. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37267. */
  37268. /**
  37269. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37270. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37271. */
  37272. autoTransitionRange: boolean;
  37273. private _attachedCamera;
  37274. private _onAfterCheckInputsObserver;
  37275. private _onMeshTargetChangedObserver;
  37276. /**
  37277. * Initializes the behavior.
  37278. */
  37279. init(): void;
  37280. /**
  37281. * Attaches the behavior to its arc rotate camera.
  37282. * @param camera Defines the camera to attach the behavior to
  37283. */
  37284. attach(camera: ArcRotateCamera): void;
  37285. /**
  37286. * Detaches the behavior from its current arc rotate camera.
  37287. */
  37288. detach(): void;
  37289. private _radiusIsAnimating;
  37290. private _radiusBounceTransition;
  37291. private _animatables;
  37292. private _cachedWheelPrecision;
  37293. /**
  37294. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37295. * @param radiusLimit The limit to check against.
  37296. * @return Bool to indicate if at limit.
  37297. */
  37298. private _isRadiusAtLimit;
  37299. /**
  37300. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37301. * @param radiusDelta The delta by which to animate to. Can be negative.
  37302. */
  37303. private _applyBoundRadiusAnimation;
  37304. /**
  37305. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37306. */
  37307. protected _clearAnimationLocks(): void;
  37308. /**
  37309. * Stops and removes all animations that have been applied to the camera
  37310. */
  37311. stopAllAnimations(): void;
  37312. }
  37313. }
  37314. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  37315. import { Behavior } from "babylonjs/Behaviors/behavior";
  37316. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37317. import { ExponentialEase } from "babylonjs/Animations/easing";
  37318. import { Nullable } from "babylonjs/types";
  37319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37320. import { Vector3 } from "babylonjs/Maths/math.vector";
  37321. /**
  37322. * 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.
  37323. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37324. */
  37325. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37326. /**
  37327. * Gets the name of the behavior.
  37328. */
  37329. readonly name: string;
  37330. private _mode;
  37331. private _radiusScale;
  37332. private _positionScale;
  37333. private _defaultElevation;
  37334. private _elevationReturnTime;
  37335. private _elevationReturnWaitTime;
  37336. private _zoomStopsAnimation;
  37337. private _framingTime;
  37338. /**
  37339. * The easing function used by animations
  37340. */
  37341. static EasingFunction: ExponentialEase;
  37342. /**
  37343. * The easing mode used by animations
  37344. */
  37345. static EasingMode: number;
  37346. /**
  37347. * Sets the current mode used by the behavior
  37348. */
  37349. /**
  37350. * Gets current mode used by the behavior.
  37351. */
  37352. mode: number;
  37353. /**
  37354. * Sets the scale applied to the radius (1 by default)
  37355. */
  37356. /**
  37357. * Gets the scale applied to the radius
  37358. */
  37359. radiusScale: number;
  37360. /**
  37361. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37362. */
  37363. /**
  37364. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37365. */
  37366. positionScale: number;
  37367. /**
  37368. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37369. * behaviour is triggered, in radians.
  37370. */
  37371. /**
  37372. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37373. * behaviour is triggered, in radians.
  37374. */
  37375. defaultElevation: number;
  37376. /**
  37377. * Sets the time (in milliseconds) taken to return to the default beta position.
  37378. * Negative value indicates camera should not return to default.
  37379. */
  37380. /**
  37381. * Gets the time (in milliseconds) taken to return to the default beta position.
  37382. * Negative value indicates camera should not return to default.
  37383. */
  37384. elevationReturnTime: number;
  37385. /**
  37386. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37387. */
  37388. /**
  37389. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37390. */
  37391. elevationReturnWaitTime: number;
  37392. /**
  37393. * Sets the flag that indicates if user zooming should stop animation.
  37394. */
  37395. /**
  37396. * Gets the flag that indicates if user zooming should stop animation.
  37397. */
  37398. zoomStopsAnimation: boolean;
  37399. /**
  37400. * Sets the transition time when framing the mesh, in milliseconds
  37401. */
  37402. /**
  37403. * Gets the transition time when framing the mesh, in milliseconds
  37404. */
  37405. framingTime: number;
  37406. /**
  37407. * Define if the behavior should automatically change the configured
  37408. * camera limits and sensibilities.
  37409. */
  37410. autoCorrectCameraLimitsAndSensibility: boolean;
  37411. private _onPrePointerObservableObserver;
  37412. private _onAfterCheckInputsObserver;
  37413. private _onMeshTargetChangedObserver;
  37414. private _attachedCamera;
  37415. private _isPointerDown;
  37416. private _lastInteractionTime;
  37417. /**
  37418. * Initializes the behavior.
  37419. */
  37420. init(): void;
  37421. /**
  37422. * Attaches the behavior to its arc rotate camera.
  37423. * @param camera Defines the camera to attach the behavior to
  37424. */
  37425. attach(camera: ArcRotateCamera): void;
  37426. /**
  37427. * Detaches the behavior from its current arc rotate camera.
  37428. */
  37429. detach(): void;
  37430. private _animatables;
  37431. private _betaIsAnimating;
  37432. private _betaTransition;
  37433. private _radiusTransition;
  37434. private _vectorTransition;
  37435. /**
  37436. * Targets the given mesh and updates zoom level accordingly.
  37437. * @param mesh The mesh to target.
  37438. * @param radius Optional. If a cached radius position already exists, overrides default.
  37439. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37440. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37441. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37442. */
  37443. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37444. /**
  37445. * Targets the given mesh with its children and updates zoom level accordingly.
  37446. * @param mesh The mesh to target.
  37447. * @param radius Optional. If a cached radius position already exists, overrides default.
  37448. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37449. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37450. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37451. */
  37452. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37453. /**
  37454. * Targets the given meshes with their children and updates zoom level accordingly.
  37455. * @param meshes The mesh to target.
  37456. * @param radius Optional. If a cached radius position already exists, overrides default.
  37457. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37458. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37459. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37460. */
  37461. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37462. /**
  37463. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37464. * @param minimumWorld Determines the smaller position of the bounding box extend
  37465. * @param maximumWorld Determines the bigger position of the bounding box extend
  37466. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37467. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37468. */
  37469. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37470. /**
  37471. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37472. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37473. * frustum width.
  37474. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37475. * to fully enclose the mesh in the viewing frustum.
  37476. */
  37477. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37478. /**
  37479. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37480. * is automatically returned to its default position (expected to be above ground plane).
  37481. */
  37482. private _maintainCameraAboveGround;
  37483. /**
  37484. * Returns the frustum slope based on the canvas ratio and camera FOV
  37485. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37486. */
  37487. private _getFrustumSlope;
  37488. /**
  37489. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37490. */
  37491. private _clearAnimationLocks;
  37492. /**
  37493. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37494. */
  37495. private _applyUserInteraction;
  37496. /**
  37497. * Stops and removes all animations that have been applied to the camera
  37498. */
  37499. stopAllAnimations(): void;
  37500. /**
  37501. * Gets a value indicating if the user is moving the camera
  37502. */
  37503. readonly isUserIsMoving: boolean;
  37504. /**
  37505. * The camera can move all the way towards the mesh.
  37506. */
  37507. static IgnoreBoundsSizeMode: number;
  37508. /**
  37509. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37510. */
  37511. static FitFrustumSidesMode: number;
  37512. }
  37513. }
  37514. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37515. import { Nullable } from "babylonjs/types";
  37516. import { Camera } from "babylonjs/Cameras/camera";
  37517. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37518. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37519. /**
  37520. * Base class for Camera Pointer Inputs.
  37521. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37522. * for example usage.
  37523. */
  37524. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37525. /**
  37526. * Defines the camera the input is attached to.
  37527. */
  37528. abstract camera: Camera;
  37529. /**
  37530. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37531. */
  37532. protected _altKey: boolean;
  37533. protected _ctrlKey: boolean;
  37534. protected _metaKey: boolean;
  37535. protected _shiftKey: boolean;
  37536. /**
  37537. * Which mouse buttons were pressed at time of last mouse event.
  37538. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37539. */
  37540. protected _buttonsPressed: number;
  37541. /**
  37542. * Defines the buttons associated with the input to handle camera move.
  37543. */
  37544. buttons: number[];
  37545. /**
  37546. * Attach the input controls to a specific dom element to get the input from.
  37547. * @param element Defines the element the controls should be listened from
  37548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37549. */
  37550. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37551. /**
  37552. * Detach the current controls from the specified dom element.
  37553. * @param element Defines the element to stop listening the inputs from
  37554. */
  37555. detachControl(element: Nullable<HTMLElement>): void;
  37556. /**
  37557. * Gets the class name of the current input.
  37558. * @returns the class name
  37559. */
  37560. getClassName(): string;
  37561. /**
  37562. * Get the friendly name associated with the input class.
  37563. * @returns the input friendly name
  37564. */
  37565. getSimpleName(): string;
  37566. /**
  37567. * Called on pointer POINTERDOUBLETAP event.
  37568. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37569. */
  37570. protected onDoubleTap(type: string): void;
  37571. /**
  37572. * Called on pointer POINTERMOVE event if only a single touch is active.
  37573. * Override this method to provide functionality.
  37574. */
  37575. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37576. /**
  37577. * Called on pointer POINTERMOVE event if multiple touches are active.
  37578. * Override this method to provide functionality.
  37579. */
  37580. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37581. /**
  37582. * Called on JS contextmenu event.
  37583. * Override this method to provide functionality.
  37584. */
  37585. protected onContextMenu(evt: PointerEvent): void;
  37586. /**
  37587. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37588. * press.
  37589. * Override this method to provide functionality.
  37590. */
  37591. protected onButtonDown(evt: PointerEvent): void;
  37592. /**
  37593. * Called each time a new POINTERUP event occurs. Ie, for each button
  37594. * release.
  37595. * Override this method to provide functionality.
  37596. */
  37597. protected onButtonUp(evt: PointerEvent): void;
  37598. /**
  37599. * Called when window becomes inactive.
  37600. * Override this method to provide functionality.
  37601. */
  37602. protected onLostFocus(): void;
  37603. private _pointerInput;
  37604. private _observer;
  37605. private _onLostFocus;
  37606. private pointA;
  37607. private pointB;
  37608. }
  37609. }
  37610. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37611. import { Nullable } from "babylonjs/types";
  37612. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37613. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37614. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37615. /**
  37616. * Manage the pointers inputs to control an arc rotate camera.
  37617. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37618. */
  37619. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37620. /**
  37621. * Defines the camera the input is attached to.
  37622. */
  37623. camera: ArcRotateCamera;
  37624. /**
  37625. * Gets the class name of the current input.
  37626. * @returns the class name
  37627. */
  37628. getClassName(): string;
  37629. /**
  37630. * Defines the buttons associated with the input to handle camera move.
  37631. */
  37632. buttons: number[];
  37633. /**
  37634. * Defines the pointer angular sensibility along the X axis or how fast is
  37635. * the camera rotating.
  37636. */
  37637. angularSensibilityX: number;
  37638. /**
  37639. * Defines the pointer angular sensibility along the Y axis or how fast is
  37640. * the camera rotating.
  37641. */
  37642. angularSensibilityY: number;
  37643. /**
  37644. * Defines the pointer pinch precision or how fast is the camera zooming.
  37645. */
  37646. pinchPrecision: number;
  37647. /**
  37648. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37649. * from 0.
  37650. * It defines the percentage of current camera.radius to use as delta when
  37651. * pinch zoom is used.
  37652. */
  37653. pinchDeltaPercentage: number;
  37654. /**
  37655. * Defines the pointer panning sensibility or how fast is the camera moving.
  37656. */
  37657. panningSensibility: number;
  37658. /**
  37659. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37660. */
  37661. multiTouchPanning: boolean;
  37662. /**
  37663. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37664. * zoom (pinch) through multitouch.
  37665. */
  37666. multiTouchPanAndZoom: boolean;
  37667. /**
  37668. * Revers pinch action direction.
  37669. */
  37670. pinchInwards: boolean;
  37671. private _isPanClick;
  37672. private _twoFingerActivityCount;
  37673. private _isPinching;
  37674. /**
  37675. * Called on pointer POINTERMOVE event if only a single touch is active.
  37676. */
  37677. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37678. /**
  37679. * Called on pointer POINTERDOUBLETAP event.
  37680. */
  37681. protected onDoubleTap(type: string): void;
  37682. /**
  37683. * Called on pointer POINTERMOVE event if multiple touches are active.
  37684. */
  37685. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37686. /**
  37687. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37688. * press.
  37689. */
  37690. protected onButtonDown(evt: PointerEvent): void;
  37691. /**
  37692. * Called each time a new POINTERUP event occurs. Ie, for each button
  37693. * release.
  37694. */
  37695. protected onButtonUp(evt: PointerEvent): void;
  37696. /**
  37697. * Called when window becomes inactive.
  37698. */
  37699. protected onLostFocus(): void;
  37700. }
  37701. }
  37702. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37703. import { Nullable } from "babylonjs/types";
  37704. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37705. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37706. /**
  37707. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37708. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37709. */
  37710. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37711. /**
  37712. * Defines the camera the input is attached to.
  37713. */
  37714. camera: ArcRotateCamera;
  37715. /**
  37716. * Defines the list of key codes associated with the up action (increase alpha)
  37717. */
  37718. keysUp: number[];
  37719. /**
  37720. * Defines the list of key codes associated with the down action (decrease alpha)
  37721. */
  37722. keysDown: number[];
  37723. /**
  37724. * Defines the list of key codes associated with the left action (increase beta)
  37725. */
  37726. keysLeft: number[];
  37727. /**
  37728. * Defines the list of key codes associated with the right action (decrease beta)
  37729. */
  37730. keysRight: number[];
  37731. /**
  37732. * Defines the list of key codes associated with the reset action.
  37733. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37734. */
  37735. keysReset: number[];
  37736. /**
  37737. * Defines the panning sensibility of the inputs.
  37738. * (How fast is the camera paning)
  37739. */
  37740. panningSensibility: number;
  37741. /**
  37742. * Defines the zooming sensibility of the inputs.
  37743. * (How fast is the camera zooming)
  37744. */
  37745. zoomingSensibility: number;
  37746. /**
  37747. * Defines wether maintaining the alt key down switch the movement mode from
  37748. * orientation to zoom.
  37749. */
  37750. useAltToZoom: boolean;
  37751. /**
  37752. * Rotation speed of the camera
  37753. */
  37754. angularSpeed: number;
  37755. private _keys;
  37756. private _ctrlPressed;
  37757. private _altPressed;
  37758. private _onCanvasBlurObserver;
  37759. private _onKeyboardObserver;
  37760. private _engine;
  37761. private _scene;
  37762. /**
  37763. * Attach the input controls to a specific dom element to get the input from.
  37764. * @param element Defines the element the controls should be listened from
  37765. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37766. */
  37767. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37768. /**
  37769. * Detach the current controls from the specified dom element.
  37770. * @param element Defines the element to stop listening the inputs from
  37771. */
  37772. detachControl(element: Nullable<HTMLElement>): void;
  37773. /**
  37774. * Update the current camera state depending on the inputs that have been used this frame.
  37775. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37776. */
  37777. checkInputs(): void;
  37778. /**
  37779. * Gets the class name of the current intput.
  37780. * @returns the class name
  37781. */
  37782. getClassName(): string;
  37783. /**
  37784. * Get the friendly name associated with the input class.
  37785. * @returns the input friendly name
  37786. */
  37787. getSimpleName(): string;
  37788. }
  37789. }
  37790. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37791. import { Nullable } from "babylonjs/types";
  37792. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37793. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37794. /**
  37795. * Manage the mouse wheel inputs to control an arc rotate camera.
  37796. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37797. */
  37798. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37799. /**
  37800. * Defines the camera the input is attached to.
  37801. */
  37802. camera: ArcRotateCamera;
  37803. /**
  37804. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37805. */
  37806. wheelPrecision: number;
  37807. /**
  37808. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37809. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37810. */
  37811. wheelDeltaPercentage: number;
  37812. private _wheel;
  37813. private _observer;
  37814. private computeDeltaFromMouseWheelLegacyEvent;
  37815. /**
  37816. * Attach the input controls to a specific dom element to get the input from.
  37817. * @param element Defines the element the controls should be listened from
  37818. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37819. */
  37820. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37821. /**
  37822. * Detach the current controls from the specified dom element.
  37823. * @param element Defines the element to stop listening the inputs from
  37824. */
  37825. detachControl(element: Nullable<HTMLElement>): void;
  37826. /**
  37827. * Gets the class name of the current intput.
  37828. * @returns the class name
  37829. */
  37830. getClassName(): string;
  37831. /**
  37832. * Get the friendly name associated with the input class.
  37833. * @returns the input friendly name
  37834. */
  37835. getSimpleName(): string;
  37836. }
  37837. }
  37838. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37839. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37840. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37841. /**
  37842. * Default Inputs manager for the ArcRotateCamera.
  37843. * It groups all the default supported inputs for ease of use.
  37844. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37845. */
  37846. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37847. /**
  37848. * Instantiates a new ArcRotateCameraInputsManager.
  37849. * @param camera Defines the camera the inputs belong to
  37850. */
  37851. constructor(camera: ArcRotateCamera);
  37852. /**
  37853. * Add mouse wheel input support to the input manager.
  37854. * @returns the current input manager
  37855. */
  37856. addMouseWheel(): ArcRotateCameraInputsManager;
  37857. /**
  37858. * Add pointers input support to the input manager.
  37859. * @returns the current input manager
  37860. */
  37861. addPointers(): ArcRotateCameraInputsManager;
  37862. /**
  37863. * Add keyboard input support to the input manager.
  37864. * @returns the current input manager
  37865. */
  37866. addKeyboard(): ArcRotateCameraInputsManager;
  37867. }
  37868. }
  37869. declare module "babylonjs/Cameras/arcRotateCamera" {
  37870. import { Observable } from "babylonjs/Misc/observable";
  37871. import { Nullable } from "babylonjs/types";
  37872. import { Scene } from "babylonjs/scene";
  37873. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37875. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37876. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37877. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37878. import { Camera } from "babylonjs/Cameras/camera";
  37879. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37880. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37881. import { Collider } from "babylonjs/Collisions/collider";
  37882. /**
  37883. * This represents an orbital type of camera.
  37884. *
  37885. * 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.
  37886. * 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.
  37887. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37888. */
  37889. export class ArcRotateCamera extends TargetCamera {
  37890. /**
  37891. * Defines the rotation angle of the camera along the longitudinal axis.
  37892. */
  37893. alpha: number;
  37894. /**
  37895. * Defines the rotation angle of the camera along the latitudinal axis.
  37896. */
  37897. beta: number;
  37898. /**
  37899. * Defines the radius of the camera from it s target point.
  37900. */
  37901. radius: number;
  37902. protected _target: Vector3;
  37903. protected _targetHost: Nullable<AbstractMesh>;
  37904. /**
  37905. * Defines the target point of the camera.
  37906. * The camera looks towards it form the radius distance.
  37907. */
  37908. target: Vector3;
  37909. /**
  37910. * Define the current local position of the camera in the scene
  37911. */
  37912. position: Vector3;
  37913. protected _upVector: Vector3;
  37914. protected _upToYMatrix: Matrix;
  37915. protected _YToUpMatrix: Matrix;
  37916. /**
  37917. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37918. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37919. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37920. */
  37921. upVector: Vector3;
  37922. /**
  37923. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37924. */
  37925. setMatUp(): void;
  37926. /**
  37927. * Current inertia value on the longitudinal axis.
  37928. * The bigger this number the longer it will take for the camera to stop.
  37929. */
  37930. inertialAlphaOffset: number;
  37931. /**
  37932. * Current inertia value on the latitudinal axis.
  37933. * The bigger this number the longer it will take for the camera to stop.
  37934. */
  37935. inertialBetaOffset: number;
  37936. /**
  37937. * Current inertia value on the radius axis.
  37938. * The bigger this number the longer it will take for the camera to stop.
  37939. */
  37940. inertialRadiusOffset: number;
  37941. /**
  37942. * Minimum allowed angle on the longitudinal axis.
  37943. * This can help limiting how the Camera is able to move in the scene.
  37944. */
  37945. lowerAlphaLimit: Nullable<number>;
  37946. /**
  37947. * Maximum allowed angle on the longitudinal axis.
  37948. * This can help limiting how the Camera is able to move in the scene.
  37949. */
  37950. upperAlphaLimit: Nullable<number>;
  37951. /**
  37952. * Minimum allowed angle on the latitudinal axis.
  37953. * This can help limiting how the Camera is able to move in the scene.
  37954. */
  37955. lowerBetaLimit: number;
  37956. /**
  37957. * Maximum allowed angle on the latitudinal axis.
  37958. * This can help limiting how the Camera is able to move in the scene.
  37959. */
  37960. upperBetaLimit: number;
  37961. /**
  37962. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37963. * This can help limiting how the Camera is able to move in the scene.
  37964. */
  37965. lowerRadiusLimit: Nullable<number>;
  37966. /**
  37967. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37968. * This can help limiting how the Camera is able to move in the scene.
  37969. */
  37970. upperRadiusLimit: Nullable<number>;
  37971. /**
  37972. * Defines the current inertia value used during panning of the camera along the X axis.
  37973. */
  37974. inertialPanningX: number;
  37975. /**
  37976. * Defines the current inertia value used during panning of the camera along the Y axis.
  37977. */
  37978. inertialPanningY: number;
  37979. /**
  37980. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37981. * Basically if your fingers moves away from more than this distance you will be considered
  37982. * in pinch mode.
  37983. */
  37984. pinchToPanMaxDistance: number;
  37985. /**
  37986. * Defines the maximum distance the camera can pan.
  37987. * This could help keeping the cammera always in your scene.
  37988. */
  37989. panningDistanceLimit: Nullable<number>;
  37990. /**
  37991. * Defines the target of the camera before paning.
  37992. */
  37993. panningOriginTarget: Vector3;
  37994. /**
  37995. * Defines the value of the inertia used during panning.
  37996. * 0 would mean stop inertia and one would mean no decelleration at all.
  37997. */
  37998. panningInertia: number;
  37999. /**
  38000. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38001. */
  38002. angularSensibilityX: number;
  38003. /**
  38004. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38005. */
  38006. angularSensibilityY: number;
  38007. /**
  38008. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38009. */
  38010. pinchPrecision: number;
  38011. /**
  38012. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38013. * It will be used instead of pinchDeltaPrecision if different from 0.
  38014. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38015. */
  38016. pinchDeltaPercentage: number;
  38017. /**
  38018. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38019. */
  38020. panningSensibility: number;
  38021. /**
  38022. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38023. */
  38024. keysUp: number[];
  38025. /**
  38026. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38027. */
  38028. keysDown: number[];
  38029. /**
  38030. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38031. */
  38032. keysLeft: number[];
  38033. /**
  38034. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38035. */
  38036. keysRight: number[];
  38037. /**
  38038. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38039. */
  38040. wheelPrecision: number;
  38041. /**
  38042. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38043. * It will be used instead of pinchDeltaPrecision if different from 0.
  38044. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38045. */
  38046. wheelDeltaPercentage: number;
  38047. /**
  38048. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38049. */
  38050. zoomOnFactor: number;
  38051. /**
  38052. * Defines a screen offset for the camera position.
  38053. */
  38054. targetScreenOffset: Vector2;
  38055. /**
  38056. * Allows the camera to be completely reversed.
  38057. * If false the camera can not arrive upside down.
  38058. */
  38059. allowUpsideDown: boolean;
  38060. /**
  38061. * Define if double tap/click is used to restore the previously saved state of the camera.
  38062. */
  38063. useInputToRestoreState: boolean;
  38064. /** @hidden */
  38065. _viewMatrix: Matrix;
  38066. /** @hidden */
  38067. _useCtrlForPanning: boolean;
  38068. /** @hidden */
  38069. _panningMouseButton: number;
  38070. /**
  38071. * Defines the input associated to the camera.
  38072. */
  38073. inputs: ArcRotateCameraInputsManager;
  38074. /** @hidden */
  38075. _reset: () => void;
  38076. /**
  38077. * Defines the allowed panning axis.
  38078. */
  38079. panningAxis: Vector3;
  38080. protected _localDirection: Vector3;
  38081. protected _transformedDirection: Vector3;
  38082. private _bouncingBehavior;
  38083. /**
  38084. * Gets the bouncing behavior of the camera if it has been enabled.
  38085. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38086. */
  38087. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  38088. /**
  38089. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38090. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38091. */
  38092. useBouncingBehavior: boolean;
  38093. private _framingBehavior;
  38094. /**
  38095. * Gets the framing behavior of the camera if it has been enabled.
  38096. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38097. */
  38098. readonly framingBehavior: Nullable<FramingBehavior>;
  38099. /**
  38100. * Defines if the framing behavior of the camera is enabled on the camera.
  38101. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38102. */
  38103. useFramingBehavior: boolean;
  38104. private _autoRotationBehavior;
  38105. /**
  38106. * Gets the auto rotation behavior of the camera if it has been enabled.
  38107. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38108. */
  38109. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  38110. /**
  38111. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38112. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38113. */
  38114. useAutoRotationBehavior: boolean;
  38115. /**
  38116. * Observable triggered when the mesh target has been changed on the camera.
  38117. */
  38118. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38119. /**
  38120. * Event raised when the camera is colliding with a mesh.
  38121. */
  38122. onCollide: (collidedMesh: AbstractMesh) => void;
  38123. /**
  38124. * Defines whether the camera should check collision with the objects oh the scene.
  38125. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38126. */
  38127. checkCollisions: boolean;
  38128. /**
  38129. * Defines the collision radius of the camera.
  38130. * This simulates a sphere around the camera.
  38131. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38132. */
  38133. collisionRadius: Vector3;
  38134. protected _collider: Collider;
  38135. protected _previousPosition: Vector3;
  38136. protected _collisionVelocity: Vector3;
  38137. protected _newPosition: Vector3;
  38138. protected _previousAlpha: number;
  38139. protected _previousBeta: number;
  38140. protected _previousRadius: number;
  38141. protected _collisionTriggered: boolean;
  38142. protected _targetBoundingCenter: Nullable<Vector3>;
  38143. private _computationVector;
  38144. /**
  38145. * Instantiates a new ArcRotateCamera in a given scene
  38146. * @param name Defines the name of the camera
  38147. * @param alpha Defines the camera rotation along the logitudinal axis
  38148. * @param beta Defines the camera rotation along the latitudinal axis
  38149. * @param radius Defines the camera distance from its target
  38150. * @param target Defines the camera target
  38151. * @param scene Defines the scene the camera belongs to
  38152. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38153. */
  38154. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38155. /** @hidden */
  38156. _initCache(): void;
  38157. /** @hidden */
  38158. _updateCache(ignoreParentClass?: boolean): void;
  38159. protected _getTargetPosition(): Vector3;
  38160. private _storedAlpha;
  38161. private _storedBeta;
  38162. private _storedRadius;
  38163. private _storedTarget;
  38164. private _storedTargetScreenOffset;
  38165. /**
  38166. * Stores the current state of the camera (alpha, beta, radius and target)
  38167. * @returns the camera itself
  38168. */
  38169. storeState(): Camera;
  38170. /**
  38171. * @hidden
  38172. * Restored camera state. You must call storeState() first
  38173. */
  38174. _restoreStateValues(): boolean;
  38175. /** @hidden */
  38176. _isSynchronizedViewMatrix(): boolean;
  38177. /**
  38178. * Attached controls to the current camera.
  38179. * @param element Defines the element the controls should be listened from
  38180. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38181. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38182. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38183. */
  38184. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38185. /**
  38186. * Detach the current controls from the camera.
  38187. * The camera will stop reacting to inputs.
  38188. * @param element Defines the element to stop listening the inputs from
  38189. */
  38190. detachControl(element: HTMLElement): void;
  38191. /** @hidden */
  38192. _checkInputs(): void;
  38193. protected _checkLimits(): void;
  38194. /**
  38195. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38196. */
  38197. rebuildAnglesAndRadius(): void;
  38198. /**
  38199. * Use a position to define the current camera related information like alpha, beta and radius
  38200. * @param position Defines the position to set the camera at
  38201. */
  38202. setPosition(position: Vector3): void;
  38203. /**
  38204. * Defines the target the camera should look at.
  38205. * This will automatically adapt alpha beta and radius to fit within the new target.
  38206. * @param target Defines the new target as a Vector or a mesh
  38207. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38208. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38209. */
  38210. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38211. /** @hidden */
  38212. _getViewMatrix(): Matrix;
  38213. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38214. /**
  38215. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38216. * @param meshes Defines the mesh to zoom on
  38217. * @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)
  38218. */
  38219. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38220. /**
  38221. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38222. * The target will be changed but the radius
  38223. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38224. * @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)
  38225. */
  38226. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38227. min: Vector3;
  38228. max: Vector3;
  38229. distance: number;
  38230. }, doNotUpdateMaxZ?: boolean): void;
  38231. /**
  38232. * @override
  38233. * Override Camera.createRigCamera
  38234. */
  38235. createRigCamera(name: string, cameraIndex: number): Camera;
  38236. /**
  38237. * @hidden
  38238. * @override
  38239. * Override Camera._updateRigCameras
  38240. */
  38241. _updateRigCameras(): void;
  38242. /**
  38243. * Destroy the camera and release the current resources hold by it.
  38244. */
  38245. dispose(): void;
  38246. /**
  38247. * Gets the current object class name.
  38248. * @return the class name
  38249. */
  38250. getClassName(): string;
  38251. }
  38252. }
  38253. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  38254. import { Behavior } from "babylonjs/Behaviors/behavior";
  38255. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38256. /**
  38257. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38258. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38259. */
  38260. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38261. /**
  38262. * Gets the name of the behavior.
  38263. */
  38264. readonly name: string;
  38265. private _zoomStopsAnimation;
  38266. private _idleRotationSpeed;
  38267. private _idleRotationWaitTime;
  38268. private _idleRotationSpinupTime;
  38269. /**
  38270. * Sets the flag that indicates if user zooming should stop animation.
  38271. */
  38272. /**
  38273. * Gets the flag that indicates if user zooming should stop animation.
  38274. */
  38275. zoomStopsAnimation: boolean;
  38276. /**
  38277. * Sets the default speed at which the camera rotates around the model.
  38278. */
  38279. /**
  38280. * Gets the default speed at which the camera rotates around the model.
  38281. */
  38282. idleRotationSpeed: number;
  38283. /**
  38284. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38285. */
  38286. /**
  38287. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38288. */
  38289. idleRotationWaitTime: number;
  38290. /**
  38291. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38292. */
  38293. /**
  38294. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38295. */
  38296. idleRotationSpinupTime: number;
  38297. /**
  38298. * Gets a value indicating if the camera is currently rotating because of this behavior
  38299. */
  38300. readonly rotationInProgress: boolean;
  38301. private _onPrePointerObservableObserver;
  38302. private _onAfterCheckInputsObserver;
  38303. private _attachedCamera;
  38304. private _isPointerDown;
  38305. private _lastFrameTime;
  38306. private _lastInteractionTime;
  38307. private _cameraRotationSpeed;
  38308. /**
  38309. * Initializes the behavior.
  38310. */
  38311. init(): void;
  38312. /**
  38313. * Attaches the behavior to its arc rotate camera.
  38314. * @param camera Defines the camera to attach the behavior to
  38315. */
  38316. attach(camera: ArcRotateCamera): void;
  38317. /**
  38318. * Detaches the behavior from its current arc rotate camera.
  38319. */
  38320. detach(): void;
  38321. /**
  38322. * Returns true if user is scrolling.
  38323. * @return true if user is scrolling.
  38324. */
  38325. private _userIsZooming;
  38326. private _lastFrameRadius;
  38327. private _shouldAnimationStopForInteraction;
  38328. /**
  38329. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38330. */
  38331. private _applyUserInteraction;
  38332. private _userIsMoving;
  38333. }
  38334. }
  38335. declare module "babylonjs/Behaviors/Cameras/index" {
  38336. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  38337. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  38338. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  38339. }
  38340. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  38341. import { Mesh } from "babylonjs/Meshes/mesh";
  38342. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38343. import { Behavior } from "babylonjs/Behaviors/behavior";
  38344. /**
  38345. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38346. */
  38347. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38348. private ui;
  38349. /**
  38350. * The name of the behavior
  38351. */
  38352. name: string;
  38353. /**
  38354. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38355. */
  38356. distanceAwayFromFace: number;
  38357. /**
  38358. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38359. */
  38360. distanceAwayFromBottomOfFace: number;
  38361. private _faceVectors;
  38362. private _target;
  38363. private _scene;
  38364. private _onRenderObserver;
  38365. private _tmpMatrix;
  38366. private _tmpVector;
  38367. /**
  38368. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38369. * @param ui The transform node that should be attched to the mesh
  38370. */
  38371. constructor(ui: TransformNode);
  38372. /**
  38373. * Initializes the behavior
  38374. */
  38375. init(): void;
  38376. private _closestFace;
  38377. private _zeroVector;
  38378. private _lookAtTmpMatrix;
  38379. private _lookAtToRef;
  38380. /**
  38381. * Attaches the AttachToBoxBehavior to the passed in mesh
  38382. * @param target The mesh that the specified node will be attached to
  38383. */
  38384. attach(target: Mesh): void;
  38385. /**
  38386. * Detaches the behavior from the mesh
  38387. */
  38388. detach(): void;
  38389. }
  38390. }
  38391. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  38392. import { Behavior } from "babylonjs/Behaviors/behavior";
  38393. import { Mesh } from "babylonjs/Meshes/mesh";
  38394. /**
  38395. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38396. */
  38397. export class FadeInOutBehavior implements Behavior<Mesh> {
  38398. /**
  38399. * Time in milliseconds to delay before fading in (Default: 0)
  38400. */
  38401. delay: number;
  38402. /**
  38403. * Time in milliseconds for the mesh to fade in (Default: 300)
  38404. */
  38405. fadeInTime: number;
  38406. private _millisecondsPerFrame;
  38407. private _hovered;
  38408. private _hoverValue;
  38409. private _ownerNode;
  38410. /**
  38411. * Instatiates the FadeInOutBehavior
  38412. */
  38413. constructor();
  38414. /**
  38415. * The name of the behavior
  38416. */
  38417. readonly name: string;
  38418. /**
  38419. * Initializes the behavior
  38420. */
  38421. init(): void;
  38422. /**
  38423. * Attaches the fade behavior on the passed in mesh
  38424. * @param ownerNode The mesh that will be faded in/out once attached
  38425. */
  38426. attach(ownerNode: Mesh): void;
  38427. /**
  38428. * Detaches the behavior from the mesh
  38429. */
  38430. detach(): void;
  38431. /**
  38432. * Triggers the mesh to begin fading in or out
  38433. * @param value if the object should fade in or out (true to fade in)
  38434. */
  38435. fadeIn(value: boolean): void;
  38436. private _update;
  38437. private _setAllVisibility;
  38438. }
  38439. }
  38440. declare module "babylonjs/Misc/pivotTools" {
  38441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38442. /**
  38443. * Class containing a set of static utilities functions for managing Pivots
  38444. * @hidden
  38445. */
  38446. export class PivotTools {
  38447. private static _PivotCached;
  38448. private static _OldPivotPoint;
  38449. private static _PivotTranslation;
  38450. private static _PivotTmpVector;
  38451. /** @hidden */
  38452. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38453. /** @hidden */
  38454. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38455. }
  38456. }
  38457. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38458. import { Scene } from "babylonjs/scene";
  38459. import { Vector4 } from "babylonjs/Maths/math.vector";
  38460. import { Mesh } from "babylonjs/Meshes/mesh";
  38461. import { Nullable } from "babylonjs/types";
  38462. import { Plane } from "babylonjs/Maths/math.plane";
  38463. /**
  38464. * Class containing static functions to help procedurally build meshes
  38465. */
  38466. export class PlaneBuilder {
  38467. /**
  38468. * Creates a plane mesh
  38469. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38470. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38471. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38473. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38475. * @param name defines the name of the mesh
  38476. * @param options defines the options used to create the mesh
  38477. * @param scene defines the hosting scene
  38478. * @returns the plane mesh
  38479. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38480. */
  38481. static CreatePlane(name: string, options: {
  38482. size?: number;
  38483. width?: number;
  38484. height?: number;
  38485. sideOrientation?: number;
  38486. frontUVs?: Vector4;
  38487. backUVs?: Vector4;
  38488. updatable?: boolean;
  38489. sourcePlane?: Plane;
  38490. }, scene?: Nullable<Scene>): Mesh;
  38491. }
  38492. }
  38493. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38494. import { Behavior } from "babylonjs/Behaviors/behavior";
  38495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38496. import { Observable } from "babylonjs/Misc/observable";
  38497. import { Vector3 } from "babylonjs/Maths/math.vector";
  38498. import { Ray } from "babylonjs/Culling/ray";
  38499. import "babylonjs/Meshes/Builders/planeBuilder";
  38500. /**
  38501. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38502. */
  38503. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38504. private static _AnyMouseID;
  38505. /**
  38506. * Abstract mesh the behavior is set on
  38507. */
  38508. attachedNode: AbstractMesh;
  38509. private _dragPlane;
  38510. private _scene;
  38511. private _pointerObserver;
  38512. private _beforeRenderObserver;
  38513. private static _planeScene;
  38514. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38515. /**
  38516. * 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)
  38517. */
  38518. maxDragAngle: number;
  38519. /**
  38520. * @hidden
  38521. */
  38522. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38523. /**
  38524. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38525. */
  38526. currentDraggingPointerID: number;
  38527. /**
  38528. * The last position where the pointer hit the drag plane in world space
  38529. */
  38530. lastDragPosition: Vector3;
  38531. /**
  38532. * If the behavior is currently in a dragging state
  38533. */
  38534. dragging: boolean;
  38535. /**
  38536. * 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)
  38537. */
  38538. dragDeltaRatio: number;
  38539. /**
  38540. * If the drag plane orientation should be updated during the dragging (Default: true)
  38541. */
  38542. updateDragPlane: boolean;
  38543. private _debugMode;
  38544. private _moving;
  38545. /**
  38546. * Fires each time the attached mesh is dragged with the pointer
  38547. * * delta between last drag position and current drag position in world space
  38548. * * dragDistance along the drag axis
  38549. * * dragPlaneNormal normal of the current drag plane used during the drag
  38550. * * dragPlanePoint in world space where the drag intersects the drag plane
  38551. */
  38552. onDragObservable: Observable<{
  38553. delta: Vector3;
  38554. dragPlanePoint: Vector3;
  38555. dragPlaneNormal: Vector3;
  38556. dragDistance: number;
  38557. pointerId: number;
  38558. }>;
  38559. /**
  38560. * Fires each time a drag begins (eg. mouse down on mesh)
  38561. */
  38562. onDragStartObservable: Observable<{
  38563. dragPlanePoint: Vector3;
  38564. pointerId: number;
  38565. }>;
  38566. /**
  38567. * Fires each time a drag ends (eg. mouse release after drag)
  38568. */
  38569. onDragEndObservable: Observable<{
  38570. dragPlanePoint: Vector3;
  38571. pointerId: number;
  38572. }>;
  38573. /**
  38574. * If the attached mesh should be moved when dragged
  38575. */
  38576. moveAttached: boolean;
  38577. /**
  38578. * If the drag behavior will react to drag events (Default: true)
  38579. */
  38580. enabled: boolean;
  38581. /**
  38582. * If pointer events should start and release the drag (Default: true)
  38583. */
  38584. startAndReleaseDragOnPointerEvents: boolean;
  38585. /**
  38586. * If camera controls should be detached during the drag
  38587. */
  38588. detachCameraControls: boolean;
  38589. /**
  38590. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38591. */
  38592. useObjectOrienationForDragging: boolean;
  38593. private _options;
  38594. /**
  38595. * Creates a pointer drag behavior that can be attached to a mesh
  38596. * @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)
  38597. */
  38598. constructor(options?: {
  38599. dragAxis?: Vector3;
  38600. dragPlaneNormal?: Vector3;
  38601. });
  38602. /**
  38603. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38604. */
  38605. validateDrag: (targetPosition: Vector3) => boolean;
  38606. /**
  38607. * The name of the behavior
  38608. */
  38609. readonly name: string;
  38610. /**
  38611. * Initializes the behavior
  38612. */
  38613. init(): void;
  38614. private _tmpVector;
  38615. private _alternatePickedPoint;
  38616. private _worldDragAxis;
  38617. private _targetPosition;
  38618. private _attachedElement;
  38619. /**
  38620. * Attaches the drag behavior the passed in mesh
  38621. * @param ownerNode The mesh that will be dragged around once attached
  38622. * @param predicate Predicate to use for pick filtering
  38623. */
  38624. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38625. /**
  38626. * Force relase the drag action by code.
  38627. */
  38628. releaseDrag(): void;
  38629. private _startDragRay;
  38630. private _lastPointerRay;
  38631. /**
  38632. * Simulates the start of a pointer drag event on the behavior
  38633. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38634. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38635. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38636. */
  38637. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38638. private _startDrag;
  38639. private _dragDelta;
  38640. private _moveDrag;
  38641. private _pickWithRayOnDragPlane;
  38642. private _pointA;
  38643. private _pointB;
  38644. private _pointC;
  38645. private _lineA;
  38646. private _lineB;
  38647. private _localAxis;
  38648. private _lookAt;
  38649. private _updateDragPlanePosition;
  38650. /**
  38651. * Detaches the behavior from the mesh
  38652. */
  38653. detach(): void;
  38654. }
  38655. }
  38656. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38657. import { Mesh } from "babylonjs/Meshes/mesh";
  38658. import { Behavior } from "babylonjs/Behaviors/behavior";
  38659. /**
  38660. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38661. */
  38662. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38663. private _dragBehaviorA;
  38664. private _dragBehaviorB;
  38665. private _startDistance;
  38666. private _initialScale;
  38667. private _targetScale;
  38668. private _ownerNode;
  38669. private _sceneRenderObserver;
  38670. /**
  38671. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38672. */
  38673. constructor();
  38674. /**
  38675. * The name of the behavior
  38676. */
  38677. readonly name: string;
  38678. /**
  38679. * Initializes the behavior
  38680. */
  38681. init(): void;
  38682. private _getCurrentDistance;
  38683. /**
  38684. * Attaches the scale behavior the passed in mesh
  38685. * @param ownerNode The mesh that will be scaled around once attached
  38686. */
  38687. attach(ownerNode: Mesh): void;
  38688. /**
  38689. * Detaches the behavior from the mesh
  38690. */
  38691. detach(): void;
  38692. }
  38693. }
  38694. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38695. import { Behavior } from "babylonjs/Behaviors/behavior";
  38696. import { Mesh } from "babylonjs/Meshes/mesh";
  38697. import { Observable } from "babylonjs/Misc/observable";
  38698. /**
  38699. * 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
  38700. */
  38701. export class SixDofDragBehavior implements Behavior<Mesh> {
  38702. private static _virtualScene;
  38703. private _ownerNode;
  38704. private _sceneRenderObserver;
  38705. private _scene;
  38706. private _targetPosition;
  38707. private _virtualOriginMesh;
  38708. private _virtualDragMesh;
  38709. private _pointerObserver;
  38710. private _moving;
  38711. private _startingOrientation;
  38712. /**
  38713. * 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)
  38714. */
  38715. private zDragFactor;
  38716. /**
  38717. * If the object should rotate to face the drag origin
  38718. */
  38719. rotateDraggedObject: boolean;
  38720. /**
  38721. * If the behavior is currently in a dragging state
  38722. */
  38723. dragging: boolean;
  38724. /**
  38725. * 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)
  38726. */
  38727. dragDeltaRatio: number;
  38728. /**
  38729. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38730. */
  38731. currentDraggingPointerID: number;
  38732. /**
  38733. * If camera controls should be detached during the drag
  38734. */
  38735. detachCameraControls: boolean;
  38736. /**
  38737. * Fires each time a drag starts
  38738. */
  38739. onDragStartObservable: Observable<{}>;
  38740. /**
  38741. * Fires each time a drag ends (eg. mouse release after drag)
  38742. */
  38743. onDragEndObservable: Observable<{}>;
  38744. /**
  38745. * 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
  38746. */
  38747. constructor();
  38748. /**
  38749. * The name of the behavior
  38750. */
  38751. readonly name: string;
  38752. /**
  38753. * Initializes the behavior
  38754. */
  38755. init(): void;
  38756. /**
  38757. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38758. */
  38759. private readonly _pointerCamera;
  38760. /**
  38761. * Attaches the scale behavior the passed in mesh
  38762. * @param ownerNode The mesh that will be scaled around once attached
  38763. */
  38764. attach(ownerNode: Mesh): void;
  38765. /**
  38766. * Detaches the behavior from the mesh
  38767. */
  38768. detach(): void;
  38769. }
  38770. }
  38771. declare module "babylonjs/Behaviors/Meshes/index" {
  38772. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38773. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38774. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38775. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38776. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38777. }
  38778. declare module "babylonjs/Behaviors/index" {
  38779. export * from "babylonjs/Behaviors/behavior";
  38780. export * from "babylonjs/Behaviors/Cameras/index";
  38781. export * from "babylonjs/Behaviors/Meshes/index";
  38782. }
  38783. declare module "babylonjs/Bones/boneIKController" {
  38784. import { Bone } from "babylonjs/Bones/bone";
  38785. import { Vector3 } from "babylonjs/Maths/math.vector";
  38786. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38787. import { Nullable } from "babylonjs/types";
  38788. /**
  38789. * Class used to apply inverse kinematics to bones
  38790. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38791. */
  38792. export class BoneIKController {
  38793. private static _tmpVecs;
  38794. private static _tmpQuat;
  38795. private static _tmpMats;
  38796. /**
  38797. * Gets or sets the target mesh
  38798. */
  38799. targetMesh: AbstractMesh;
  38800. /** Gets or sets the mesh used as pole */
  38801. poleTargetMesh: AbstractMesh;
  38802. /**
  38803. * Gets or sets the bone used as pole
  38804. */
  38805. poleTargetBone: Nullable<Bone>;
  38806. /**
  38807. * Gets or sets the target position
  38808. */
  38809. targetPosition: Vector3;
  38810. /**
  38811. * Gets or sets the pole target position
  38812. */
  38813. poleTargetPosition: Vector3;
  38814. /**
  38815. * Gets or sets the pole target local offset
  38816. */
  38817. poleTargetLocalOffset: Vector3;
  38818. /**
  38819. * Gets or sets the pole angle
  38820. */
  38821. poleAngle: number;
  38822. /**
  38823. * Gets or sets the mesh associated with the controller
  38824. */
  38825. mesh: AbstractMesh;
  38826. /**
  38827. * 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)
  38828. */
  38829. slerpAmount: number;
  38830. private _bone1Quat;
  38831. private _bone1Mat;
  38832. private _bone2Ang;
  38833. private _bone1;
  38834. private _bone2;
  38835. private _bone1Length;
  38836. private _bone2Length;
  38837. private _maxAngle;
  38838. private _maxReach;
  38839. private _rightHandedSystem;
  38840. private _bendAxis;
  38841. private _slerping;
  38842. private _adjustRoll;
  38843. /**
  38844. * Gets or sets maximum allowed angle
  38845. */
  38846. maxAngle: number;
  38847. /**
  38848. * Creates a new BoneIKController
  38849. * @param mesh defines the mesh to control
  38850. * @param bone defines the bone to control
  38851. * @param options defines options to set up the controller
  38852. */
  38853. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38854. targetMesh?: AbstractMesh;
  38855. poleTargetMesh?: AbstractMesh;
  38856. poleTargetBone?: Bone;
  38857. poleTargetLocalOffset?: Vector3;
  38858. poleAngle?: number;
  38859. bendAxis?: Vector3;
  38860. maxAngle?: number;
  38861. slerpAmount?: number;
  38862. });
  38863. private _setMaxAngle;
  38864. /**
  38865. * Force the controller to update the bones
  38866. */
  38867. update(): void;
  38868. }
  38869. }
  38870. declare module "babylonjs/Bones/boneLookController" {
  38871. import { Vector3 } from "babylonjs/Maths/math.vector";
  38872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38873. import { Bone } from "babylonjs/Bones/bone";
  38874. import { Space } from "babylonjs/Maths/math.axis";
  38875. /**
  38876. * Class used to make a bone look toward a point in space
  38877. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38878. */
  38879. export class BoneLookController {
  38880. private static _tmpVecs;
  38881. private static _tmpQuat;
  38882. private static _tmpMats;
  38883. /**
  38884. * The target Vector3 that the bone will look at
  38885. */
  38886. target: Vector3;
  38887. /**
  38888. * The mesh that the bone is attached to
  38889. */
  38890. mesh: AbstractMesh;
  38891. /**
  38892. * The bone that will be looking to the target
  38893. */
  38894. bone: Bone;
  38895. /**
  38896. * The up axis of the coordinate system that is used when the bone is rotated
  38897. */
  38898. upAxis: Vector3;
  38899. /**
  38900. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38901. */
  38902. upAxisSpace: Space;
  38903. /**
  38904. * Used to make an adjustment to the yaw of the bone
  38905. */
  38906. adjustYaw: number;
  38907. /**
  38908. * Used to make an adjustment to the pitch of the bone
  38909. */
  38910. adjustPitch: number;
  38911. /**
  38912. * Used to make an adjustment to the roll of the bone
  38913. */
  38914. adjustRoll: number;
  38915. /**
  38916. * 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)
  38917. */
  38918. slerpAmount: number;
  38919. private _minYaw;
  38920. private _maxYaw;
  38921. private _minPitch;
  38922. private _maxPitch;
  38923. private _minYawSin;
  38924. private _minYawCos;
  38925. private _maxYawSin;
  38926. private _maxYawCos;
  38927. private _midYawConstraint;
  38928. private _minPitchTan;
  38929. private _maxPitchTan;
  38930. private _boneQuat;
  38931. private _slerping;
  38932. private _transformYawPitch;
  38933. private _transformYawPitchInv;
  38934. private _firstFrameSkipped;
  38935. private _yawRange;
  38936. private _fowardAxis;
  38937. /**
  38938. * Gets or sets the minimum yaw angle that the bone can look to
  38939. */
  38940. minYaw: number;
  38941. /**
  38942. * Gets or sets the maximum yaw angle that the bone can look to
  38943. */
  38944. maxYaw: number;
  38945. /**
  38946. * Gets or sets the minimum pitch angle that the bone can look to
  38947. */
  38948. minPitch: number;
  38949. /**
  38950. * Gets or sets the maximum pitch angle that the bone can look to
  38951. */
  38952. maxPitch: number;
  38953. /**
  38954. * Create a BoneLookController
  38955. * @param mesh the mesh that the bone belongs to
  38956. * @param bone the bone that will be looking to the target
  38957. * @param target the target Vector3 to look at
  38958. * @param options optional settings:
  38959. * * maxYaw: the maximum angle the bone will yaw to
  38960. * * minYaw: the minimum angle the bone will yaw to
  38961. * * maxPitch: the maximum angle the bone will pitch to
  38962. * * minPitch: the minimum angle the bone will yaw to
  38963. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38964. * * upAxis: the up axis of the coordinate system
  38965. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38966. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38967. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38968. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38969. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38970. * * adjustRoll: used to make an adjustment to the roll of the bone
  38971. **/
  38972. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38973. maxYaw?: number;
  38974. minYaw?: number;
  38975. maxPitch?: number;
  38976. minPitch?: number;
  38977. slerpAmount?: number;
  38978. upAxis?: Vector3;
  38979. upAxisSpace?: Space;
  38980. yawAxis?: Vector3;
  38981. pitchAxis?: Vector3;
  38982. adjustYaw?: number;
  38983. adjustPitch?: number;
  38984. adjustRoll?: number;
  38985. });
  38986. /**
  38987. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38988. */
  38989. update(): void;
  38990. private _getAngleDiff;
  38991. private _getAngleBetween;
  38992. private _isAngleBetween;
  38993. }
  38994. }
  38995. declare module "babylonjs/Bones/index" {
  38996. export * from "babylonjs/Bones/bone";
  38997. export * from "babylonjs/Bones/boneIKController";
  38998. export * from "babylonjs/Bones/boneLookController";
  38999. export * from "babylonjs/Bones/skeleton";
  39000. }
  39001. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  39002. import { Nullable } from "babylonjs/types";
  39003. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39004. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39005. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39006. /**
  39007. * Manage the gamepad inputs to control an arc rotate camera.
  39008. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39009. */
  39010. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39011. /**
  39012. * Defines the camera the input is attached to.
  39013. */
  39014. camera: ArcRotateCamera;
  39015. /**
  39016. * Defines the gamepad the input is gathering event from.
  39017. */
  39018. gamepad: Nullable<Gamepad>;
  39019. /**
  39020. * Defines the gamepad rotation sensiblity.
  39021. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39022. */
  39023. gamepadRotationSensibility: number;
  39024. /**
  39025. * Defines the gamepad move sensiblity.
  39026. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39027. */
  39028. gamepadMoveSensibility: number;
  39029. private _yAxisScale;
  39030. /**
  39031. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39032. */
  39033. invertYAxis: boolean;
  39034. private _onGamepadConnectedObserver;
  39035. private _onGamepadDisconnectedObserver;
  39036. /**
  39037. * Attach the input controls to a specific dom element to get the input from.
  39038. * @param element Defines the element the controls should be listened from
  39039. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39040. */
  39041. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39042. /**
  39043. * Detach the current controls from the specified dom element.
  39044. * @param element Defines the element to stop listening the inputs from
  39045. */
  39046. detachControl(element: Nullable<HTMLElement>): void;
  39047. /**
  39048. * Update the current camera state depending on the inputs that have been used this frame.
  39049. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39050. */
  39051. checkInputs(): void;
  39052. /**
  39053. * Gets the class name of the current intput.
  39054. * @returns the class name
  39055. */
  39056. getClassName(): string;
  39057. /**
  39058. * Get the friendly name associated with the input class.
  39059. * @returns the input friendly name
  39060. */
  39061. getSimpleName(): string;
  39062. }
  39063. }
  39064. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  39065. import { Nullable } from "babylonjs/types";
  39066. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39067. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39068. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39069. interface ArcRotateCameraInputsManager {
  39070. /**
  39071. * Add orientation input support to the input manager.
  39072. * @returns the current input manager
  39073. */
  39074. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39075. }
  39076. }
  39077. /**
  39078. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39079. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39080. */
  39081. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39082. /**
  39083. * Defines the camera the input is attached to.
  39084. */
  39085. camera: ArcRotateCamera;
  39086. /**
  39087. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39088. */
  39089. alphaCorrection: number;
  39090. /**
  39091. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39092. */
  39093. gammaCorrection: number;
  39094. private _alpha;
  39095. private _gamma;
  39096. private _dirty;
  39097. private _deviceOrientationHandler;
  39098. /**
  39099. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39100. */
  39101. constructor();
  39102. /**
  39103. * Attach the input controls to a specific dom element to get the input from.
  39104. * @param element Defines the element the controls should be listened from
  39105. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39106. */
  39107. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39108. /** @hidden */
  39109. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39110. /**
  39111. * Update the current camera state depending on the inputs that have been used this frame.
  39112. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39113. */
  39114. checkInputs(): void;
  39115. /**
  39116. * Detach the current controls from the specified dom element.
  39117. * @param element Defines the element to stop listening the inputs from
  39118. */
  39119. detachControl(element: Nullable<HTMLElement>): void;
  39120. /**
  39121. * Gets the class name of the current intput.
  39122. * @returns the class name
  39123. */
  39124. getClassName(): string;
  39125. /**
  39126. * Get the friendly name associated with the input class.
  39127. * @returns the input friendly name
  39128. */
  39129. getSimpleName(): string;
  39130. }
  39131. }
  39132. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  39133. import { Nullable } from "babylonjs/types";
  39134. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39135. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39136. /**
  39137. * Listen to mouse events to control the camera.
  39138. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39139. */
  39140. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39141. /**
  39142. * Defines the camera the input is attached to.
  39143. */
  39144. camera: FlyCamera;
  39145. /**
  39146. * Defines if touch is enabled. (Default is true.)
  39147. */
  39148. touchEnabled: boolean;
  39149. /**
  39150. * Defines the buttons associated with the input to handle camera rotation.
  39151. */
  39152. buttons: number[];
  39153. /**
  39154. * Assign buttons for Yaw control.
  39155. */
  39156. buttonsYaw: number[];
  39157. /**
  39158. * Assign buttons for Pitch control.
  39159. */
  39160. buttonsPitch: number[];
  39161. /**
  39162. * Assign buttons for Roll control.
  39163. */
  39164. buttonsRoll: number[];
  39165. /**
  39166. * Detect if any button is being pressed while mouse is moved.
  39167. * -1 = Mouse locked.
  39168. * 0 = Left button.
  39169. * 1 = Middle Button.
  39170. * 2 = Right Button.
  39171. */
  39172. activeButton: number;
  39173. /**
  39174. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39175. * Higher values reduce its sensitivity.
  39176. */
  39177. angularSensibility: number;
  39178. private _mousemoveCallback;
  39179. private _observer;
  39180. private _rollObserver;
  39181. private previousPosition;
  39182. private noPreventDefault;
  39183. private element;
  39184. /**
  39185. * Listen to mouse events to control the camera.
  39186. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39187. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39188. */
  39189. constructor(touchEnabled?: boolean);
  39190. /**
  39191. * Attach the mouse control to the HTML DOM element.
  39192. * @param element Defines the element that listens to the input events.
  39193. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39194. */
  39195. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39196. /**
  39197. * Detach the current controls from the specified dom element.
  39198. * @param element Defines the element to stop listening the inputs from
  39199. */
  39200. detachControl(element: Nullable<HTMLElement>): void;
  39201. /**
  39202. * Gets the class name of the current input.
  39203. * @returns the class name.
  39204. */
  39205. getClassName(): string;
  39206. /**
  39207. * Get the friendly name associated with the input class.
  39208. * @returns the input's friendly name.
  39209. */
  39210. getSimpleName(): string;
  39211. private _pointerInput;
  39212. private _onMouseMove;
  39213. /**
  39214. * Rotate camera by mouse offset.
  39215. */
  39216. private rotateCamera;
  39217. }
  39218. }
  39219. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  39220. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39221. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39222. /**
  39223. * Default Inputs manager for the FlyCamera.
  39224. * It groups all the default supported inputs for ease of use.
  39225. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39226. */
  39227. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39228. /**
  39229. * Instantiates a new FlyCameraInputsManager.
  39230. * @param camera Defines the camera the inputs belong to.
  39231. */
  39232. constructor(camera: FlyCamera);
  39233. /**
  39234. * Add keyboard input support to the input manager.
  39235. * @returns the new FlyCameraKeyboardMoveInput().
  39236. */
  39237. addKeyboard(): FlyCameraInputsManager;
  39238. /**
  39239. * Add mouse input support to the input manager.
  39240. * @param touchEnabled Enable touch screen support.
  39241. * @returns the new FlyCameraMouseInput().
  39242. */
  39243. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39244. }
  39245. }
  39246. declare module "babylonjs/Cameras/flyCamera" {
  39247. import { Scene } from "babylonjs/scene";
  39248. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  39249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39250. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39251. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  39252. /**
  39253. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39254. * such as in a 3D Space Shooter or a Flight Simulator.
  39255. */
  39256. export class FlyCamera extends TargetCamera {
  39257. /**
  39258. * Define the collision ellipsoid of the camera.
  39259. * This is helpful for simulating a camera body, like a player's body.
  39260. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39261. */
  39262. ellipsoid: Vector3;
  39263. /**
  39264. * Define an offset for the position of the ellipsoid around the camera.
  39265. * This can be helpful if the camera is attached away from the player's body center,
  39266. * such as at its head.
  39267. */
  39268. ellipsoidOffset: Vector3;
  39269. /**
  39270. * Enable or disable collisions of the camera with the rest of the scene objects.
  39271. */
  39272. checkCollisions: boolean;
  39273. /**
  39274. * Enable or disable gravity on the camera.
  39275. */
  39276. applyGravity: boolean;
  39277. /**
  39278. * Define the current direction the camera is moving to.
  39279. */
  39280. cameraDirection: Vector3;
  39281. /**
  39282. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39283. * This overrides and empties cameraRotation.
  39284. */
  39285. rotationQuaternion: Quaternion;
  39286. /**
  39287. * Track Roll to maintain the wanted Rolling when looking around.
  39288. */
  39289. _trackRoll: number;
  39290. /**
  39291. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39292. */
  39293. rollCorrect: number;
  39294. /**
  39295. * Mimic a banked turn, Rolling the camera when Yawing.
  39296. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39297. */
  39298. bankedTurn: boolean;
  39299. /**
  39300. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39301. */
  39302. bankedTurnLimit: number;
  39303. /**
  39304. * Value of 0 disables the banked Roll.
  39305. * Value of 1 is equal to the Yaw angle in radians.
  39306. */
  39307. bankedTurnMultiplier: number;
  39308. /**
  39309. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39310. */
  39311. inputs: FlyCameraInputsManager;
  39312. /**
  39313. * Gets the input sensibility for mouse input.
  39314. * Higher values reduce sensitivity.
  39315. */
  39316. /**
  39317. * Sets the input sensibility for a mouse input.
  39318. * Higher values reduce sensitivity.
  39319. */
  39320. angularSensibility: number;
  39321. /**
  39322. * Get the keys for camera movement forward.
  39323. */
  39324. /**
  39325. * Set the keys for camera movement forward.
  39326. */
  39327. keysForward: number[];
  39328. /**
  39329. * Get the keys for camera movement backward.
  39330. */
  39331. keysBackward: number[];
  39332. /**
  39333. * Get the keys for camera movement up.
  39334. */
  39335. /**
  39336. * Set the keys for camera movement up.
  39337. */
  39338. keysUp: number[];
  39339. /**
  39340. * Get the keys for camera movement down.
  39341. */
  39342. /**
  39343. * Set the keys for camera movement down.
  39344. */
  39345. keysDown: number[];
  39346. /**
  39347. * Get the keys for camera movement left.
  39348. */
  39349. /**
  39350. * Set the keys for camera movement left.
  39351. */
  39352. keysLeft: number[];
  39353. /**
  39354. * Set the keys for camera movement right.
  39355. */
  39356. /**
  39357. * Set the keys for camera movement right.
  39358. */
  39359. keysRight: number[];
  39360. /**
  39361. * Event raised when the camera collides with a mesh in the scene.
  39362. */
  39363. onCollide: (collidedMesh: AbstractMesh) => void;
  39364. private _collider;
  39365. private _needMoveForGravity;
  39366. private _oldPosition;
  39367. private _diffPosition;
  39368. private _newPosition;
  39369. /** @hidden */
  39370. _localDirection: Vector3;
  39371. /** @hidden */
  39372. _transformedDirection: Vector3;
  39373. /**
  39374. * Instantiates a FlyCamera.
  39375. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39376. * such as in a 3D Space Shooter or a Flight Simulator.
  39377. * @param name Define the name of the camera in the scene.
  39378. * @param position Define the starting position of the camera in the scene.
  39379. * @param scene Define the scene the camera belongs to.
  39380. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39381. */
  39382. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39383. /**
  39384. * Attach a control to the HTML DOM element.
  39385. * @param element Defines the element that listens to the input events.
  39386. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39387. */
  39388. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39389. /**
  39390. * Detach a control from the HTML DOM element.
  39391. * The camera will stop reacting to that input.
  39392. * @param element Defines the element that listens to the input events.
  39393. */
  39394. detachControl(element: HTMLElement): void;
  39395. private _collisionMask;
  39396. /**
  39397. * Get the mask that the camera ignores in collision events.
  39398. */
  39399. /**
  39400. * Set the mask that the camera ignores in collision events.
  39401. */
  39402. collisionMask: number;
  39403. /** @hidden */
  39404. _collideWithWorld(displacement: Vector3): void;
  39405. /** @hidden */
  39406. private _onCollisionPositionChange;
  39407. /** @hidden */
  39408. _checkInputs(): void;
  39409. /** @hidden */
  39410. _decideIfNeedsToMove(): boolean;
  39411. /** @hidden */
  39412. _updatePosition(): void;
  39413. /**
  39414. * Restore the Roll to its target value at the rate specified.
  39415. * @param rate - Higher means slower restoring.
  39416. * @hidden
  39417. */
  39418. restoreRoll(rate: number): void;
  39419. /**
  39420. * Destroy the camera and release the current resources held by it.
  39421. */
  39422. dispose(): void;
  39423. /**
  39424. * Get the current object class name.
  39425. * @returns the class name.
  39426. */
  39427. getClassName(): string;
  39428. }
  39429. }
  39430. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  39431. import { Nullable } from "babylonjs/types";
  39432. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39433. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39434. /**
  39435. * Listen to keyboard events to control the camera.
  39436. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39437. */
  39438. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39439. /**
  39440. * Defines the camera the input is attached to.
  39441. */
  39442. camera: FlyCamera;
  39443. /**
  39444. * The list of keyboard keys used to control the forward move of the camera.
  39445. */
  39446. keysForward: number[];
  39447. /**
  39448. * The list of keyboard keys used to control the backward move of the camera.
  39449. */
  39450. keysBackward: number[];
  39451. /**
  39452. * The list of keyboard keys used to control the forward move of the camera.
  39453. */
  39454. keysUp: number[];
  39455. /**
  39456. * The list of keyboard keys used to control the backward move of the camera.
  39457. */
  39458. keysDown: number[];
  39459. /**
  39460. * The list of keyboard keys used to control the right strafe move of the camera.
  39461. */
  39462. keysRight: number[];
  39463. /**
  39464. * The list of keyboard keys used to control the left strafe move of the camera.
  39465. */
  39466. keysLeft: number[];
  39467. private _keys;
  39468. private _onCanvasBlurObserver;
  39469. private _onKeyboardObserver;
  39470. private _engine;
  39471. private _scene;
  39472. /**
  39473. * Attach the input controls to a specific dom element to get the input from.
  39474. * @param element Defines the element the controls should be listened from
  39475. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39476. */
  39477. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39478. /**
  39479. * Detach the current controls from the specified dom element.
  39480. * @param element Defines the element to stop listening the inputs from
  39481. */
  39482. detachControl(element: Nullable<HTMLElement>): void;
  39483. /**
  39484. * Gets the class name of the current intput.
  39485. * @returns the class name
  39486. */
  39487. getClassName(): string;
  39488. /** @hidden */
  39489. _onLostFocus(e: FocusEvent): void;
  39490. /**
  39491. * Get the friendly name associated with the input class.
  39492. * @returns the input friendly name
  39493. */
  39494. getSimpleName(): string;
  39495. /**
  39496. * Update the current camera state depending on the inputs that have been used this frame.
  39497. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39498. */
  39499. checkInputs(): void;
  39500. }
  39501. }
  39502. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39503. import { Nullable } from "babylonjs/types";
  39504. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39505. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39506. /**
  39507. * Manage the mouse wheel inputs to control a follow camera.
  39508. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39509. */
  39510. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39511. /**
  39512. * Defines the camera the input is attached to.
  39513. */
  39514. camera: FollowCamera;
  39515. /**
  39516. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39517. */
  39518. axisControlRadius: boolean;
  39519. /**
  39520. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39521. */
  39522. axisControlHeight: boolean;
  39523. /**
  39524. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39525. */
  39526. axisControlRotation: boolean;
  39527. /**
  39528. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39529. * relation to mouseWheel events.
  39530. */
  39531. wheelPrecision: number;
  39532. /**
  39533. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39534. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39535. */
  39536. wheelDeltaPercentage: number;
  39537. private _wheel;
  39538. private _observer;
  39539. /**
  39540. * Attach the input controls to a specific dom element to get the input from.
  39541. * @param element Defines the element the controls should be listened from
  39542. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39543. */
  39544. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39545. /**
  39546. * Detach the current controls from the specified dom element.
  39547. * @param element Defines the element to stop listening the inputs from
  39548. */
  39549. detachControl(element: Nullable<HTMLElement>): void;
  39550. /**
  39551. * Gets the class name of the current intput.
  39552. * @returns the class name
  39553. */
  39554. getClassName(): string;
  39555. /**
  39556. * Get the friendly name associated with the input class.
  39557. * @returns the input friendly name
  39558. */
  39559. getSimpleName(): string;
  39560. }
  39561. }
  39562. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39563. import { Nullable } from "babylonjs/types";
  39564. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39565. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39566. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39567. /**
  39568. * Manage the pointers inputs to control an follow camera.
  39569. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39570. */
  39571. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39572. /**
  39573. * Defines the camera the input is attached to.
  39574. */
  39575. camera: FollowCamera;
  39576. /**
  39577. * Gets the class name of the current input.
  39578. * @returns the class name
  39579. */
  39580. getClassName(): string;
  39581. /**
  39582. * Defines the pointer angular sensibility along the X axis or how fast is
  39583. * the camera rotating.
  39584. * A negative number will reverse the axis direction.
  39585. */
  39586. angularSensibilityX: number;
  39587. /**
  39588. * Defines the pointer angular sensibility along the Y axis or how fast is
  39589. * the camera rotating.
  39590. * A negative number will reverse the axis direction.
  39591. */
  39592. angularSensibilityY: number;
  39593. /**
  39594. * Defines the pointer pinch precision or how fast is the camera zooming.
  39595. * A negative number will reverse the axis direction.
  39596. */
  39597. pinchPrecision: number;
  39598. /**
  39599. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39600. * from 0.
  39601. * It defines the percentage of current camera.radius to use as delta when
  39602. * pinch zoom is used.
  39603. */
  39604. pinchDeltaPercentage: number;
  39605. /**
  39606. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39607. */
  39608. axisXControlRadius: boolean;
  39609. /**
  39610. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39611. */
  39612. axisXControlHeight: boolean;
  39613. /**
  39614. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39615. */
  39616. axisXControlRotation: boolean;
  39617. /**
  39618. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39619. */
  39620. axisYControlRadius: boolean;
  39621. /**
  39622. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39623. */
  39624. axisYControlHeight: boolean;
  39625. /**
  39626. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39627. */
  39628. axisYControlRotation: boolean;
  39629. /**
  39630. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39631. */
  39632. axisPinchControlRadius: boolean;
  39633. /**
  39634. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39635. */
  39636. axisPinchControlHeight: boolean;
  39637. /**
  39638. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39639. */
  39640. axisPinchControlRotation: boolean;
  39641. /**
  39642. * Log error messages if basic misconfiguration has occurred.
  39643. */
  39644. warningEnable: boolean;
  39645. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39646. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39647. private _warningCounter;
  39648. private _warning;
  39649. }
  39650. }
  39651. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39652. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39653. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39654. /**
  39655. * Default Inputs manager for the FollowCamera.
  39656. * It groups all the default supported inputs for ease of use.
  39657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39658. */
  39659. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39660. /**
  39661. * Instantiates a new FollowCameraInputsManager.
  39662. * @param camera Defines the camera the inputs belong to
  39663. */
  39664. constructor(camera: FollowCamera);
  39665. /**
  39666. * Add keyboard input support to the input manager.
  39667. * @returns the current input manager
  39668. */
  39669. addKeyboard(): FollowCameraInputsManager;
  39670. /**
  39671. * Add mouse wheel input support to the input manager.
  39672. * @returns the current input manager
  39673. */
  39674. addMouseWheel(): FollowCameraInputsManager;
  39675. /**
  39676. * Add pointers input support to the input manager.
  39677. * @returns the current input manager
  39678. */
  39679. addPointers(): FollowCameraInputsManager;
  39680. /**
  39681. * Add orientation input support to the input manager.
  39682. * @returns the current input manager
  39683. */
  39684. addVRDeviceOrientation(): FollowCameraInputsManager;
  39685. }
  39686. }
  39687. declare module "babylonjs/Cameras/followCamera" {
  39688. import { Nullable } from "babylonjs/types";
  39689. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39690. import { Scene } from "babylonjs/scene";
  39691. import { Vector3 } from "babylonjs/Maths/math.vector";
  39692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39693. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39694. /**
  39695. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39696. * an arc rotate version arcFollowCamera are available.
  39697. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39698. */
  39699. export class FollowCamera extends TargetCamera {
  39700. /**
  39701. * Distance the follow camera should follow an object at
  39702. */
  39703. radius: number;
  39704. /**
  39705. * Minimum allowed distance of the camera to the axis of rotation
  39706. * (The camera can not get closer).
  39707. * This can help limiting how the Camera is able to move in the scene.
  39708. */
  39709. lowerRadiusLimit: Nullable<number>;
  39710. /**
  39711. * Maximum allowed distance of the camera to the axis of rotation
  39712. * (The camera can not get further).
  39713. * This can help limiting how the Camera is able to move in the scene.
  39714. */
  39715. upperRadiusLimit: Nullable<number>;
  39716. /**
  39717. * Define a rotation offset between the camera and the object it follows
  39718. */
  39719. rotationOffset: number;
  39720. /**
  39721. * Minimum allowed angle to camera position relative to target object.
  39722. * This can help limiting how the Camera is able to move in the scene.
  39723. */
  39724. lowerRotationOffsetLimit: Nullable<number>;
  39725. /**
  39726. * Maximum allowed angle to camera position relative to target object.
  39727. * This can help limiting how the Camera is able to move in the scene.
  39728. */
  39729. upperRotationOffsetLimit: Nullable<number>;
  39730. /**
  39731. * Define a height offset between the camera and the object it follows.
  39732. * It can help following an object from the top (like a car chaing a plane)
  39733. */
  39734. heightOffset: number;
  39735. /**
  39736. * Minimum allowed height of camera position relative to target object.
  39737. * This can help limiting how the Camera is able to move in the scene.
  39738. */
  39739. lowerHeightOffsetLimit: Nullable<number>;
  39740. /**
  39741. * Maximum allowed height of camera position relative to target object.
  39742. * This can help limiting how the Camera is able to move in the scene.
  39743. */
  39744. upperHeightOffsetLimit: Nullable<number>;
  39745. /**
  39746. * Define how fast the camera can accelerate to follow it s target.
  39747. */
  39748. cameraAcceleration: number;
  39749. /**
  39750. * Define the speed limit of the camera following an object.
  39751. */
  39752. maxCameraSpeed: number;
  39753. /**
  39754. * Define the target of the camera.
  39755. */
  39756. lockedTarget: Nullable<AbstractMesh>;
  39757. /**
  39758. * Defines the input associated with the camera.
  39759. */
  39760. inputs: FollowCameraInputsManager;
  39761. /**
  39762. * Instantiates the follow camera.
  39763. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39764. * @param name Define the name of the camera in the scene
  39765. * @param position Define the position of the camera
  39766. * @param scene Define the scene the camera belong to
  39767. * @param lockedTarget Define the target of the camera
  39768. */
  39769. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39770. private _follow;
  39771. /**
  39772. * Attached controls to the current camera.
  39773. * @param element Defines the element the controls should be listened from
  39774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39775. */
  39776. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39777. /**
  39778. * Detach the current controls from the camera.
  39779. * The camera will stop reacting to inputs.
  39780. * @param element Defines the element to stop listening the inputs from
  39781. */
  39782. detachControl(element: HTMLElement): void;
  39783. /** @hidden */
  39784. _checkInputs(): void;
  39785. private _checkLimits;
  39786. /**
  39787. * Gets the camera class name.
  39788. * @returns the class name
  39789. */
  39790. getClassName(): string;
  39791. }
  39792. /**
  39793. * Arc Rotate version of the follow camera.
  39794. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39795. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39796. */
  39797. export class ArcFollowCamera extends TargetCamera {
  39798. /** The longitudinal angle of the camera */
  39799. alpha: number;
  39800. /** The latitudinal angle of the camera */
  39801. beta: number;
  39802. /** The radius of the camera from its target */
  39803. radius: number;
  39804. /** Define the camera target (the messh it should follow) */
  39805. target: Nullable<AbstractMesh>;
  39806. private _cartesianCoordinates;
  39807. /**
  39808. * Instantiates a new ArcFollowCamera
  39809. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39810. * @param name Define the name of the camera
  39811. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39812. * @param beta Define the rotation angle of the camera around the elevation axis
  39813. * @param radius Define the radius of the camera from its target point
  39814. * @param target Define the target of the camera
  39815. * @param scene Define the scene the camera belongs to
  39816. */
  39817. constructor(name: string,
  39818. /** The longitudinal angle of the camera */
  39819. alpha: number,
  39820. /** The latitudinal angle of the camera */
  39821. beta: number,
  39822. /** The radius of the camera from its target */
  39823. radius: number,
  39824. /** Define the camera target (the messh it should follow) */
  39825. target: Nullable<AbstractMesh>, scene: Scene);
  39826. private _follow;
  39827. /** @hidden */
  39828. _checkInputs(): void;
  39829. /**
  39830. * Returns the class name of the object.
  39831. * It is mostly used internally for serialization purposes.
  39832. */
  39833. getClassName(): string;
  39834. }
  39835. }
  39836. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39837. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39838. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39839. import { Nullable } from "babylonjs/types";
  39840. /**
  39841. * Manage the keyboard inputs to control the movement of a follow camera.
  39842. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39843. */
  39844. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39845. /**
  39846. * Defines the camera the input is attached to.
  39847. */
  39848. camera: FollowCamera;
  39849. /**
  39850. * Defines the list of key codes associated with the up action (increase heightOffset)
  39851. */
  39852. keysHeightOffsetIncr: number[];
  39853. /**
  39854. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39855. */
  39856. keysHeightOffsetDecr: number[];
  39857. /**
  39858. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39859. */
  39860. keysHeightOffsetModifierAlt: boolean;
  39861. /**
  39862. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39863. */
  39864. keysHeightOffsetModifierCtrl: boolean;
  39865. /**
  39866. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39867. */
  39868. keysHeightOffsetModifierShift: boolean;
  39869. /**
  39870. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39871. */
  39872. keysRotationOffsetIncr: number[];
  39873. /**
  39874. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39875. */
  39876. keysRotationOffsetDecr: number[];
  39877. /**
  39878. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39879. */
  39880. keysRotationOffsetModifierAlt: boolean;
  39881. /**
  39882. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39883. */
  39884. keysRotationOffsetModifierCtrl: boolean;
  39885. /**
  39886. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39887. */
  39888. keysRotationOffsetModifierShift: boolean;
  39889. /**
  39890. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39891. */
  39892. keysRadiusIncr: number[];
  39893. /**
  39894. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39895. */
  39896. keysRadiusDecr: number[];
  39897. /**
  39898. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39899. */
  39900. keysRadiusModifierAlt: boolean;
  39901. /**
  39902. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39903. */
  39904. keysRadiusModifierCtrl: boolean;
  39905. /**
  39906. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39907. */
  39908. keysRadiusModifierShift: boolean;
  39909. /**
  39910. * Defines the rate of change of heightOffset.
  39911. */
  39912. heightSensibility: number;
  39913. /**
  39914. * Defines the rate of change of rotationOffset.
  39915. */
  39916. rotationSensibility: number;
  39917. /**
  39918. * Defines the rate of change of radius.
  39919. */
  39920. radiusSensibility: number;
  39921. private _keys;
  39922. private _ctrlPressed;
  39923. private _altPressed;
  39924. private _shiftPressed;
  39925. private _onCanvasBlurObserver;
  39926. private _onKeyboardObserver;
  39927. private _engine;
  39928. private _scene;
  39929. /**
  39930. * Attach the input controls to a specific dom element to get the input from.
  39931. * @param element Defines the element the controls should be listened from
  39932. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39933. */
  39934. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39935. /**
  39936. * Detach the current controls from the specified dom element.
  39937. * @param element Defines the element to stop listening the inputs from
  39938. */
  39939. detachControl(element: Nullable<HTMLElement>): void;
  39940. /**
  39941. * Update the current camera state depending on the inputs that have been used this frame.
  39942. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39943. */
  39944. checkInputs(): void;
  39945. /**
  39946. * Gets the class name of the current input.
  39947. * @returns the class name
  39948. */
  39949. getClassName(): string;
  39950. /**
  39951. * Get the friendly name associated with the input class.
  39952. * @returns the input friendly name
  39953. */
  39954. getSimpleName(): string;
  39955. /**
  39956. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39957. * allow modification of the heightOffset value.
  39958. */
  39959. private _modifierHeightOffset;
  39960. /**
  39961. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39962. * allow modification of the rotationOffset value.
  39963. */
  39964. private _modifierRotationOffset;
  39965. /**
  39966. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39967. * allow modification of the radius value.
  39968. */
  39969. private _modifierRadius;
  39970. }
  39971. }
  39972. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39973. import { Nullable } from "babylonjs/types";
  39974. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39975. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39976. import { Observable } from "babylonjs/Misc/observable";
  39977. module "babylonjs/Cameras/freeCameraInputsManager" {
  39978. interface FreeCameraInputsManager {
  39979. /**
  39980. * @hidden
  39981. */
  39982. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39983. /**
  39984. * Add orientation input support to the input manager.
  39985. * @returns the current input manager
  39986. */
  39987. addDeviceOrientation(): FreeCameraInputsManager;
  39988. }
  39989. }
  39990. /**
  39991. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39992. * Screen rotation is taken into account.
  39993. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39994. */
  39995. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39996. private _camera;
  39997. private _screenOrientationAngle;
  39998. private _constantTranform;
  39999. private _screenQuaternion;
  40000. private _alpha;
  40001. private _beta;
  40002. private _gamma;
  40003. /**
  40004. * Can be used to detect if a device orientation sensor is availible on a device
  40005. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40006. * @returns a promise that will resolve on orientation change
  40007. */
  40008. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40009. /**
  40010. * @hidden
  40011. */
  40012. _onDeviceOrientationChangedObservable: Observable<void>;
  40013. /**
  40014. * Instantiates a new input
  40015. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40016. */
  40017. constructor();
  40018. /**
  40019. * Define the camera controlled by the input.
  40020. */
  40021. camera: FreeCamera;
  40022. /**
  40023. * Attach the input controls to a specific dom element to get the input from.
  40024. * @param element Defines the element the controls should be listened from
  40025. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40026. */
  40027. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40028. private _orientationChanged;
  40029. private _deviceOrientation;
  40030. /**
  40031. * Detach the current controls from the specified dom element.
  40032. * @param element Defines the element to stop listening the inputs from
  40033. */
  40034. detachControl(element: Nullable<HTMLElement>): void;
  40035. /**
  40036. * Update the current camera state depending on the inputs that have been used this frame.
  40037. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40038. */
  40039. checkInputs(): void;
  40040. /**
  40041. * Gets the class name of the current intput.
  40042. * @returns the class name
  40043. */
  40044. getClassName(): string;
  40045. /**
  40046. * Get the friendly name associated with the input class.
  40047. * @returns the input friendly name
  40048. */
  40049. getSimpleName(): string;
  40050. }
  40051. }
  40052. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  40053. import { Nullable } from "babylonjs/types";
  40054. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40055. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40056. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40057. /**
  40058. * Manage the gamepad inputs to control a free camera.
  40059. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40060. */
  40061. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40062. /**
  40063. * Define the camera the input is attached to.
  40064. */
  40065. camera: FreeCamera;
  40066. /**
  40067. * Define the Gamepad controlling the input
  40068. */
  40069. gamepad: Nullable<Gamepad>;
  40070. /**
  40071. * Defines the gamepad rotation sensiblity.
  40072. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40073. */
  40074. gamepadAngularSensibility: number;
  40075. /**
  40076. * Defines the gamepad move sensiblity.
  40077. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40078. */
  40079. gamepadMoveSensibility: number;
  40080. private _yAxisScale;
  40081. /**
  40082. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40083. */
  40084. invertYAxis: boolean;
  40085. private _onGamepadConnectedObserver;
  40086. private _onGamepadDisconnectedObserver;
  40087. private _cameraTransform;
  40088. private _deltaTransform;
  40089. private _vector3;
  40090. private _vector2;
  40091. /**
  40092. * Attach the input controls to a specific dom element to get the input from.
  40093. * @param element Defines the element the controls should be listened from
  40094. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40095. */
  40096. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40097. /**
  40098. * Detach the current controls from the specified dom element.
  40099. * @param element Defines the element to stop listening the inputs from
  40100. */
  40101. detachControl(element: Nullable<HTMLElement>): void;
  40102. /**
  40103. * Update the current camera state depending on the inputs that have been used this frame.
  40104. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40105. */
  40106. checkInputs(): void;
  40107. /**
  40108. * Gets the class name of the current intput.
  40109. * @returns the class name
  40110. */
  40111. getClassName(): string;
  40112. /**
  40113. * Get the friendly name associated with the input class.
  40114. * @returns the input friendly name
  40115. */
  40116. getSimpleName(): string;
  40117. }
  40118. }
  40119. declare module "babylonjs/Misc/virtualJoystick" {
  40120. import { Nullable } from "babylonjs/types";
  40121. import { Vector3 } from "babylonjs/Maths/math.vector";
  40122. /**
  40123. * Defines the potential axis of a Joystick
  40124. */
  40125. export enum JoystickAxis {
  40126. /** X axis */
  40127. X = 0,
  40128. /** Y axis */
  40129. Y = 1,
  40130. /** Z axis */
  40131. Z = 2
  40132. }
  40133. /**
  40134. * Class used to define virtual joystick (used in touch mode)
  40135. */
  40136. export class VirtualJoystick {
  40137. /**
  40138. * Gets or sets a boolean indicating that left and right values must be inverted
  40139. */
  40140. reverseLeftRight: boolean;
  40141. /**
  40142. * Gets or sets a boolean indicating that up and down values must be inverted
  40143. */
  40144. reverseUpDown: boolean;
  40145. /**
  40146. * Gets the offset value for the position (ie. the change of the position value)
  40147. */
  40148. deltaPosition: Vector3;
  40149. /**
  40150. * Gets a boolean indicating if the virtual joystick was pressed
  40151. */
  40152. pressed: boolean;
  40153. /**
  40154. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40155. */
  40156. static Canvas: Nullable<HTMLCanvasElement>;
  40157. private static _globalJoystickIndex;
  40158. private static vjCanvasContext;
  40159. private static vjCanvasWidth;
  40160. private static vjCanvasHeight;
  40161. private static halfWidth;
  40162. private _action;
  40163. private _axisTargetedByLeftAndRight;
  40164. private _axisTargetedByUpAndDown;
  40165. private _joystickSensibility;
  40166. private _inversedSensibility;
  40167. private _joystickPointerID;
  40168. private _joystickColor;
  40169. private _joystickPointerPos;
  40170. private _joystickPreviousPointerPos;
  40171. private _joystickPointerStartPos;
  40172. private _deltaJoystickVector;
  40173. private _leftJoystick;
  40174. private _touches;
  40175. private _onPointerDownHandlerRef;
  40176. private _onPointerMoveHandlerRef;
  40177. private _onPointerUpHandlerRef;
  40178. private _onResize;
  40179. /**
  40180. * Creates a new virtual joystick
  40181. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40182. */
  40183. constructor(leftJoystick?: boolean);
  40184. /**
  40185. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40186. * @param newJoystickSensibility defines the new sensibility
  40187. */
  40188. setJoystickSensibility(newJoystickSensibility: number): void;
  40189. private _onPointerDown;
  40190. private _onPointerMove;
  40191. private _onPointerUp;
  40192. /**
  40193. * Change the color of the virtual joystick
  40194. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40195. */
  40196. setJoystickColor(newColor: string): void;
  40197. /**
  40198. * Defines a callback to call when the joystick is touched
  40199. * @param action defines the callback
  40200. */
  40201. setActionOnTouch(action: () => any): void;
  40202. /**
  40203. * Defines which axis you'd like to control for left & right
  40204. * @param axis defines the axis to use
  40205. */
  40206. setAxisForLeftRight(axis: JoystickAxis): void;
  40207. /**
  40208. * Defines which axis you'd like to control for up & down
  40209. * @param axis defines the axis to use
  40210. */
  40211. setAxisForUpDown(axis: JoystickAxis): void;
  40212. private _drawVirtualJoystick;
  40213. /**
  40214. * Release internal HTML canvas
  40215. */
  40216. releaseCanvas(): void;
  40217. }
  40218. }
  40219. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  40220. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  40221. import { Nullable } from "babylonjs/types";
  40222. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40223. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40224. module "babylonjs/Cameras/freeCameraInputsManager" {
  40225. interface FreeCameraInputsManager {
  40226. /**
  40227. * Add virtual joystick input support to the input manager.
  40228. * @returns the current input manager
  40229. */
  40230. addVirtualJoystick(): FreeCameraInputsManager;
  40231. }
  40232. }
  40233. /**
  40234. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40235. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40236. */
  40237. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40238. /**
  40239. * Defines the camera the input is attached to.
  40240. */
  40241. camera: FreeCamera;
  40242. private _leftjoystick;
  40243. private _rightjoystick;
  40244. /**
  40245. * Gets the left stick of the virtual joystick.
  40246. * @returns The virtual Joystick
  40247. */
  40248. getLeftJoystick(): VirtualJoystick;
  40249. /**
  40250. * Gets the right stick of the virtual joystick.
  40251. * @returns The virtual Joystick
  40252. */
  40253. getRightJoystick(): VirtualJoystick;
  40254. /**
  40255. * Update the current camera state depending on the inputs that have been used this frame.
  40256. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40257. */
  40258. checkInputs(): void;
  40259. /**
  40260. * Attach the input controls to a specific dom element to get the input from.
  40261. * @param element Defines the element the controls should be listened from
  40262. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40263. */
  40264. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40265. /**
  40266. * Detach the current controls from the specified dom element.
  40267. * @param element Defines the element to stop listening the inputs from
  40268. */
  40269. detachControl(element: Nullable<HTMLElement>): void;
  40270. /**
  40271. * Gets the class name of the current intput.
  40272. * @returns the class name
  40273. */
  40274. getClassName(): string;
  40275. /**
  40276. * Get the friendly name associated with the input class.
  40277. * @returns the input friendly name
  40278. */
  40279. getSimpleName(): string;
  40280. }
  40281. }
  40282. declare module "babylonjs/Cameras/Inputs/index" {
  40283. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  40284. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  40285. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  40286. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  40287. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40288. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  40289. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  40290. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  40291. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  40292. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  40293. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40294. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  40295. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  40296. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  40297. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  40298. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40299. }
  40300. declare module "babylonjs/Cameras/touchCamera" {
  40301. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40302. import { Scene } from "babylonjs/scene";
  40303. import { Vector3 } from "babylonjs/Maths/math.vector";
  40304. /**
  40305. * This represents a FPS type of camera controlled by touch.
  40306. * This is like a universal camera minus the Gamepad controls.
  40307. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40308. */
  40309. export class TouchCamera extends FreeCamera {
  40310. /**
  40311. * Defines the touch sensibility for rotation.
  40312. * The higher the faster.
  40313. */
  40314. touchAngularSensibility: number;
  40315. /**
  40316. * Defines the touch sensibility for move.
  40317. * The higher the faster.
  40318. */
  40319. touchMoveSensibility: number;
  40320. /**
  40321. * Instantiates a new touch camera.
  40322. * This represents a FPS type of camera controlled by touch.
  40323. * This is like a universal camera minus the Gamepad controls.
  40324. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40325. * @param name Define the name of the camera in the scene
  40326. * @param position Define the start position of the camera in the scene
  40327. * @param scene Define the scene the camera belongs to
  40328. */
  40329. constructor(name: string, position: Vector3, scene: Scene);
  40330. /**
  40331. * Gets the current object class name.
  40332. * @return the class name
  40333. */
  40334. getClassName(): string;
  40335. /** @hidden */
  40336. _setupInputs(): void;
  40337. }
  40338. }
  40339. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  40340. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40341. import { Scene } from "babylonjs/scene";
  40342. import { Vector3 } from "babylonjs/Maths/math.vector";
  40343. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40344. import { Axis } from "babylonjs/Maths/math.axis";
  40345. /**
  40346. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40347. * being tilted forward or back and left or right.
  40348. */
  40349. export class DeviceOrientationCamera extends FreeCamera {
  40350. private _initialQuaternion;
  40351. private _quaternionCache;
  40352. private _tmpDragQuaternion;
  40353. private _disablePointerInputWhenUsingDeviceOrientation;
  40354. /**
  40355. * Creates a new device orientation camera
  40356. * @param name The name of the camera
  40357. * @param position The start position camera
  40358. * @param scene The scene the camera belongs to
  40359. */
  40360. constructor(name: string, position: Vector3, scene: Scene);
  40361. /**
  40362. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40363. */
  40364. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40365. private _dragFactor;
  40366. /**
  40367. * Enabled turning on the y axis when the orientation sensor is active
  40368. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40369. */
  40370. enableHorizontalDragging(dragFactor?: number): void;
  40371. /**
  40372. * Gets the current instance class name ("DeviceOrientationCamera").
  40373. * This helps avoiding instanceof at run time.
  40374. * @returns the class name
  40375. */
  40376. getClassName(): string;
  40377. /**
  40378. * @hidden
  40379. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40380. */
  40381. _checkInputs(): void;
  40382. /**
  40383. * Reset the camera to its default orientation on the specified axis only.
  40384. * @param axis The axis to reset
  40385. */
  40386. resetToCurrentRotation(axis?: Axis): void;
  40387. }
  40388. }
  40389. declare module "babylonjs/Gamepads/xboxGamepad" {
  40390. import { Observable } from "babylonjs/Misc/observable";
  40391. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40392. /**
  40393. * Defines supported buttons for XBox360 compatible gamepads
  40394. */
  40395. export enum Xbox360Button {
  40396. /** A */
  40397. A = 0,
  40398. /** B */
  40399. B = 1,
  40400. /** X */
  40401. X = 2,
  40402. /** Y */
  40403. Y = 3,
  40404. /** Start */
  40405. Start = 4,
  40406. /** Back */
  40407. Back = 5,
  40408. /** Left button */
  40409. LB = 6,
  40410. /** Right button */
  40411. RB = 7,
  40412. /** Left stick */
  40413. LeftStick = 8,
  40414. /** Right stick */
  40415. RightStick = 9
  40416. }
  40417. /** Defines values for XBox360 DPad */
  40418. export enum Xbox360Dpad {
  40419. /** Up */
  40420. Up = 0,
  40421. /** Down */
  40422. Down = 1,
  40423. /** Left */
  40424. Left = 2,
  40425. /** Right */
  40426. Right = 3
  40427. }
  40428. /**
  40429. * Defines a XBox360 gamepad
  40430. */
  40431. export class Xbox360Pad extends Gamepad {
  40432. private _leftTrigger;
  40433. private _rightTrigger;
  40434. private _onlefttriggerchanged;
  40435. private _onrighttriggerchanged;
  40436. private _onbuttondown;
  40437. private _onbuttonup;
  40438. private _ondpaddown;
  40439. private _ondpadup;
  40440. /** Observable raised when a button is pressed */
  40441. onButtonDownObservable: Observable<Xbox360Button>;
  40442. /** Observable raised when a button is released */
  40443. onButtonUpObservable: Observable<Xbox360Button>;
  40444. /** Observable raised when a pad is pressed */
  40445. onPadDownObservable: Observable<Xbox360Dpad>;
  40446. /** Observable raised when a pad is released */
  40447. onPadUpObservable: Observable<Xbox360Dpad>;
  40448. private _buttonA;
  40449. private _buttonB;
  40450. private _buttonX;
  40451. private _buttonY;
  40452. private _buttonBack;
  40453. private _buttonStart;
  40454. private _buttonLB;
  40455. private _buttonRB;
  40456. private _buttonLeftStick;
  40457. private _buttonRightStick;
  40458. private _dPadUp;
  40459. private _dPadDown;
  40460. private _dPadLeft;
  40461. private _dPadRight;
  40462. private _isXboxOnePad;
  40463. /**
  40464. * Creates a new XBox360 gamepad object
  40465. * @param id defines the id of this gamepad
  40466. * @param index defines its index
  40467. * @param gamepad defines the internal HTML gamepad object
  40468. * @param xboxOne defines if it is a XBox One gamepad
  40469. */
  40470. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40471. /**
  40472. * Defines the callback to call when left trigger is pressed
  40473. * @param callback defines the callback to use
  40474. */
  40475. onlefttriggerchanged(callback: (value: number) => void): void;
  40476. /**
  40477. * Defines the callback to call when right trigger is pressed
  40478. * @param callback defines the callback to use
  40479. */
  40480. onrighttriggerchanged(callback: (value: number) => void): void;
  40481. /**
  40482. * Gets the left trigger value
  40483. */
  40484. /**
  40485. * Sets the left trigger value
  40486. */
  40487. leftTrigger: number;
  40488. /**
  40489. * Gets the right trigger value
  40490. */
  40491. /**
  40492. * Sets the right trigger value
  40493. */
  40494. rightTrigger: number;
  40495. /**
  40496. * Defines the callback to call when a button is pressed
  40497. * @param callback defines the callback to use
  40498. */
  40499. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40500. /**
  40501. * Defines the callback to call when a button is released
  40502. * @param callback defines the callback to use
  40503. */
  40504. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40505. /**
  40506. * Defines the callback to call when a pad is pressed
  40507. * @param callback defines the callback to use
  40508. */
  40509. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40510. /**
  40511. * Defines the callback to call when a pad is released
  40512. * @param callback defines the callback to use
  40513. */
  40514. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40515. private _setButtonValue;
  40516. private _setDPadValue;
  40517. /**
  40518. * Gets the value of the `A` button
  40519. */
  40520. /**
  40521. * Sets the value of the `A` button
  40522. */
  40523. buttonA: number;
  40524. /**
  40525. * Gets the value of the `B` button
  40526. */
  40527. /**
  40528. * Sets the value of the `B` button
  40529. */
  40530. buttonB: number;
  40531. /**
  40532. * Gets the value of the `X` button
  40533. */
  40534. /**
  40535. * Sets the value of the `X` button
  40536. */
  40537. buttonX: number;
  40538. /**
  40539. * Gets the value of the `Y` button
  40540. */
  40541. /**
  40542. * Sets the value of the `Y` button
  40543. */
  40544. buttonY: number;
  40545. /**
  40546. * Gets the value of the `Start` button
  40547. */
  40548. /**
  40549. * Sets the value of the `Start` button
  40550. */
  40551. buttonStart: number;
  40552. /**
  40553. * Gets the value of the `Back` button
  40554. */
  40555. /**
  40556. * Sets the value of the `Back` button
  40557. */
  40558. buttonBack: number;
  40559. /**
  40560. * Gets the value of the `Left` button
  40561. */
  40562. /**
  40563. * Sets the value of the `Left` button
  40564. */
  40565. buttonLB: number;
  40566. /**
  40567. * Gets the value of the `Right` button
  40568. */
  40569. /**
  40570. * Sets the value of the `Right` button
  40571. */
  40572. buttonRB: number;
  40573. /**
  40574. * Gets the value of the Left joystick
  40575. */
  40576. /**
  40577. * Sets the value of the Left joystick
  40578. */
  40579. buttonLeftStick: number;
  40580. /**
  40581. * Gets the value of the Right joystick
  40582. */
  40583. /**
  40584. * Sets the value of the Right joystick
  40585. */
  40586. buttonRightStick: number;
  40587. /**
  40588. * Gets the value of D-pad up
  40589. */
  40590. /**
  40591. * Sets the value of D-pad up
  40592. */
  40593. dPadUp: number;
  40594. /**
  40595. * Gets the value of D-pad down
  40596. */
  40597. /**
  40598. * Sets the value of D-pad down
  40599. */
  40600. dPadDown: number;
  40601. /**
  40602. * Gets the value of D-pad left
  40603. */
  40604. /**
  40605. * Sets the value of D-pad left
  40606. */
  40607. dPadLeft: number;
  40608. /**
  40609. * Gets the value of D-pad right
  40610. */
  40611. /**
  40612. * Sets the value of D-pad right
  40613. */
  40614. dPadRight: number;
  40615. /**
  40616. * Force the gamepad to synchronize with device values
  40617. */
  40618. update(): void;
  40619. /**
  40620. * Disposes the gamepad
  40621. */
  40622. dispose(): void;
  40623. }
  40624. }
  40625. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40626. import { Observable } from "babylonjs/Misc/observable";
  40627. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40628. /**
  40629. * Defines supported buttons for DualShock compatible gamepads
  40630. */
  40631. export enum DualShockButton {
  40632. /** Cross */
  40633. Cross = 0,
  40634. /** Circle */
  40635. Circle = 1,
  40636. /** Square */
  40637. Square = 2,
  40638. /** Triangle */
  40639. Triangle = 3,
  40640. /** Options */
  40641. Options = 4,
  40642. /** Share */
  40643. Share = 5,
  40644. /** L1 */
  40645. L1 = 6,
  40646. /** R1 */
  40647. R1 = 7,
  40648. /** Left stick */
  40649. LeftStick = 8,
  40650. /** Right stick */
  40651. RightStick = 9
  40652. }
  40653. /** Defines values for DualShock DPad */
  40654. export enum DualShockDpad {
  40655. /** Up */
  40656. Up = 0,
  40657. /** Down */
  40658. Down = 1,
  40659. /** Left */
  40660. Left = 2,
  40661. /** Right */
  40662. Right = 3
  40663. }
  40664. /**
  40665. * Defines a DualShock gamepad
  40666. */
  40667. export class DualShockPad extends Gamepad {
  40668. private _leftTrigger;
  40669. private _rightTrigger;
  40670. private _onlefttriggerchanged;
  40671. private _onrighttriggerchanged;
  40672. private _onbuttondown;
  40673. private _onbuttonup;
  40674. private _ondpaddown;
  40675. private _ondpadup;
  40676. /** Observable raised when a button is pressed */
  40677. onButtonDownObservable: Observable<DualShockButton>;
  40678. /** Observable raised when a button is released */
  40679. onButtonUpObservable: Observable<DualShockButton>;
  40680. /** Observable raised when a pad is pressed */
  40681. onPadDownObservable: Observable<DualShockDpad>;
  40682. /** Observable raised when a pad is released */
  40683. onPadUpObservable: Observable<DualShockDpad>;
  40684. private _buttonCross;
  40685. private _buttonCircle;
  40686. private _buttonSquare;
  40687. private _buttonTriangle;
  40688. private _buttonShare;
  40689. private _buttonOptions;
  40690. private _buttonL1;
  40691. private _buttonR1;
  40692. private _buttonLeftStick;
  40693. private _buttonRightStick;
  40694. private _dPadUp;
  40695. private _dPadDown;
  40696. private _dPadLeft;
  40697. private _dPadRight;
  40698. /**
  40699. * Creates a new DualShock gamepad object
  40700. * @param id defines the id of this gamepad
  40701. * @param index defines its index
  40702. * @param gamepad defines the internal HTML gamepad object
  40703. */
  40704. constructor(id: string, index: number, gamepad: any);
  40705. /**
  40706. * Defines the callback to call when left trigger is pressed
  40707. * @param callback defines the callback to use
  40708. */
  40709. onlefttriggerchanged(callback: (value: number) => void): void;
  40710. /**
  40711. * Defines the callback to call when right trigger is pressed
  40712. * @param callback defines the callback to use
  40713. */
  40714. onrighttriggerchanged(callback: (value: number) => void): void;
  40715. /**
  40716. * Gets the left trigger value
  40717. */
  40718. /**
  40719. * Sets the left trigger value
  40720. */
  40721. leftTrigger: number;
  40722. /**
  40723. * Gets the right trigger value
  40724. */
  40725. /**
  40726. * Sets the right trigger value
  40727. */
  40728. rightTrigger: number;
  40729. /**
  40730. * Defines the callback to call when a button is pressed
  40731. * @param callback defines the callback to use
  40732. */
  40733. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40734. /**
  40735. * Defines the callback to call when a button is released
  40736. * @param callback defines the callback to use
  40737. */
  40738. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40739. /**
  40740. * Defines the callback to call when a pad is pressed
  40741. * @param callback defines the callback to use
  40742. */
  40743. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40744. /**
  40745. * Defines the callback to call when a pad is released
  40746. * @param callback defines the callback to use
  40747. */
  40748. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40749. private _setButtonValue;
  40750. private _setDPadValue;
  40751. /**
  40752. * Gets the value of the `Cross` button
  40753. */
  40754. /**
  40755. * Sets the value of the `Cross` button
  40756. */
  40757. buttonCross: number;
  40758. /**
  40759. * Gets the value of the `Circle` button
  40760. */
  40761. /**
  40762. * Sets the value of the `Circle` button
  40763. */
  40764. buttonCircle: number;
  40765. /**
  40766. * Gets the value of the `Square` button
  40767. */
  40768. /**
  40769. * Sets the value of the `Square` button
  40770. */
  40771. buttonSquare: number;
  40772. /**
  40773. * Gets the value of the `Triangle` button
  40774. */
  40775. /**
  40776. * Sets the value of the `Triangle` button
  40777. */
  40778. buttonTriangle: number;
  40779. /**
  40780. * Gets the value of the `Options` button
  40781. */
  40782. /**
  40783. * Sets the value of the `Options` button
  40784. */
  40785. buttonOptions: number;
  40786. /**
  40787. * Gets the value of the `Share` button
  40788. */
  40789. /**
  40790. * Sets the value of the `Share` button
  40791. */
  40792. buttonShare: number;
  40793. /**
  40794. * Gets the value of the `L1` button
  40795. */
  40796. /**
  40797. * Sets the value of the `L1` button
  40798. */
  40799. buttonL1: number;
  40800. /**
  40801. * Gets the value of the `R1` button
  40802. */
  40803. /**
  40804. * Sets the value of the `R1` button
  40805. */
  40806. buttonR1: number;
  40807. /**
  40808. * Gets the value of the Left joystick
  40809. */
  40810. /**
  40811. * Sets the value of the Left joystick
  40812. */
  40813. buttonLeftStick: number;
  40814. /**
  40815. * Gets the value of the Right joystick
  40816. */
  40817. /**
  40818. * Sets the value of the Right joystick
  40819. */
  40820. buttonRightStick: number;
  40821. /**
  40822. * Gets the value of D-pad up
  40823. */
  40824. /**
  40825. * Sets the value of D-pad up
  40826. */
  40827. dPadUp: number;
  40828. /**
  40829. * Gets the value of D-pad down
  40830. */
  40831. /**
  40832. * Sets the value of D-pad down
  40833. */
  40834. dPadDown: number;
  40835. /**
  40836. * Gets the value of D-pad left
  40837. */
  40838. /**
  40839. * Sets the value of D-pad left
  40840. */
  40841. dPadLeft: number;
  40842. /**
  40843. * Gets the value of D-pad right
  40844. */
  40845. /**
  40846. * Sets the value of D-pad right
  40847. */
  40848. dPadRight: number;
  40849. /**
  40850. * Force the gamepad to synchronize with device values
  40851. */
  40852. update(): void;
  40853. /**
  40854. * Disposes the gamepad
  40855. */
  40856. dispose(): void;
  40857. }
  40858. }
  40859. declare module "babylonjs/Gamepads/gamepadManager" {
  40860. import { Observable } from "babylonjs/Misc/observable";
  40861. import { Nullable } from "babylonjs/types";
  40862. import { Scene } from "babylonjs/scene";
  40863. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40864. /**
  40865. * Manager for handling gamepads
  40866. */
  40867. export class GamepadManager {
  40868. private _scene?;
  40869. private _babylonGamepads;
  40870. private _oneGamepadConnected;
  40871. /** @hidden */
  40872. _isMonitoring: boolean;
  40873. private _gamepadEventSupported;
  40874. private _gamepadSupport;
  40875. /**
  40876. * observable to be triggered when the gamepad controller has been connected
  40877. */
  40878. onGamepadConnectedObservable: Observable<Gamepad>;
  40879. /**
  40880. * observable to be triggered when the gamepad controller has been disconnected
  40881. */
  40882. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40883. private _onGamepadConnectedEvent;
  40884. private _onGamepadDisconnectedEvent;
  40885. /**
  40886. * Initializes the gamepad manager
  40887. * @param _scene BabylonJS scene
  40888. */
  40889. constructor(_scene?: Scene | undefined);
  40890. /**
  40891. * The gamepads in the game pad manager
  40892. */
  40893. readonly gamepads: Gamepad[];
  40894. /**
  40895. * Get the gamepad controllers based on type
  40896. * @param type The type of gamepad controller
  40897. * @returns Nullable gamepad
  40898. */
  40899. getGamepadByType(type?: number): Nullable<Gamepad>;
  40900. /**
  40901. * Disposes the gamepad manager
  40902. */
  40903. dispose(): void;
  40904. private _addNewGamepad;
  40905. private _startMonitoringGamepads;
  40906. private _stopMonitoringGamepads;
  40907. /** @hidden */
  40908. _checkGamepadsStatus(): void;
  40909. private _updateGamepadObjects;
  40910. }
  40911. }
  40912. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40913. import { Nullable } from "babylonjs/types";
  40914. import { Scene } from "babylonjs/scene";
  40915. import { ISceneComponent } from "babylonjs/sceneComponent";
  40916. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40917. module "babylonjs/scene" {
  40918. interface Scene {
  40919. /** @hidden */
  40920. _gamepadManager: Nullable<GamepadManager>;
  40921. /**
  40922. * Gets the gamepad manager associated with the scene
  40923. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40924. */
  40925. gamepadManager: GamepadManager;
  40926. }
  40927. }
  40928. module "babylonjs/Cameras/freeCameraInputsManager" {
  40929. /**
  40930. * Interface representing a free camera inputs manager
  40931. */
  40932. interface FreeCameraInputsManager {
  40933. /**
  40934. * Adds gamepad input support to the FreeCameraInputsManager.
  40935. * @returns the FreeCameraInputsManager
  40936. */
  40937. addGamepad(): FreeCameraInputsManager;
  40938. }
  40939. }
  40940. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40941. /**
  40942. * Interface representing an arc rotate camera inputs manager
  40943. */
  40944. interface ArcRotateCameraInputsManager {
  40945. /**
  40946. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40947. * @returns the camera inputs manager
  40948. */
  40949. addGamepad(): ArcRotateCameraInputsManager;
  40950. }
  40951. }
  40952. /**
  40953. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40954. */
  40955. export class GamepadSystemSceneComponent implements ISceneComponent {
  40956. /**
  40957. * The component name helpfull to identify the component in the list of scene components.
  40958. */
  40959. readonly name: string;
  40960. /**
  40961. * The scene the component belongs to.
  40962. */
  40963. scene: Scene;
  40964. /**
  40965. * Creates a new instance of the component for the given scene
  40966. * @param scene Defines the scene to register the component in
  40967. */
  40968. constructor(scene: Scene);
  40969. /**
  40970. * Registers the component in a given scene
  40971. */
  40972. register(): void;
  40973. /**
  40974. * Rebuilds the elements related to this component in case of
  40975. * context lost for instance.
  40976. */
  40977. rebuild(): void;
  40978. /**
  40979. * Disposes the component and the associated ressources
  40980. */
  40981. dispose(): void;
  40982. private _beforeCameraUpdate;
  40983. }
  40984. }
  40985. declare module "babylonjs/Cameras/universalCamera" {
  40986. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40987. import { Scene } from "babylonjs/scene";
  40988. import { Vector3 } from "babylonjs/Maths/math.vector";
  40989. import "babylonjs/Gamepads/gamepadSceneComponent";
  40990. /**
  40991. * 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,
  40992. * which still works and will still be found in many Playgrounds.
  40993. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40994. */
  40995. export class UniversalCamera extends TouchCamera {
  40996. /**
  40997. * Defines the gamepad rotation sensiblity.
  40998. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40999. */
  41000. gamepadAngularSensibility: number;
  41001. /**
  41002. * Defines the gamepad move sensiblity.
  41003. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41004. */
  41005. gamepadMoveSensibility: number;
  41006. /**
  41007. * 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,
  41008. * which still works and will still be found in many Playgrounds.
  41009. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41010. * @param name Define the name of the camera in the scene
  41011. * @param position Define the start position of the camera in the scene
  41012. * @param scene Define the scene the camera belongs to
  41013. */
  41014. constructor(name: string, position: Vector3, scene: Scene);
  41015. /**
  41016. * Gets the current object class name.
  41017. * @return the class name
  41018. */
  41019. getClassName(): string;
  41020. }
  41021. }
  41022. declare module "babylonjs/Cameras/gamepadCamera" {
  41023. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41024. import { Scene } from "babylonjs/scene";
  41025. import { Vector3 } from "babylonjs/Maths/math.vector";
  41026. /**
  41027. * This represents a FPS type of camera. This is only here for back compat purpose.
  41028. * Please use the UniversalCamera instead as both are identical.
  41029. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41030. */
  41031. export class GamepadCamera extends UniversalCamera {
  41032. /**
  41033. * Instantiates a new Gamepad Camera
  41034. * This represents a FPS type of camera. This is only here for back compat purpose.
  41035. * Please use the UniversalCamera instead as both are identical.
  41036. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41037. * @param name Define the name of the camera in the scene
  41038. * @param position Define the start position of the camera in the scene
  41039. * @param scene Define the scene the camera belongs to
  41040. */
  41041. constructor(name: string, position: Vector3, scene: Scene);
  41042. /**
  41043. * Gets the current object class name.
  41044. * @return the class name
  41045. */
  41046. getClassName(): string;
  41047. }
  41048. }
  41049. declare module "babylonjs/Shaders/pass.fragment" {
  41050. /** @hidden */
  41051. export var passPixelShader: {
  41052. name: string;
  41053. shader: string;
  41054. };
  41055. }
  41056. declare module "babylonjs/Shaders/passCube.fragment" {
  41057. /** @hidden */
  41058. export var passCubePixelShader: {
  41059. name: string;
  41060. shader: string;
  41061. };
  41062. }
  41063. declare module "babylonjs/PostProcesses/passPostProcess" {
  41064. import { Nullable } from "babylonjs/types";
  41065. import { Camera } from "babylonjs/Cameras/camera";
  41066. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41067. import { Engine } from "babylonjs/Engines/engine";
  41068. import "babylonjs/Shaders/pass.fragment";
  41069. import "babylonjs/Shaders/passCube.fragment";
  41070. /**
  41071. * PassPostProcess which produces an output the same as it's input
  41072. */
  41073. export class PassPostProcess extends PostProcess {
  41074. /**
  41075. * Creates the PassPostProcess
  41076. * @param name The name of the effect.
  41077. * @param options The required width/height ratio to downsize to before computing the render pass.
  41078. * @param camera The camera to apply the render pass to.
  41079. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41080. * @param engine The engine which the post process will be applied. (default: current engine)
  41081. * @param reusable If the post process can be reused on the same frame. (default: false)
  41082. * @param textureType The type of texture to be used when performing the post processing.
  41083. * @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)
  41084. */
  41085. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41086. }
  41087. /**
  41088. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41089. */
  41090. export class PassCubePostProcess extends PostProcess {
  41091. private _face;
  41092. /**
  41093. * Gets or sets the cube face to display.
  41094. * * 0 is +X
  41095. * * 1 is -X
  41096. * * 2 is +Y
  41097. * * 3 is -Y
  41098. * * 4 is +Z
  41099. * * 5 is -Z
  41100. */
  41101. face: number;
  41102. /**
  41103. * Creates the PassCubePostProcess
  41104. * @param name The name of the effect.
  41105. * @param options The required width/height ratio to downsize to before computing the render pass.
  41106. * @param camera The camera to apply the render pass to.
  41107. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41108. * @param engine The engine which the post process will be applied. (default: current engine)
  41109. * @param reusable If the post process can be reused on the same frame. (default: false)
  41110. * @param textureType The type of texture to be used when performing the post processing.
  41111. * @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)
  41112. */
  41113. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41114. }
  41115. }
  41116. declare module "babylonjs/Shaders/anaglyph.fragment" {
  41117. /** @hidden */
  41118. export var anaglyphPixelShader: {
  41119. name: string;
  41120. shader: string;
  41121. };
  41122. }
  41123. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  41124. import { Engine } from "babylonjs/Engines/engine";
  41125. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41126. import { Camera } from "babylonjs/Cameras/camera";
  41127. import "babylonjs/Shaders/anaglyph.fragment";
  41128. /**
  41129. * Postprocess used to generate anaglyphic rendering
  41130. */
  41131. export class AnaglyphPostProcess extends PostProcess {
  41132. private _passedProcess;
  41133. /**
  41134. * Creates a new AnaglyphPostProcess
  41135. * @param name defines postprocess name
  41136. * @param options defines creation options or target ratio scale
  41137. * @param rigCameras defines cameras using this postprocess
  41138. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41139. * @param engine defines hosting engine
  41140. * @param reusable defines if the postprocess will be reused multiple times per frame
  41141. */
  41142. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41143. }
  41144. }
  41145. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  41146. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  41147. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41148. import { Scene } from "babylonjs/scene";
  41149. import { Vector3 } from "babylonjs/Maths/math.vector";
  41150. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41151. /**
  41152. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41153. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41154. */
  41155. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41156. /**
  41157. * Creates a new AnaglyphArcRotateCamera
  41158. * @param name defines camera name
  41159. * @param alpha defines alpha angle (in radians)
  41160. * @param beta defines beta angle (in radians)
  41161. * @param radius defines radius
  41162. * @param target defines camera target
  41163. * @param interaxialDistance defines distance between each color axis
  41164. * @param scene defines the hosting scene
  41165. */
  41166. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41167. /**
  41168. * Gets camera class name
  41169. * @returns AnaglyphArcRotateCamera
  41170. */
  41171. getClassName(): string;
  41172. }
  41173. }
  41174. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  41175. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41176. import { Scene } from "babylonjs/scene";
  41177. import { Vector3 } from "babylonjs/Maths/math.vector";
  41178. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41179. /**
  41180. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41181. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41182. */
  41183. export class AnaglyphFreeCamera extends FreeCamera {
  41184. /**
  41185. * Creates a new AnaglyphFreeCamera
  41186. * @param name defines camera name
  41187. * @param position defines initial position
  41188. * @param interaxialDistance defines distance between each color axis
  41189. * @param scene defines the hosting scene
  41190. */
  41191. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41192. /**
  41193. * Gets camera class name
  41194. * @returns AnaglyphFreeCamera
  41195. */
  41196. getClassName(): string;
  41197. }
  41198. }
  41199. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  41200. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41201. import { Scene } from "babylonjs/scene";
  41202. import { Vector3 } from "babylonjs/Maths/math.vector";
  41203. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41204. /**
  41205. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41206. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41207. */
  41208. export class AnaglyphGamepadCamera extends GamepadCamera {
  41209. /**
  41210. * Creates a new AnaglyphGamepadCamera
  41211. * @param name defines camera name
  41212. * @param position defines initial position
  41213. * @param interaxialDistance defines distance between each color axis
  41214. * @param scene defines the hosting scene
  41215. */
  41216. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41217. /**
  41218. * Gets camera class name
  41219. * @returns AnaglyphGamepadCamera
  41220. */
  41221. getClassName(): string;
  41222. }
  41223. }
  41224. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  41225. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41226. import { Scene } from "babylonjs/scene";
  41227. import { Vector3 } from "babylonjs/Maths/math.vector";
  41228. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41229. /**
  41230. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41231. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41232. */
  41233. export class AnaglyphUniversalCamera extends UniversalCamera {
  41234. /**
  41235. * Creates a new AnaglyphUniversalCamera
  41236. * @param name defines camera name
  41237. * @param position defines initial position
  41238. * @param interaxialDistance defines distance between each color axis
  41239. * @param scene defines the hosting scene
  41240. */
  41241. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41242. /**
  41243. * Gets camera class name
  41244. * @returns AnaglyphUniversalCamera
  41245. */
  41246. getClassName(): string;
  41247. }
  41248. }
  41249. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  41250. /** @hidden */
  41251. export var stereoscopicInterlacePixelShader: {
  41252. name: string;
  41253. shader: string;
  41254. };
  41255. }
  41256. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  41257. import { Camera } from "babylonjs/Cameras/camera";
  41258. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41259. import { Engine } from "babylonjs/Engines/engine";
  41260. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  41261. /**
  41262. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41263. */
  41264. export class StereoscopicInterlacePostProcess extends PostProcess {
  41265. private _stepSize;
  41266. private _passedProcess;
  41267. /**
  41268. * Initializes a StereoscopicInterlacePostProcess
  41269. * @param name The name of the effect.
  41270. * @param rigCameras The rig cameras to be appled to the post process
  41271. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41273. * @param engine The engine which the post process will be applied. (default: current engine)
  41274. * @param reusable If the post process can be reused on the same frame. (default: false)
  41275. */
  41276. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41277. }
  41278. }
  41279. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  41280. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  41281. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41282. import { Scene } from "babylonjs/scene";
  41283. import { Vector3 } from "babylonjs/Maths/math.vector";
  41284. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41285. /**
  41286. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41287. * @see http://doc.babylonjs.com/features/cameras
  41288. */
  41289. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41290. /**
  41291. * Creates a new StereoscopicArcRotateCamera
  41292. * @param name defines camera name
  41293. * @param alpha defines alpha angle (in radians)
  41294. * @param beta defines beta angle (in radians)
  41295. * @param radius defines radius
  41296. * @param target defines camera target
  41297. * @param interaxialDistance defines distance between each color axis
  41298. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41299. * @param scene defines the hosting scene
  41300. */
  41301. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41302. /**
  41303. * Gets camera class name
  41304. * @returns StereoscopicArcRotateCamera
  41305. */
  41306. getClassName(): string;
  41307. }
  41308. }
  41309. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  41310. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41311. import { Scene } from "babylonjs/scene";
  41312. import { Vector3 } from "babylonjs/Maths/math.vector";
  41313. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41314. /**
  41315. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41316. * @see http://doc.babylonjs.com/features/cameras
  41317. */
  41318. export class StereoscopicFreeCamera extends FreeCamera {
  41319. /**
  41320. * Creates a new StereoscopicFreeCamera
  41321. * @param name defines camera name
  41322. * @param position defines initial position
  41323. * @param interaxialDistance defines distance between each color axis
  41324. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41325. * @param scene defines the hosting scene
  41326. */
  41327. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41328. /**
  41329. * Gets camera class name
  41330. * @returns StereoscopicFreeCamera
  41331. */
  41332. getClassName(): string;
  41333. }
  41334. }
  41335. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  41336. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41337. import { Scene } from "babylonjs/scene";
  41338. import { Vector3 } from "babylonjs/Maths/math.vector";
  41339. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41340. /**
  41341. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41342. * @see http://doc.babylonjs.com/features/cameras
  41343. */
  41344. export class StereoscopicGamepadCamera extends GamepadCamera {
  41345. /**
  41346. * Creates a new StereoscopicGamepadCamera
  41347. * @param name defines camera name
  41348. * @param position defines initial position
  41349. * @param interaxialDistance defines distance between each color axis
  41350. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41351. * @param scene defines the hosting scene
  41352. */
  41353. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41354. /**
  41355. * Gets camera class name
  41356. * @returns StereoscopicGamepadCamera
  41357. */
  41358. getClassName(): string;
  41359. }
  41360. }
  41361. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  41362. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41363. import { Scene } from "babylonjs/scene";
  41364. import { Vector3 } from "babylonjs/Maths/math.vector";
  41365. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41366. /**
  41367. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41368. * @see http://doc.babylonjs.com/features/cameras
  41369. */
  41370. export class StereoscopicUniversalCamera extends UniversalCamera {
  41371. /**
  41372. * Creates a new StereoscopicUniversalCamera
  41373. * @param name defines camera name
  41374. * @param position defines initial position
  41375. * @param interaxialDistance defines distance between each color axis
  41376. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41377. * @param scene defines the hosting scene
  41378. */
  41379. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41380. /**
  41381. * Gets camera class name
  41382. * @returns StereoscopicUniversalCamera
  41383. */
  41384. getClassName(): string;
  41385. }
  41386. }
  41387. declare module "babylonjs/Cameras/Stereoscopic/index" {
  41388. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  41389. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  41390. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  41391. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  41392. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  41393. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  41394. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  41395. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  41396. }
  41397. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  41398. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41399. import { Scene } from "babylonjs/scene";
  41400. import { Vector3 } from "babylonjs/Maths/math.vector";
  41401. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41402. /**
  41403. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41404. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41405. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41406. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41407. */
  41408. export class VirtualJoysticksCamera extends FreeCamera {
  41409. /**
  41410. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41411. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41412. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41413. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41414. * @param name Define the name of the camera in the scene
  41415. * @param position Define the start position of the camera in the scene
  41416. * @param scene Define the scene the camera belongs to
  41417. */
  41418. constructor(name: string, position: Vector3, scene: Scene);
  41419. /**
  41420. * Gets the current object class name.
  41421. * @return the class name
  41422. */
  41423. getClassName(): string;
  41424. }
  41425. }
  41426. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  41427. import { Matrix } from "babylonjs/Maths/math.vector";
  41428. /**
  41429. * This represents all the required metrics to create a VR camera.
  41430. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41431. */
  41432. export class VRCameraMetrics {
  41433. /**
  41434. * Define the horizontal resolution off the screen.
  41435. */
  41436. hResolution: number;
  41437. /**
  41438. * Define the vertical resolution off the screen.
  41439. */
  41440. vResolution: number;
  41441. /**
  41442. * Define the horizontal screen size.
  41443. */
  41444. hScreenSize: number;
  41445. /**
  41446. * Define the vertical screen size.
  41447. */
  41448. vScreenSize: number;
  41449. /**
  41450. * Define the vertical screen center position.
  41451. */
  41452. vScreenCenter: number;
  41453. /**
  41454. * Define the distance of the eyes to the screen.
  41455. */
  41456. eyeToScreenDistance: number;
  41457. /**
  41458. * Define the distance between both lenses
  41459. */
  41460. lensSeparationDistance: number;
  41461. /**
  41462. * Define the distance between both viewer's eyes.
  41463. */
  41464. interpupillaryDistance: number;
  41465. /**
  41466. * Define the distortion factor of the VR postprocess.
  41467. * Please, touch with care.
  41468. */
  41469. distortionK: number[];
  41470. /**
  41471. * Define the chromatic aberration correction factors for the VR post process.
  41472. */
  41473. chromaAbCorrection: number[];
  41474. /**
  41475. * Define the scale factor of the post process.
  41476. * The smaller the better but the slower.
  41477. */
  41478. postProcessScaleFactor: number;
  41479. /**
  41480. * Define an offset for the lens center.
  41481. */
  41482. lensCenterOffset: number;
  41483. /**
  41484. * Define if the current vr camera should compensate the distortion of the lense or not.
  41485. */
  41486. compensateDistortion: boolean;
  41487. /**
  41488. * Defines if multiview should be enabled when rendering (Default: false)
  41489. */
  41490. multiviewEnabled: boolean;
  41491. /**
  41492. * Gets the rendering aspect ratio based on the provided resolutions.
  41493. */
  41494. readonly aspectRatio: number;
  41495. /**
  41496. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41497. */
  41498. readonly aspectRatioFov: number;
  41499. /**
  41500. * @hidden
  41501. */
  41502. readonly leftHMatrix: Matrix;
  41503. /**
  41504. * @hidden
  41505. */
  41506. readonly rightHMatrix: Matrix;
  41507. /**
  41508. * @hidden
  41509. */
  41510. readonly leftPreViewMatrix: Matrix;
  41511. /**
  41512. * @hidden
  41513. */
  41514. readonly rightPreViewMatrix: Matrix;
  41515. /**
  41516. * Get the default VRMetrics based on the most generic setup.
  41517. * @returns the default vr metrics
  41518. */
  41519. static GetDefault(): VRCameraMetrics;
  41520. }
  41521. }
  41522. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41523. /** @hidden */
  41524. export var vrDistortionCorrectionPixelShader: {
  41525. name: string;
  41526. shader: string;
  41527. };
  41528. }
  41529. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41530. import { Camera } from "babylonjs/Cameras/camera";
  41531. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41532. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41533. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41534. /**
  41535. * VRDistortionCorrectionPostProcess used for mobile VR
  41536. */
  41537. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41538. private _isRightEye;
  41539. private _distortionFactors;
  41540. private _postProcessScaleFactor;
  41541. private _lensCenterOffset;
  41542. private _scaleIn;
  41543. private _scaleFactor;
  41544. private _lensCenter;
  41545. /**
  41546. * Initializes the VRDistortionCorrectionPostProcess
  41547. * @param name The name of the effect.
  41548. * @param camera The camera to apply the render pass to.
  41549. * @param isRightEye If this is for the right eye distortion
  41550. * @param vrMetrics All the required metrics for the VR camera
  41551. */
  41552. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41553. }
  41554. }
  41555. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41556. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41557. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41558. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41559. import { Scene } from "babylonjs/scene";
  41560. import { Vector3 } from "babylonjs/Maths/math.vector";
  41561. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41562. import "babylonjs/Cameras/RigModes/vrRigMode";
  41563. /**
  41564. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41565. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41566. */
  41567. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41568. /**
  41569. * Creates a new VRDeviceOrientationArcRotateCamera
  41570. * @param name defines camera name
  41571. * @param alpha defines the camera rotation along the logitudinal axis
  41572. * @param beta defines the camera rotation along the latitudinal axis
  41573. * @param radius defines the camera distance from its target
  41574. * @param target defines the camera target
  41575. * @param scene defines the scene the camera belongs to
  41576. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41577. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41578. */
  41579. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41580. /**
  41581. * Gets camera class name
  41582. * @returns VRDeviceOrientationArcRotateCamera
  41583. */
  41584. getClassName(): string;
  41585. }
  41586. }
  41587. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41588. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41589. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41590. import { Scene } from "babylonjs/scene";
  41591. import { Vector3 } from "babylonjs/Maths/math.vector";
  41592. import "babylonjs/Cameras/RigModes/vrRigMode";
  41593. /**
  41594. * Camera used to simulate VR rendering (based on FreeCamera)
  41595. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41596. */
  41597. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41598. /**
  41599. * Creates a new VRDeviceOrientationFreeCamera
  41600. * @param name defines camera name
  41601. * @param position defines the start position of the camera
  41602. * @param scene defines the scene the camera belongs to
  41603. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41604. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41605. */
  41606. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41607. /**
  41608. * Gets camera class name
  41609. * @returns VRDeviceOrientationFreeCamera
  41610. */
  41611. getClassName(): string;
  41612. }
  41613. }
  41614. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41615. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41616. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41617. import { Scene } from "babylonjs/scene";
  41618. import { Vector3 } from "babylonjs/Maths/math.vector";
  41619. import "babylonjs/Gamepads/gamepadSceneComponent";
  41620. /**
  41621. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41622. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41623. */
  41624. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41625. /**
  41626. * Creates a new VRDeviceOrientationGamepadCamera
  41627. * @param name defines camera name
  41628. * @param position defines the start position of the camera
  41629. * @param scene defines the scene the camera belongs to
  41630. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41631. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41632. */
  41633. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41634. /**
  41635. * Gets camera class name
  41636. * @returns VRDeviceOrientationGamepadCamera
  41637. */
  41638. getClassName(): string;
  41639. }
  41640. }
  41641. declare module "babylonjs/Materials/pushMaterial" {
  41642. import { Nullable } from "babylonjs/types";
  41643. import { Scene } from "babylonjs/scene";
  41644. import { Matrix } from "babylonjs/Maths/math.vector";
  41645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41646. import { Mesh } from "babylonjs/Meshes/mesh";
  41647. import { Material } from "babylonjs/Materials/material";
  41648. import { Effect } from "babylonjs/Materials/effect";
  41649. /**
  41650. * Base class of materials working in push mode in babylon JS
  41651. * @hidden
  41652. */
  41653. export class PushMaterial extends Material {
  41654. protected _activeEffect: Effect;
  41655. protected _normalMatrix: Matrix;
  41656. /**
  41657. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41658. * This means that the material can keep using a previous shader while a new one is being compiled.
  41659. * This is mostly used when shader parallel compilation is supported (true by default)
  41660. */
  41661. allowShaderHotSwapping: boolean;
  41662. constructor(name: string, scene: Scene);
  41663. getEffect(): Effect;
  41664. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41665. /**
  41666. * Binds the given world matrix to the active effect
  41667. *
  41668. * @param world the matrix to bind
  41669. */
  41670. bindOnlyWorldMatrix(world: Matrix): void;
  41671. /**
  41672. * Binds the given normal matrix to the active effect
  41673. *
  41674. * @param normalMatrix the matrix to bind
  41675. */
  41676. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41677. bind(world: Matrix, mesh?: Mesh): void;
  41678. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41679. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41680. }
  41681. }
  41682. declare module "babylonjs/Materials/materialFlags" {
  41683. /**
  41684. * This groups all the flags used to control the materials channel.
  41685. */
  41686. export class MaterialFlags {
  41687. private static _DiffuseTextureEnabled;
  41688. /**
  41689. * Are diffuse textures enabled in the application.
  41690. */
  41691. static DiffuseTextureEnabled: boolean;
  41692. private static _AmbientTextureEnabled;
  41693. /**
  41694. * Are ambient textures enabled in the application.
  41695. */
  41696. static AmbientTextureEnabled: boolean;
  41697. private static _OpacityTextureEnabled;
  41698. /**
  41699. * Are opacity textures enabled in the application.
  41700. */
  41701. static OpacityTextureEnabled: boolean;
  41702. private static _ReflectionTextureEnabled;
  41703. /**
  41704. * Are reflection textures enabled in the application.
  41705. */
  41706. static ReflectionTextureEnabled: boolean;
  41707. private static _EmissiveTextureEnabled;
  41708. /**
  41709. * Are emissive textures enabled in the application.
  41710. */
  41711. static EmissiveTextureEnabled: boolean;
  41712. private static _SpecularTextureEnabled;
  41713. /**
  41714. * Are specular textures enabled in the application.
  41715. */
  41716. static SpecularTextureEnabled: boolean;
  41717. private static _BumpTextureEnabled;
  41718. /**
  41719. * Are bump textures enabled in the application.
  41720. */
  41721. static BumpTextureEnabled: boolean;
  41722. private static _LightmapTextureEnabled;
  41723. /**
  41724. * Are lightmap textures enabled in the application.
  41725. */
  41726. static LightmapTextureEnabled: boolean;
  41727. private static _RefractionTextureEnabled;
  41728. /**
  41729. * Are refraction textures enabled in the application.
  41730. */
  41731. static RefractionTextureEnabled: boolean;
  41732. private static _ColorGradingTextureEnabled;
  41733. /**
  41734. * Are color grading textures enabled in the application.
  41735. */
  41736. static ColorGradingTextureEnabled: boolean;
  41737. private static _FresnelEnabled;
  41738. /**
  41739. * Are fresnels enabled in the application.
  41740. */
  41741. static FresnelEnabled: boolean;
  41742. private static _ClearCoatTextureEnabled;
  41743. /**
  41744. * Are clear coat textures enabled in the application.
  41745. */
  41746. static ClearCoatTextureEnabled: boolean;
  41747. private static _ClearCoatBumpTextureEnabled;
  41748. /**
  41749. * Are clear coat bump textures enabled in the application.
  41750. */
  41751. static ClearCoatBumpTextureEnabled: boolean;
  41752. private static _ClearCoatTintTextureEnabled;
  41753. /**
  41754. * Are clear coat tint textures enabled in the application.
  41755. */
  41756. static ClearCoatTintTextureEnabled: boolean;
  41757. private static _SheenTextureEnabled;
  41758. /**
  41759. * Are sheen textures enabled in the application.
  41760. */
  41761. static SheenTextureEnabled: boolean;
  41762. private static _AnisotropicTextureEnabled;
  41763. /**
  41764. * Are anisotropic textures enabled in the application.
  41765. */
  41766. static AnisotropicTextureEnabled: boolean;
  41767. private static _ThicknessTextureEnabled;
  41768. /**
  41769. * Are thickness textures enabled in the application.
  41770. */
  41771. static ThicknessTextureEnabled: boolean;
  41772. }
  41773. }
  41774. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41775. /** @hidden */
  41776. export var defaultFragmentDeclaration: {
  41777. name: string;
  41778. shader: string;
  41779. };
  41780. }
  41781. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41782. /** @hidden */
  41783. export var defaultUboDeclaration: {
  41784. name: string;
  41785. shader: string;
  41786. };
  41787. }
  41788. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41789. /** @hidden */
  41790. export var lightFragmentDeclaration: {
  41791. name: string;
  41792. shader: string;
  41793. };
  41794. }
  41795. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41796. /** @hidden */
  41797. export var lightUboDeclaration: {
  41798. name: string;
  41799. shader: string;
  41800. };
  41801. }
  41802. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41803. /** @hidden */
  41804. export var lightsFragmentFunctions: {
  41805. name: string;
  41806. shader: string;
  41807. };
  41808. }
  41809. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41810. /** @hidden */
  41811. export var shadowsFragmentFunctions: {
  41812. name: string;
  41813. shader: string;
  41814. };
  41815. }
  41816. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41817. /** @hidden */
  41818. export var fresnelFunction: {
  41819. name: string;
  41820. shader: string;
  41821. };
  41822. }
  41823. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41824. /** @hidden */
  41825. export var reflectionFunction: {
  41826. name: string;
  41827. shader: string;
  41828. };
  41829. }
  41830. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41831. /** @hidden */
  41832. export var bumpFragmentFunctions: {
  41833. name: string;
  41834. shader: string;
  41835. };
  41836. }
  41837. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41838. /** @hidden */
  41839. export var logDepthDeclaration: {
  41840. name: string;
  41841. shader: string;
  41842. };
  41843. }
  41844. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41845. /** @hidden */
  41846. export var bumpFragment: {
  41847. name: string;
  41848. shader: string;
  41849. };
  41850. }
  41851. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41852. /** @hidden */
  41853. export var depthPrePass: {
  41854. name: string;
  41855. shader: string;
  41856. };
  41857. }
  41858. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41859. /** @hidden */
  41860. export var lightFragment: {
  41861. name: string;
  41862. shader: string;
  41863. };
  41864. }
  41865. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41866. /** @hidden */
  41867. export var logDepthFragment: {
  41868. name: string;
  41869. shader: string;
  41870. };
  41871. }
  41872. declare module "babylonjs/Shaders/default.fragment" {
  41873. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41874. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41875. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41876. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41877. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41878. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41879. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41880. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41881. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41882. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41883. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41884. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41885. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41886. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41887. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41888. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41889. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41890. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41891. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41892. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41893. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41894. /** @hidden */
  41895. export var defaultPixelShader: {
  41896. name: string;
  41897. shader: string;
  41898. };
  41899. }
  41900. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41901. /** @hidden */
  41902. export var defaultVertexDeclaration: {
  41903. name: string;
  41904. shader: string;
  41905. };
  41906. }
  41907. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41908. /** @hidden */
  41909. export var bumpVertexDeclaration: {
  41910. name: string;
  41911. shader: string;
  41912. };
  41913. }
  41914. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41915. /** @hidden */
  41916. export var bumpVertex: {
  41917. name: string;
  41918. shader: string;
  41919. };
  41920. }
  41921. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41922. /** @hidden */
  41923. export var fogVertex: {
  41924. name: string;
  41925. shader: string;
  41926. };
  41927. }
  41928. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41929. /** @hidden */
  41930. export var shadowsVertex: {
  41931. name: string;
  41932. shader: string;
  41933. };
  41934. }
  41935. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41936. /** @hidden */
  41937. export var pointCloudVertex: {
  41938. name: string;
  41939. shader: string;
  41940. };
  41941. }
  41942. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41943. /** @hidden */
  41944. export var logDepthVertex: {
  41945. name: string;
  41946. shader: string;
  41947. };
  41948. }
  41949. declare module "babylonjs/Shaders/default.vertex" {
  41950. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41951. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41952. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41953. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41954. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41955. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41956. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41957. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41958. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41959. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41960. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41961. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41962. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41963. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41964. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41965. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41966. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41967. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41968. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41969. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41970. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41971. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41972. /** @hidden */
  41973. export var defaultVertexShader: {
  41974. name: string;
  41975. shader: string;
  41976. };
  41977. }
  41978. declare module "babylonjs/Materials/standardMaterial" {
  41979. import { SmartArray } from "babylonjs/Misc/smartArray";
  41980. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41981. import { Nullable } from "babylonjs/types";
  41982. import { Scene } from "babylonjs/scene";
  41983. import { Matrix } from "babylonjs/Maths/math.vector";
  41984. import { Color3 } from "babylonjs/Maths/math.color";
  41985. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41987. import { Mesh } from "babylonjs/Meshes/mesh";
  41988. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41989. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41990. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41991. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41992. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41993. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41994. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41995. import "babylonjs/Shaders/default.fragment";
  41996. import "babylonjs/Shaders/default.vertex";
  41997. /** @hidden */
  41998. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41999. MAINUV1: boolean;
  42000. MAINUV2: boolean;
  42001. DIFFUSE: boolean;
  42002. DIFFUSEDIRECTUV: number;
  42003. AMBIENT: boolean;
  42004. AMBIENTDIRECTUV: number;
  42005. OPACITY: boolean;
  42006. OPACITYDIRECTUV: number;
  42007. OPACITYRGB: boolean;
  42008. REFLECTION: boolean;
  42009. EMISSIVE: boolean;
  42010. EMISSIVEDIRECTUV: number;
  42011. SPECULAR: boolean;
  42012. SPECULARDIRECTUV: number;
  42013. BUMP: boolean;
  42014. BUMPDIRECTUV: number;
  42015. PARALLAX: boolean;
  42016. PARALLAXOCCLUSION: boolean;
  42017. SPECULAROVERALPHA: boolean;
  42018. CLIPPLANE: boolean;
  42019. CLIPPLANE2: boolean;
  42020. CLIPPLANE3: boolean;
  42021. CLIPPLANE4: boolean;
  42022. ALPHATEST: boolean;
  42023. DEPTHPREPASS: boolean;
  42024. ALPHAFROMDIFFUSE: boolean;
  42025. POINTSIZE: boolean;
  42026. FOG: boolean;
  42027. SPECULARTERM: boolean;
  42028. DIFFUSEFRESNEL: boolean;
  42029. OPACITYFRESNEL: boolean;
  42030. REFLECTIONFRESNEL: boolean;
  42031. REFRACTIONFRESNEL: boolean;
  42032. EMISSIVEFRESNEL: boolean;
  42033. FRESNEL: boolean;
  42034. NORMAL: boolean;
  42035. UV1: boolean;
  42036. UV2: boolean;
  42037. VERTEXCOLOR: boolean;
  42038. VERTEXALPHA: boolean;
  42039. NUM_BONE_INFLUENCERS: number;
  42040. BonesPerMesh: number;
  42041. BONETEXTURE: boolean;
  42042. INSTANCES: boolean;
  42043. GLOSSINESS: boolean;
  42044. ROUGHNESS: boolean;
  42045. EMISSIVEASILLUMINATION: boolean;
  42046. LINKEMISSIVEWITHDIFFUSE: boolean;
  42047. REFLECTIONFRESNELFROMSPECULAR: boolean;
  42048. LIGHTMAP: boolean;
  42049. LIGHTMAPDIRECTUV: number;
  42050. OBJECTSPACE_NORMALMAP: boolean;
  42051. USELIGHTMAPASSHADOWMAP: boolean;
  42052. REFLECTIONMAP_3D: boolean;
  42053. REFLECTIONMAP_SPHERICAL: boolean;
  42054. REFLECTIONMAP_PLANAR: boolean;
  42055. REFLECTIONMAP_CUBIC: boolean;
  42056. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  42057. REFLECTIONMAP_PROJECTION: boolean;
  42058. REFLECTIONMAP_SKYBOX: boolean;
  42059. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  42060. REFLECTIONMAP_EXPLICIT: boolean;
  42061. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  42062. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  42063. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  42064. INVERTCUBICMAP: boolean;
  42065. LOGARITHMICDEPTH: boolean;
  42066. REFRACTION: boolean;
  42067. REFRACTIONMAP_3D: boolean;
  42068. REFLECTIONOVERALPHA: boolean;
  42069. TWOSIDEDLIGHTING: boolean;
  42070. SHADOWFLOAT: boolean;
  42071. MORPHTARGETS: boolean;
  42072. MORPHTARGETS_NORMAL: boolean;
  42073. MORPHTARGETS_TANGENT: boolean;
  42074. MORPHTARGETS_UV: boolean;
  42075. NUM_MORPH_INFLUENCERS: number;
  42076. NONUNIFORMSCALING: boolean;
  42077. PREMULTIPLYALPHA: boolean;
  42078. IMAGEPROCESSING: boolean;
  42079. VIGNETTE: boolean;
  42080. VIGNETTEBLENDMODEMULTIPLY: boolean;
  42081. VIGNETTEBLENDMODEOPAQUE: boolean;
  42082. TONEMAPPING: boolean;
  42083. TONEMAPPING_ACES: boolean;
  42084. CONTRAST: boolean;
  42085. COLORCURVES: boolean;
  42086. COLORGRADING: boolean;
  42087. COLORGRADING3D: boolean;
  42088. SAMPLER3DGREENDEPTH: boolean;
  42089. SAMPLER3DBGRMAP: boolean;
  42090. IMAGEPROCESSINGPOSTPROCESS: boolean;
  42091. MULTIVIEW: boolean;
  42092. /**
  42093. * If the reflection texture on this material is in linear color space
  42094. * @hidden
  42095. */
  42096. IS_REFLECTION_LINEAR: boolean;
  42097. /**
  42098. * If the refraction texture on this material is in linear color space
  42099. * @hidden
  42100. */
  42101. IS_REFRACTION_LINEAR: boolean;
  42102. EXPOSURE: boolean;
  42103. constructor();
  42104. setReflectionMode(modeToEnable: string): void;
  42105. }
  42106. /**
  42107. * This is the default material used in Babylon. It is the best trade off between quality
  42108. * and performances.
  42109. * @see http://doc.babylonjs.com/babylon101/materials
  42110. */
  42111. export class StandardMaterial extends PushMaterial {
  42112. private _diffuseTexture;
  42113. /**
  42114. * The basic texture of the material as viewed under a light.
  42115. */
  42116. diffuseTexture: Nullable<BaseTexture>;
  42117. private _ambientTexture;
  42118. /**
  42119. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  42120. */
  42121. ambientTexture: Nullable<BaseTexture>;
  42122. private _opacityTexture;
  42123. /**
  42124. * Define the transparency of the material from a texture.
  42125. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  42126. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  42127. */
  42128. opacityTexture: Nullable<BaseTexture>;
  42129. private _reflectionTexture;
  42130. /**
  42131. * Define the texture used to display the reflection.
  42132. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42133. */
  42134. reflectionTexture: Nullable<BaseTexture>;
  42135. private _emissiveTexture;
  42136. /**
  42137. * Define texture of the material as if self lit.
  42138. * This will be mixed in the final result even in the absence of light.
  42139. */
  42140. emissiveTexture: Nullable<BaseTexture>;
  42141. private _specularTexture;
  42142. /**
  42143. * Define how the color and intensity of the highlight given by the light in the material.
  42144. */
  42145. specularTexture: Nullable<BaseTexture>;
  42146. private _bumpTexture;
  42147. /**
  42148. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  42149. * 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.
  42150. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  42151. */
  42152. bumpTexture: Nullable<BaseTexture>;
  42153. private _lightmapTexture;
  42154. /**
  42155. * Complex lighting can be computationally expensive to compute at runtime.
  42156. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  42157. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  42158. */
  42159. lightmapTexture: Nullable<BaseTexture>;
  42160. private _refractionTexture;
  42161. /**
  42162. * Define the texture used to display the refraction.
  42163. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42164. */
  42165. refractionTexture: Nullable<BaseTexture>;
  42166. /**
  42167. * The color of the material lit by the environmental background lighting.
  42168. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  42169. */
  42170. ambientColor: Color3;
  42171. /**
  42172. * The basic color of the material as viewed under a light.
  42173. */
  42174. diffuseColor: Color3;
  42175. /**
  42176. * Define how the color and intensity of the highlight given by the light in the material.
  42177. */
  42178. specularColor: Color3;
  42179. /**
  42180. * Define the color of the material as if self lit.
  42181. * This will be mixed in the final result even in the absence of light.
  42182. */
  42183. emissiveColor: Color3;
  42184. /**
  42185. * Defines how sharp are the highlights in the material.
  42186. * The bigger the value the sharper giving a more glossy feeling to the result.
  42187. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  42188. */
  42189. specularPower: number;
  42190. private _useAlphaFromDiffuseTexture;
  42191. /**
  42192. * Does the transparency come from the diffuse texture alpha channel.
  42193. */
  42194. useAlphaFromDiffuseTexture: boolean;
  42195. private _useEmissiveAsIllumination;
  42196. /**
  42197. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  42198. */
  42199. useEmissiveAsIllumination: boolean;
  42200. private _linkEmissiveWithDiffuse;
  42201. /**
  42202. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  42203. * the emissive level when the final color is close to one.
  42204. */
  42205. linkEmissiveWithDiffuse: boolean;
  42206. private _useSpecularOverAlpha;
  42207. /**
  42208. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  42209. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42210. */
  42211. useSpecularOverAlpha: boolean;
  42212. private _useReflectionOverAlpha;
  42213. /**
  42214. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42215. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42216. */
  42217. useReflectionOverAlpha: boolean;
  42218. private _disableLighting;
  42219. /**
  42220. * Does lights from the scene impacts this material.
  42221. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  42222. */
  42223. disableLighting: boolean;
  42224. private _useObjectSpaceNormalMap;
  42225. /**
  42226. * Allows using an object space normal map (instead of tangent space).
  42227. */
  42228. useObjectSpaceNormalMap: boolean;
  42229. private _useParallax;
  42230. /**
  42231. * Is parallax enabled or not.
  42232. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42233. */
  42234. useParallax: boolean;
  42235. private _useParallaxOcclusion;
  42236. /**
  42237. * Is parallax occlusion enabled or not.
  42238. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  42239. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42240. */
  42241. useParallaxOcclusion: boolean;
  42242. /**
  42243. * 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.
  42244. */
  42245. parallaxScaleBias: number;
  42246. private _roughness;
  42247. /**
  42248. * Helps to define how blurry the reflections should appears in the material.
  42249. */
  42250. roughness: number;
  42251. /**
  42252. * In case of refraction, define the value of the index of refraction.
  42253. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42254. */
  42255. indexOfRefraction: number;
  42256. /**
  42257. * Invert the refraction texture alongside the y axis.
  42258. * It can be useful with procedural textures or probe for instance.
  42259. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42260. */
  42261. invertRefractionY: boolean;
  42262. /**
  42263. * Defines the alpha limits in alpha test mode.
  42264. */
  42265. alphaCutOff: number;
  42266. private _useLightmapAsShadowmap;
  42267. /**
  42268. * In case of light mapping, define whether the map contains light or shadow informations.
  42269. */
  42270. useLightmapAsShadowmap: boolean;
  42271. private _diffuseFresnelParameters;
  42272. /**
  42273. * Define the diffuse fresnel parameters of the material.
  42274. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42275. */
  42276. diffuseFresnelParameters: FresnelParameters;
  42277. private _opacityFresnelParameters;
  42278. /**
  42279. * Define the opacity fresnel parameters of the material.
  42280. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42281. */
  42282. opacityFresnelParameters: FresnelParameters;
  42283. private _reflectionFresnelParameters;
  42284. /**
  42285. * Define the reflection fresnel parameters of the material.
  42286. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42287. */
  42288. reflectionFresnelParameters: FresnelParameters;
  42289. private _refractionFresnelParameters;
  42290. /**
  42291. * Define the refraction fresnel parameters of the material.
  42292. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42293. */
  42294. refractionFresnelParameters: FresnelParameters;
  42295. private _emissiveFresnelParameters;
  42296. /**
  42297. * Define the emissive fresnel parameters of the material.
  42298. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42299. */
  42300. emissiveFresnelParameters: FresnelParameters;
  42301. private _useReflectionFresnelFromSpecular;
  42302. /**
  42303. * If true automatically deducts the fresnels values from the material specularity.
  42304. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42305. */
  42306. useReflectionFresnelFromSpecular: boolean;
  42307. private _useGlossinessFromSpecularMapAlpha;
  42308. /**
  42309. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  42310. */
  42311. useGlossinessFromSpecularMapAlpha: boolean;
  42312. private _maxSimultaneousLights;
  42313. /**
  42314. * Defines the maximum number of lights that can be used in the material
  42315. */
  42316. maxSimultaneousLights: number;
  42317. private _invertNormalMapX;
  42318. /**
  42319. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  42320. */
  42321. invertNormalMapX: boolean;
  42322. private _invertNormalMapY;
  42323. /**
  42324. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  42325. */
  42326. invertNormalMapY: boolean;
  42327. private _twoSidedLighting;
  42328. /**
  42329. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42330. */
  42331. twoSidedLighting: boolean;
  42332. /**
  42333. * Default configuration related to image processing available in the standard Material.
  42334. */
  42335. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42336. /**
  42337. * Gets the image processing configuration used either in this material.
  42338. */
  42339. /**
  42340. * Sets the Default image processing configuration used either in the this material.
  42341. *
  42342. * If sets to null, the scene one is in use.
  42343. */
  42344. imageProcessingConfiguration: ImageProcessingConfiguration;
  42345. /**
  42346. * Keep track of the image processing observer to allow dispose and replace.
  42347. */
  42348. private _imageProcessingObserver;
  42349. /**
  42350. * Attaches a new image processing configuration to the Standard Material.
  42351. * @param configuration
  42352. */
  42353. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42354. /**
  42355. * Gets wether the color curves effect is enabled.
  42356. */
  42357. /**
  42358. * Sets wether the color curves effect is enabled.
  42359. */
  42360. cameraColorCurvesEnabled: boolean;
  42361. /**
  42362. * Gets wether the color grading effect is enabled.
  42363. */
  42364. /**
  42365. * Gets wether the color grading effect is enabled.
  42366. */
  42367. cameraColorGradingEnabled: boolean;
  42368. /**
  42369. * Gets wether tonemapping is enabled or not.
  42370. */
  42371. /**
  42372. * Sets wether tonemapping is enabled or not
  42373. */
  42374. cameraToneMappingEnabled: boolean;
  42375. /**
  42376. * The camera exposure used on this material.
  42377. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42378. * This corresponds to a photographic exposure.
  42379. */
  42380. /**
  42381. * The camera exposure used on this material.
  42382. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42383. * This corresponds to a photographic exposure.
  42384. */
  42385. cameraExposure: number;
  42386. /**
  42387. * Gets The camera contrast used on this material.
  42388. */
  42389. /**
  42390. * Sets The camera contrast used on this material.
  42391. */
  42392. cameraContrast: number;
  42393. /**
  42394. * Gets the Color Grading 2D Lookup Texture.
  42395. */
  42396. /**
  42397. * Sets the Color Grading 2D Lookup Texture.
  42398. */
  42399. cameraColorGradingTexture: Nullable<BaseTexture>;
  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. /**
  42407. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42408. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42409. * 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;
  42410. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42411. */
  42412. cameraColorCurves: Nullable<ColorCurves>;
  42413. /**
  42414. * Custom callback helping to override the default shader used in the material.
  42415. */
  42416. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  42417. protected _renderTargets: SmartArray<RenderTargetTexture>;
  42418. protected _worldViewProjectionMatrix: Matrix;
  42419. protected _globalAmbientColor: Color3;
  42420. protected _useLogarithmicDepth: boolean;
  42421. protected _rebuildInParallel: boolean;
  42422. /**
  42423. * Instantiates a new standard material.
  42424. * This is the default material used in Babylon. It is the best trade off between quality
  42425. * and performances.
  42426. * @see http://doc.babylonjs.com/babylon101/materials
  42427. * @param name Define the name of the material in the scene
  42428. * @param scene Define the scene the material belong to
  42429. */
  42430. constructor(name: string, scene: Scene);
  42431. /**
  42432. * Gets a boolean indicating that current material needs to register RTT
  42433. */
  42434. readonly hasRenderTargetTextures: boolean;
  42435. /**
  42436. * Gets the current class name of the material e.g. "StandardMaterial"
  42437. * Mainly use in serialization.
  42438. * @returns the class name
  42439. */
  42440. getClassName(): string;
  42441. /**
  42442. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  42443. * You can try switching to logarithmic depth.
  42444. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  42445. */
  42446. useLogarithmicDepth: boolean;
  42447. /**
  42448. * Specifies if the material will require alpha blending
  42449. * @returns a boolean specifying if alpha blending is needed
  42450. */
  42451. needAlphaBlending(): boolean;
  42452. /**
  42453. * Specifies if this material should be rendered in alpha test mode
  42454. * @returns a boolean specifying if an alpha test is needed.
  42455. */
  42456. needAlphaTesting(): boolean;
  42457. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  42458. /**
  42459. * Get the texture used for alpha test purpose.
  42460. * @returns the diffuse texture in case of the standard material.
  42461. */
  42462. getAlphaTestTexture(): Nullable<BaseTexture>;
  42463. /**
  42464. * Get if the submesh is ready to be used and all its information available.
  42465. * Child classes can use it to update shaders
  42466. * @param mesh defines the mesh to check
  42467. * @param subMesh defines which submesh to check
  42468. * @param useInstances specifies that instances should be used
  42469. * @returns a boolean indicating that the submesh is ready or not
  42470. */
  42471. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42472. /**
  42473. * Builds the material UBO layouts.
  42474. * Used internally during the effect preparation.
  42475. */
  42476. buildUniformLayout(): void;
  42477. /**
  42478. * Unbinds the material from the mesh
  42479. */
  42480. unbind(): void;
  42481. /**
  42482. * Binds the submesh to this material by preparing the effect and shader to draw
  42483. * @param world defines the world transformation matrix
  42484. * @param mesh defines the mesh containing the submesh
  42485. * @param subMesh defines the submesh to bind the material to
  42486. */
  42487. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42488. /**
  42489. * Get the list of animatables in the material.
  42490. * @returns the list of animatables object used in the material
  42491. */
  42492. getAnimatables(): IAnimatable[];
  42493. /**
  42494. * Gets the active textures from the material
  42495. * @returns an array of textures
  42496. */
  42497. getActiveTextures(): BaseTexture[];
  42498. /**
  42499. * Specifies if the material uses a texture
  42500. * @param texture defines the texture to check against the material
  42501. * @returns a boolean specifying if the material uses the texture
  42502. */
  42503. hasTexture(texture: BaseTexture): boolean;
  42504. /**
  42505. * Disposes the material
  42506. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42507. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42508. */
  42509. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42510. /**
  42511. * Makes a duplicate of the material, and gives it a new name
  42512. * @param name defines the new name for the duplicated material
  42513. * @returns the cloned material
  42514. */
  42515. clone(name: string): StandardMaterial;
  42516. /**
  42517. * Serializes this material in a JSON representation
  42518. * @returns the serialized material object
  42519. */
  42520. serialize(): any;
  42521. /**
  42522. * Creates a standard material from parsed material data
  42523. * @param source defines the JSON representation of the material
  42524. * @param scene defines the hosting scene
  42525. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42526. * @returns a new standard material
  42527. */
  42528. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42529. /**
  42530. * Are diffuse textures enabled in the application.
  42531. */
  42532. static DiffuseTextureEnabled: boolean;
  42533. /**
  42534. * Are ambient textures enabled in the application.
  42535. */
  42536. static AmbientTextureEnabled: boolean;
  42537. /**
  42538. * Are opacity textures enabled in the application.
  42539. */
  42540. static OpacityTextureEnabled: boolean;
  42541. /**
  42542. * Are reflection textures enabled in the application.
  42543. */
  42544. static ReflectionTextureEnabled: boolean;
  42545. /**
  42546. * Are emissive textures enabled in the application.
  42547. */
  42548. static EmissiveTextureEnabled: boolean;
  42549. /**
  42550. * Are specular textures enabled in the application.
  42551. */
  42552. static SpecularTextureEnabled: boolean;
  42553. /**
  42554. * Are bump textures enabled in the application.
  42555. */
  42556. static BumpTextureEnabled: boolean;
  42557. /**
  42558. * Are lightmap textures enabled in the application.
  42559. */
  42560. static LightmapTextureEnabled: boolean;
  42561. /**
  42562. * Are refraction textures enabled in the application.
  42563. */
  42564. static RefractionTextureEnabled: boolean;
  42565. /**
  42566. * Are color grading textures enabled in the application.
  42567. */
  42568. static ColorGradingTextureEnabled: boolean;
  42569. /**
  42570. * Are fresnels enabled in the application.
  42571. */
  42572. static FresnelEnabled: boolean;
  42573. }
  42574. }
  42575. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42576. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42577. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42578. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42579. /** @hidden */
  42580. export var imageProcessingPixelShader: {
  42581. name: string;
  42582. shader: string;
  42583. };
  42584. }
  42585. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42586. import { Nullable } from "babylonjs/types";
  42587. import { Color4 } from "babylonjs/Maths/math.color";
  42588. import { Camera } from "babylonjs/Cameras/camera";
  42589. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42590. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42591. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42592. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42593. import { Engine } from "babylonjs/Engines/engine";
  42594. import "babylonjs/Shaders/imageProcessing.fragment";
  42595. import "babylonjs/Shaders/postprocess.vertex";
  42596. /**
  42597. * ImageProcessingPostProcess
  42598. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42599. */
  42600. export class ImageProcessingPostProcess extends PostProcess {
  42601. /**
  42602. * Default configuration related to image processing available in the PBR Material.
  42603. */
  42604. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42605. /**
  42606. * Gets the image processing configuration used either in this material.
  42607. */
  42608. /**
  42609. * Sets the Default image processing configuration used either in the this material.
  42610. *
  42611. * If sets to null, the scene one is in use.
  42612. */
  42613. imageProcessingConfiguration: ImageProcessingConfiguration;
  42614. /**
  42615. * Keep track of the image processing observer to allow dispose and replace.
  42616. */
  42617. private _imageProcessingObserver;
  42618. /**
  42619. * Attaches a new image processing configuration to the PBR Material.
  42620. * @param configuration
  42621. */
  42622. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42623. /**
  42624. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42625. */
  42626. /**
  42627. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42628. */
  42629. colorCurves: Nullable<ColorCurves>;
  42630. /**
  42631. * Gets wether the color curves effect is enabled.
  42632. */
  42633. /**
  42634. * Sets wether the color curves effect is enabled.
  42635. */
  42636. colorCurvesEnabled: boolean;
  42637. /**
  42638. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42639. */
  42640. /**
  42641. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42642. */
  42643. colorGradingTexture: Nullable<BaseTexture>;
  42644. /**
  42645. * Gets wether the color grading effect is enabled.
  42646. */
  42647. /**
  42648. * Gets wether the color grading effect is enabled.
  42649. */
  42650. colorGradingEnabled: boolean;
  42651. /**
  42652. * Gets exposure used in the effect.
  42653. */
  42654. /**
  42655. * Sets exposure used in the effect.
  42656. */
  42657. exposure: number;
  42658. /**
  42659. * Gets wether tonemapping is enabled or not.
  42660. */
  42661. /**
  42662. * Sets wether tonemapping is enabled or not
  42663. */
  42664. toneMappingEnabled: boolean;
  42665. /**
  42666. * Gets the type of tone mapping effect.
  42667. */
  42668. /**
  42669. * Sets the type of tone mapping effect.
  42670. */
  42671. toneMappingType: number;
  42672. /**
  42673. * Gets contrast used in the effect.
  42674. */
  42675. /**
  42676. * Sets contrast used in the effect.
  42677. */
  42678. contrast: number;
  42679. /**
  42680. * Gets Vignette stretch size.
  42681. */
  42682. /**
  42683. * Sets Vignette stretch size.
  42684. */
  42685. vignetteStretch: number;
  42686. /**
  42687. * Gets Vignette centre X Offset.
  42688. */
  42689. /**
  42690. * Sets Vignette centre X Offset.
  42691. */
  42692. vignetteCentreX: number;
  42693. /**
  42694. * Gets Vignette centre Y Offset.
  42695. */
  42696. /**
  42697. * Sets Vignette centre Y Offset.
  42698. */
  42699. vignetteCentreY: number;
  42700. /**
  42701. * Gets Vignette weight or intensity of the vignette effect.
  42702. */
  42703. /**
  42704. * Sets Vignette weight or intensity of the vignette effect.
  42705. */
  42706. vignetteWeight: number;
  42707. /**
  42708. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42709. * if vignetteEnabled is set to true.
  42710. */
  42711. /**
  42712. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42713. * if vignetteEnabled is set to true.
  42714. */
  42715. vignetteColor: Color4;
  42716. /**
  42717. * Gets Camera field of view used by the Vignette effect.
  42718. */
  42719. /**
  42720. * Sets Camera field of view used by the Vignette effect.
  42721. */
  42722. vignetteCameraFov: number;
  42723. /**
  42724. * Gets the vignette blend mode allowing different kind of effect.
  42725. */
  42726. /**
  42727. * Sets the vignette blend mode allowing different kind of effect.
  42728. */
  42729. vignetteBlendMode: number;
  42730. /**
  42731. * Gets wether the vignette effect is enabled.
  42732. */
  42733. /**
  42734. * Sets wether the vignette effect is enabled.
  42735. */
  42736. vignetteEnabled: boolean;
  42737. private _fromLinearSpace;
  42738. /**
  42739. * Gets wether the input of the processing is in Gamma or Linear Space.
  42740. */
  42741. /**
  42742. * Sets wether the input of the processing is in Gamma or Linear Space.
  42743. */
  42744. fromLinearSpace: boolean;
  42745. /**
  42746. * Defines cache preventing GC.
  42747. */
  42748. private _defines;
  42749. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42750. /**
  42751. * "ImageProcessingPostProcess"
  42752. * @returns "ImageProcessingPostProcess"
  42753. */
  42754. getClassName(): string;
  42755. protected _updateParameters(): void;
  42756. dispose(camera?: Camera): void;
  42757. }
  42758. }
  42759. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42760. import { Scene } from "babylonjs/scene";
  42761. import { Color3 } from "babylonjs/Maths/math.color";
  42762. import { Mesh } from "babylonjs/Meshes/mesh";
  42763. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42764. import { Nullable } from "babylonjs/types";
  42765. /**
  42766. * Class containing static functions to help procedurally build meshes
  42767. */
  42768. export class GroundBuilder {
  42769. /**
  42770. * Creates a ground mesh
  42771. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42772. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42774. * @param name defines the name of the mesh
  42775. * @param options defines the options used to create the mesh
  42776. * @param scene defines the hosting scene
  42777. * @returns the ground mesh
  42778. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42779. */
  42780. static CreateGround(name: string, options: {
  42781. width?: number;
  42782. height?: number;
  42783. subdivisions?: number;
  42784. subdivisionsX?: number;
  42785. subdivisionsY?: number;
  42786. updatable?: boolean;
  42787. }, scene: any): Mesh;
  42788. /**
  42789. * Creates a tiled ground mesh
  42790. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42791. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42792. * * 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
  42793. * * 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
  42794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42795. * @param name defines the name of the mesh
  42796. * @param options defines the options used to create the mesh
  42797. * @param scene defines the hosting scene
  42798. * @returns the tiled ground mesh
  42799. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42800. */
  42801. static CreateTiledGround(name: string, options: {
  42802. xmin: number;
  42803. zmin: number;
  42804. xmax: number;
  42805. zmax: number;
  42806. subdivisions?: {
  42807. w: number;
  42808. h: number;
  42809. };
  42810. precision?: {
  42811. w: number;
  42812. h: number;
  42813. };
  42814. updatable?: boolean;
  42815. }, scene?: Nullable<Scene>): Mesh;
  42816. /**
  42817. * Creates a ground mesh from a height map
  42818. * * The parameter `url` sets the URL of the height map image resource.
  42819. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42820. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42821. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42822. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42823. * * 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.
  42824. * * 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).
  42825. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42827. * @param name defines the name of the mesh
  42828. * @param url defines the url to the height map
  42829. * @param options defines the options used to create the mesh
  42830. * @param scene defines the hosting scene
  42831. * @returns the ground mesh
  42832. * @see https://doc.babylonjs.com/babylon101/height_map
  42833. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42834. */
  42835. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42836. width?: number;
  42837. height?: number;
  42838. subdivisions?: number;
  42839. minHeight?: number;
  42840. maxHeight?: number;
  42841. colorFilter?: Color3;
  42842. alphaFilter?: number;
  42843. updatable?: boolean;
  42844. onReady?: (mesh: GroundMesh) => void;
  42845. }, scene?: Nullable<Scene>): GroundMesh;
  42846. }
  42847. }
  42848. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42849. import { Vector4 } from "babylonjs/Maths/math.vector";
  42850. import { Mesh } from "babylonjs/Meshes/mesh";
  42851. /**
  42852. * Class containing static functions to help procedurally build meshes
  42853. */
  42854. export class TorusBuilder {
  42855. /**
  42856. * Creates a torus mesh
  42857. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42858. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42859. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42863. * @param name defines the name of the mesh
  42864. * @param options defines the options used to create the mesh
  42865. * @param scene defines the hosting scene
  42866. * @returns the torus mesh
  42867. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42868. */
  42869. static CreateTorus(name: string, options: {
  42870. diameter?: number;
  42871. thickness?: number;
  42872. tessellation?: number;
  42873. updatable?: boolean;
  42874. sideOrientation?: number;
  42875. frontUVs?: Vector4;
  42876. backUVs?: Vector4;
  42877. }, scene: any): Mesh;
  42878. }
  42879. }
  42880. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42881. import { Vector4 } from "babylonjs/Maths/math.vector";
  42882. import { Color4 } from "babylonjs/Maths/math.color";
  42883. import { Mesh } from "babylonjs/Meshes/mesh";
  42884. /**
  42885. * Class containing static functions to help procedurally build meshes
  42886. */
  42887. export class CylinderBuilder {
  42888. /**
  42889. * Creates a cylinder or a cone mesh
  42890. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42891. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42892. * * 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.
  42893. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42894. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42895. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42896. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42897. * * 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).
  42898. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42899. * * 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).
  42900. * * 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
  42901. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42902. * * 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
  42903. * * 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.
  42904. * * If `enclose` is false, a ring surface is one element.
  42905. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42906. * * 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
  42907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42908. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42910. * @param name defines the name of the mesh
  42911. * @param options defines the options used to create the mesh
  42912. * @param scene defines the hosting scene
  42913. * @returns the cylinder mesh
  42914. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42915. */
  42916. static CreateCylinder(name: string, options: {
  42917. height?: number;
  42918. diameterTop?: number;
  42919. diameterBottom?: number;
  42920. diameter?: number;
  42921. tessellation?: number;
  42922. subdivisions?: number;
  42923. arc?: number;
  42924. faceColors?: Color4[];
  42925. faceUV?: Vector4[];
  42926. updatable?: boolean;
  42927. hasRings?: boolean;
  42928. enclose?: boolean;
  42929. cap?: number;
  42930. sideOrientation?: number;
  42931. frontUVs?: Vector4;
  42932. backUVs?: Vector4;
  42933. }, scene: any): Mesh;
  42934. }
  42935. }
  42936. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42937. import { Observable } from "babylonjs/Misc/observable";
  42938. import { Nullable } from "babylonjs/types";
  42939. import { Camera } from "babylonjs/Cameras/camera";
  42940. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42941. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42942. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42943. import { Scene } from "babylonjs/scene";
  42944. import { Vector3 } from "babylonjs/Maths/math.vector";
  42945. import { Color3 } from "babylonjs/Maths/math.color";
  42946. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42948. import { Mesh } from "babylonjs/Meshes/mesh";
  42949. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42950. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42951. import "babylonjs/Meshes/Builders/groundBuilder";
  42952. import "babylonjs/Meshes/Builders/torusBuilder";
  42953. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42954. import "babylonjs/Gamepads/gamepadSceneComponent";
  42955. import "babylonjs/Animations/animatable";
  42956. /**
  42957. * Options to modify the vr teleportation behavior.
  42958. */
  42959. export interface VRTeleportationOptions {
  42960. /**
  42961. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42962. */
  42963. floorMeshName?: string;
  42964. /**
  42965. * A list of meshes to be used as the teleportation floor. (default: empty)
  42966. */
  42967. floorMeshes?: Mesh[];
  42968. }
  42969. /**
  42970. * Options to modify the vr experience helper's behavior.
  42971. */
  42972. export interface VRExperienceHelperOptions extends WebVROptions {
  42973. /**
  42974. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42975. */
  42976. createDeviceOrientationCamera?: boolean;
  42977. /**
  42978. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42979. */
  42980. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42981. /**
  42982. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42983. */
  42984. laserToggle?: boolean;
  42985. /**
  42986. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42987. */
  42988. floorMeshes?: Mesh[];
  42989. /**
  42990. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42991. */
  42992. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42993. }
  42994. /**
  42995. * Event containing information after VR has been entered
  42996. */
  42997. export class OnAfterEnteringVRObservableEvent {
  42998. /**
  42999. * If entering vr was successful
  43000. */
  43001. success: boolean;
  43002. }
  43003. /**
  43004. * Helps to quickly add VR support to an existing scene.
  43005. * See http://doc.babylonjs.com/how_to/webvr_helper
  43006. */
  43007. export class VRExperienceHelper {
  43008. /** Options to modify the vr experience helper's behavior. */
  43009. webVROptions: VRExperienceHelperOptions;
  43010. private _scene;
  43011. private _position;
  43012. private _btnVR;
  43013. private _btnVRDisplayed;
  43014. private _webVRsupported;
  43015. private _webVRready;
  43016. private _webVRrequesting;
  43017. private _webVRpresenting;
  43018. private _hasEnteredVR;
  43019. private _fullscreenVRpresenting;
  43020. private _inputElement;
  43021. private _webVRCamera;
  43022. private _vrDeviceOrientationCamera;
  43023. private _deviceOrientationCamera;
  43024. private _existingCamera;
  43025. private _onKeyDown;
  43026. private _onVrDisplayPresentChange;
  43027. private _onVRDisplayChanged;
  43028. private _onVRRequestPresentStart;
  43029. private _onVRRequestPresentComplete;
  43030. /**
  43031. * 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)
  43032. */
  43033. enableGazeEvenWhenNoPointerLock: boolean;
  43034. /**
  43035. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  43036. */
  43037. exitVROnDoubleTap: boolean;
  43038. /**
  43039. * Observable raised right before entering VR.
  43040. */
  43041. onEnteringVRObservable: Observable<VRExperienceHelper>;
  43042. /**
  43043. * Observable raised when entering VR has completed.
  43044. */
  43045. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  43046. /**
  43047. * Observable raised when exiting VR.
  43048. */
  43049. onExitingVRObservable: Observable<VRExperienceHelper>;
  43050. /**
  43051. * Observable raised when controller mesh is loaded.
  43052. */
  43053. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43054. /** Return this.onEnteringVRObservable
  43055. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  43056. */
  43057. readonly onEnteringVR: Observable<VRExperienceHelper>;
  43058. /** Return this.onExitingVRObservable
  43059. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  43060. */
  43061. readonly onExitingVR: Observable<VRExperienceHelper>;
  43062. /** Return this.onControllerMeshLoadedObservable
  43063. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  43064. */
  43065. readonly onControllerMeshLoaded: Observable<WebVRController>;
  43066. private _rayLength;
  43067. private _useCustomVRButton;
  43068. private _teleportationRequested;
  43069. private _teleportActive;
  43070. private _floorMeshName;
  43071. private _floorMeshesCollection;
  43072. private _rotationAllowed;
  43073. private _teleportBackwardsVector;
  43074. private _teleportationTarget;
  43075. private _isDefaultTeleportationTarget;
  43076. private _postProcessMove;
  43077. private _teleportationFillColor;
  43078. private _teleportationBorderColor;
  43079. private _rotationAngle;
  43080. private _haloCenter;
  43081. private _cameraGazer;
  43082. private _padSensibilityUp;
  43083. private _padSensibilityDown;
  43084. private _leftController;
  43085. private _rightController;
  43086. /**
  43087. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  43088. */
  43089. onNewMeshSelected: Observable<AbstractMesh>;
  43090. /**
  43091. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  43092. * This observable will provide the mesh and the controller used to select the mesh
  43093. */
  43094. onMeshSelectedWithController: Observable<{
  43095. mesh: AbstractMesh;
  43096. controller: WebVRController;
  43097. }>;
  43098. /**
  43099. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  43100. */
  43101. onNewMeshPicked: Observable<PickingInfo>;
  43102. private _circleEase;
  43103. /**
  43104. * Observable raised before camera teleportation
  43105. */
  43106. onBeforeCameraTeleport: Observable<Vector3>;
  43107. /**
  43108. * Observable raised after camera teleportation
  43109. */
  43110. onAfterCameraTeleport: Observable<Vector3>;
  43111. /**
  43112. * Observable raised when current selected mesh gets unselected
  43113. */
  43114. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43115. private _raySelectionPredicate;
  43116. /**
  43117. * To be optionaly changed by user to define custom ray selection
  43118. */
  43119. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43120. /**
  43121. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43122. */
  43123. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43124. /**
  43125. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43126. */
  43127. teleportationEnabled: boolean;
  43128. private _defaultHeight;
  43129. private _teleportationInitialized;
  43130. private _interactionsEnabled;
  43131. private _interactionsRequested;
  43132. private _displayGaze;
  43133. private _displayLaserPointer;
  43134. /**
  43135. * The mesh used to display where the user is going to teleport.
  43136. */
  43137. /**
  43138. * Sets the mesh to be used to display where the user is going to teleport.
  43139. */
  43140. teleportationTarget: Mesh;
  43141. /**
  43142. * 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
  43143. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43144. * See http://doc.babylonjs.com/resources/baking_transformations
  43145. */
  43146. gazeTrackerMesh: Mesh;
  43147. /**
  43148. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43149. */
  43150. updateGazeTrackerScale: boolean;
  43151. /**
  43152. * If the gaze trackers color should be updated when selecting meshes
  43153. */
  43154. updateGazeTrackerColor: boolean;
  43155. /**
  43156. * If the controller laser color should be updated when selecting meshes
  43157. */
  43158. updateControllerLaserColor: boolean;
  43159. /**
  43160. * The gaze tracking mesh corresponding to the left controller
  43161. */
  43162. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  43163. /**
  43164. * The gaze tracking mesh corresponding to the right controller
  43165. */
  43166. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  43167. /**
  43168. * If the ray of the gaze should be displayed.
  43169. */
  43170. /**
  43171. * Sets if the ray of the gaze should be displayed.
  43172. */
  43173. displayGaze: boolean;
  43174. /**
  43175. * If the ray of the LaserPointer should be displayed.
  43176. */
  43177. /**
  43178. * Sets if the ray of the LaserPointer should be displayed.
  43179. */
  43180. displayLaserPointer: boolean;
  43181. /**
  43182. * The deviceOrientationCamera used as the camera when not in VR.
  43183. */
  43184. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  43185. /**
  43186. * Based on the current WebVR support, returns the current VR camera used.
  43187. */
  43188. readonly currentVRCamera: Nullable<Camera>;
  43189. /**
  43190. * The webVRCamera which is used when in VR.
  43191. */
  43192. readonly webVRCamera: WebVRFreeCamera;
  43193. /**
  43194. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43195. */
  43196. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  43197. /**
  43198. * The html button that is used to trigger entering into VR.
  43199. */
  43200. readonly vrButton: Nullable<HTMLButtonElement>;
  43201. private readonly _teleportationRequestInitiated;
  43202. /**
  43203. * Defines wether or not Pointer lock should be requested when switching to
  43204. * full screen.
  43205. */
  43206. requestPointerLockOnFullScreen: boolean;
  43207. /**
  43208. * Instantiates a VRExperienceHelper.
  43209. * Helps to quickly add VR support to an existing scene.
  43210. * @param scene The scene the VRExperienceHelper belongs to.
  43211. * @param webVROptions Options to modify the vr experience helper's behavior.
  43212. */
  43213. constructor(scene: Scene,
  43214. /** Options to modify the vr experience helper's behavior. */
  43215. webVROptions?: VRExperienceHelperOptions);
  43216. private _onDefaultMeshLoaded;
  43217. private _onResize;
  43218. private _onFullscreenChange;
  43219. /**
  43220. * Gets a value indicating if we are currently in VR mode.
  43221. */
  43222. readonly isInVRMode: boolean;
  43223. private onVrDisplayPresentChange;
  43224. private onVRDisplayChanged;
  43225. private moveButtonToBottomRight;
  43226. private displayVRButton;
  43227. private updateButtonVisibility;
  43228. private _cachedAngularSensibility;
  43229. /**
  43230. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  43231. * Otherwise, will use the fullscreen API.
  43232. */
  43233. enterVR(): void;
  43234. /**
  43235. * Attempt to exit VR, or fullscreen.
  43236. */
  43237. exitVR(): void;
  43238. /**
  43239. * The position of the vr experience helper.
  43240. */
  43241. /**
  43242. * Sets the position of the vr experience helper.
  43243. */
  43244. position: Vector3;
  43245. /**
  43246. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43247. */
  43248. enableInteractions(): void;
  43249. private readonly _noControllerIsActive;
  43250. private beforeRender;
  43251. private _isTeleportationFloor;
  43252. /**
  43253. * Adds a floor mesh to be used for teleportation.
  43254. * @param floorMesh the mesh to be used for teleportation.
  43255. */
  43256. addFloorMesh(floorMesh: Mesh): void;
  43257. /**
  43258. * Removes a floor mesh from being used for teleportation.
  43259. * @param floorMesh the mesh to be removed.
  43260. */
  43261. removeFloorMesh(floorMesh: Mesh): void;
  43262. /**
  43263. * Enables interactions and teleportation using the VR controllers and gaze.
  43264. * @param vrTeleportationOptions options to modify teleportation behavior.
  43265. */
  43266. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43267. private _onNewGamepadConnected;
  43268. private _tryEnableInteractionOnController;
  43269. private _onNewGamepadDisconnected;
  43270. private _enableInteractionOnController;
  43271. private _checkTeleportWithRay;
  43272. private _checkRotate;
  43273. private _checkTeleportBackwards;
  43274. private _enableTeleportationOnController;
  43275. private _createTeleportationCircles;
  43276. private _displayTeleportationTarget;
  43277. private _hideTeleportationTarget;
  43278. private _rotateCamera;
  43279. private _moveTeleportationSelectorTo;
  43280. private _workingVector;
  43281. private _workingQuaternion;
  43282. private _workingMatrix;
  43283. /**
  43284. * Teleports the users feet to the desired location
  43285. * @param location The location where the user's feet should be placed
  43286. */
  43287. teleportCamera(location: Vector3): void;
  43288. private _convertNormalToDirectionOfRay;
  43289. private _castRayAndSelectObject;
  43290. private _notifySelectedMeshUnselected;
  43291. /**
  43292. * Sets the color of the laser ray from the vr controllers.
  43293. * @param color new color for the ray.
  43294. */
  43295. changeLaserColor(color: Color3): void;
  43296. /**
  43297. * Sets the color of the ray from the vr headsets gaze.
  43298. * @param color new color for the ray.
  43299. */
  43300. changeGazeColor(color: Color3): void;
  43301. /**
  43302. * Exits VR and disposes of the vr experience helper
  43303. */
  43304. dispose(): void;
  43305. /**
  43306. * Gets the name of the VRExperienceHelper class
  43307. * @returns "VRExperienceHelper"
  43308. */
  43309. getClassName(): string;
  43310. }
  43311. }
  43312. declare module "babylonjs/Cameras/VR/index" {
  43313. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  43314. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  43315. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43316. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  43317. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  43318. export * from "babylonjs/Cameras/VR/webVRCamera";
  43319. }
  43320. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43321. import { Nullable } from "babylonjs/types";
  43322. import { IDisposable } from "babylonjs/scene";
  43323. /**
  43324. * States of the webXR experience
  43325. */
  43326. export enum WebXRState {
  43327. /**
  43328. * Transitioning to being in XR mode
  43329. */
  43330. ENTERING_XR = 0,
  43331. /**
  43332. * Transitioning to non XR mode
  43333. */
  43334. EXITING_XR = 1,
  43335. /**
  43336. * In XR mode and presenting
  43337. */
  43338. IN_XR = 2,
  43339. /**
  43340. * Not entered XR mode
  43341. */
  43342. NOT_IN_XR = 3
  43343. }
  43344. /**
  43345. * Abstraction of the XR render target
  43346. */
  43347. export interface WebXRRenderTarget extends IDisposable {
  43348. /**
  43349. * xrpresent context of the canvas which can be used to display/mirror xr content
  43350. */
  43351. canvasContext: WebGLRenderingContext;
  43352. /**
  43353. * xr layer for the canvas
  43354. */
  43355. xrLayer: Nullable<XRWebGLLayer>;
  43356. /**
  43357. * Initializes the xr layer for the session
  43358. * @param xrSession xr session
  43359. * @returns a promise that will resolve once the XR Layer has been created
  43360. */
  43361. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43362. }
  43363. }
  43364. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43365. import { Nullable } from "babylonjs/types";
  43366. import { Observable } from "babylonjs/Misc/observable";
  43367. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43368. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43369. /**
  43370. * COnfiguration object for WebXR output canvas
  43371. */
  43372. export class WebXRManagedOutputCanvasOptions {
  43373. /**
  43374. * Options for this XR Layer output
  43375. */
  43376. canvasOptions: XRWebGLLayerOptions;
  43377. /**
  43378. * CSS styling for a newly created canvas (if not provided)
  43379. */
  43380. newCanvasCssStyle?: string;
  43381. /**
  43382. * Get the default values of the configuration object
  43383. * @returns default values of this configuration object
  43384. */
  43385. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43386. }
  43387. /**
  43388. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43389. */
  43390. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43391. private configuration;
  43392. private _engine;
  43393. private _canvas;
  43394. /**
  43395. * xrpresent context of the canvas which can be used to display/mirror xr content
  43396. */
  43397. canvasContext: WebGLRenderingContext;
  43398. /**
  43399. * xr layer for the canvas
  43400. */
  43401. xrLayer: Nullable<XRWebGLLayer>;
  43402. /**
  43403. * Initializes the xr layer for the session
  43404. * @param xrSession xr session
  43405. * @returns a promise that will resolve once the XR Layer has been created
  43406. */
  43407. initializeXRLayerAsync(xrSession: any): any;
  43408. /**
  43409. * Initializes the canvas to be added/removed upon entering/exiting xr
  43410. * @param engine the Babylon engine
  43411. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43412. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43413. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43414. */
  43415. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43416. /**
  43417. * Disposes of the object
  43418. */
  43419. dispose(): void;
  43420. private _setManagedOutputCanvas;
  43421. private _addCanvas;
  43422. private _removeCanvas;
  43423. }
  43424. }
  43425. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43426. import { Observable } from "babylonjs/Misc/observable";
  43427. import { Nullable } from "babylonjs/types";
  43428. import { IDisposable, Scene } from "babylonjs/scene";
  43429. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43430. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43431. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43432. /**
  43433. * Manages an XRSession to work with Babylon's engine
  43434. * @see https://doc.babylonjs.com/how_to/webxr
  43435. */
  43436. export class WebXRSessionManager implements IDisposable {
  43437. private scene;
  43438. /**
  43439. * Fires every time a new xrFrame arrives which can be used to update the camera
  43440. */
  43441. onXRFrameObservable: Observable<any>;
  43442. /**
  43443. * Fires when the xr session is ended either by the device or manually done
  43444. */
  43445. onXRSessionEnded: Observable<any>;
  43446. /**
  43447. * Underlying xr session
  43448. */
  43449. session: XRSession;
  43450. /**
  43451. * Type of reference space used when creating the session
  43452. */
  43453. referenceSpace: XRReferenceSpace;
  43454. /**
  43455. * Current XR frame
  43456. */
  43457. currentFrame: Nullable<XRFrame>;
  43458. private _xrNavigator;
  43459. private baseLayer;
  43460. private _rttProvider;
  43461. private _sessionEnded;
  43462. /**
  43463. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43464. * @param scene The scene which the session should be created for
  43465. */
  43466. constructor(scene: Scene);
  43467. /**
  43468. * Initializes the manager
  43469. * After initialization enterXR can be called to start an XR session
  43470. * @returns Promise which resolves after it is initialized
  43471. */
  43472. initializeAsync(): Promise<void>;
  43473. /**
  43474. * Initializes an xr session
  43475. * @param xrSessionMode mode to initialize
  43476. * @param optionalFeatures defines optional values to pass to the session builder
  43477. * @returns a promise which will resolve once the session has been initialized
  43478. */
  43479. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  43480. /**
  43481. * Sets the reference space on the xr session
  43482. * @param referenceSpace space to set
  43483. * @returns a promise that will resolve once the reference space has been set
  43484. */
  43485. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43486. /**
  43487. * Updates the render state of the session
  43488. * @param state state to set
  43489. * @returns a promise that resolves once the render state has been updated
  43490. */
  43491. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43492. /**
  43493. * Starts rendering to the xr layer
  43494. * @returns a promise that will resolve once rendering has started
  43495. */
  43496. startRenderingToXRAsync(): Promise<void>;
  43497. /**
  43498. * Gets the correct render target texture to be rendered this frame for this eye
  43499. * @param eye the eye for which to get the render target
  43500. * @returns the render target for the specified eye
  43501. */
  43502. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43503. /**
  43504. * Stops the xrSession and restores the renderloop
  43505. * @returns Promise which resolves after it exits XR
  43506. */
  43507. exitXRAsync(): Promise<void>;
  43508. /**
  43509. * Checks if a session would be supported for the creation options specified
  43510. * @param sessionMode session mode to check if supported eg. immersive-vr
  43511. * @returns true if supported
  43512. */
  43513. supportsSessionAsync(sessionMode: XRSessionMode): any;
  43514. /**
  43515. * Creates a WebXRRenderTarget object for the XR session
  43516. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43517. * @param options optional options to provide when creating a new render target
  43518. * @returns a WebXR render target to which the session can render
  43519. */
  43520. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43521. /**
  43522. * @hidden
  43523. * Converts the render layer of xrSession to a render target
  43524. * @param session session to create render target for
  43525. * @param scene scene the new render target should be created for
  43526. */
  43527. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43528. /**
  43529. * Disposes of the session manager
  43530. */
  43531. dispose(): void;
  43532. }
  43533. }
  43534. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43535. import { Scene } from "babylonjs/scene";
  43536. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43537. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43538. /**
  43539. * WebXR Camera which holds the views for the xrSession
  43540. * @see https://doc.babylonjs.com/how_to/webxr
  43541. */
  43542. export class WebXRCamera extends FreeCamera {
  43543. /**
  43544. * Is the camera in debug mode. Used when using an emulator
  43545. */
  43546. debugMode: boolean;
  43547. /**
  43548. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43549. * @param name the name of the camera
  43550. * @param scene the scene to add the camera to
  43551. */
  43552. constructor(name: string, scene: Scene);
  43553. private _updateNumberOfRigCameras;
  43554. /** @hidden */
  43555. _updateForDualEyeDebugging(): void;
  43556. /**
  43557. * Updates the cameras position from the current pose information of the XR session
  43558. * @param xrSessionManager the session containing pose information
  43559. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43560. */
  43561. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43562. }
  43563. }
  43564. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43565. import { Observable } from "babylonjs/Misc/observable";
  43566. import { IDisposable, Scene } from "babylonjs/scene";
  43567. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43569. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43570. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43571. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43572. /**
  43573. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43574. * @see https://doc.babylonjs.com/how_to/webxr
  43575. */
  43576. export class WebXRExperienceHelper implements IDisposable {
  43577. private scene;
  43578. /**
  43579. * 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
  43580. */
  43581. container: AbstractMesh;
  43582. /**
  43583. * Camera used to render xr content
  43584. */
  43585. camera: WebXRCamera;
  43586. /**
  43587. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43588. */
  43589. state: WebXRState;
  43590. private _setState;
  43591. private static _TmpVector;
  43592. /**
  43593. * Fires when the state of the experience helper has changed
  43594. */
  43595. onStateChangedObservable: Observable<WebXRState>;
  43596. /** Session manager used to keep track of xr session */
  43597. sessionManager: WebXRSessionManager;
  43598. private _nonVRCamera;
  43599. private _originalSceneAutoClear;
  43600. private _supported;
  43601. /**
  43602. * Creates the experience helper
  43603. * @param scene the scene to attach the experience helper to
  43604. * @returns a promise for the experience helper
  43605. */
  43606. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43607. /**
  43608. * Creates a WebXRExperienceHelper
  43609. * @param scene The scene the helper should be created in
  43610. */
  43611. private constructor();
  43612. /**
  43613. * Exits XR mode and returns the scene to its original state
  43614. * @returns promise that resolves after xr mode has exited
  43615. */
  43616. exitXRAsync(): Promise<void>;
  43617. /**
  43618. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43619. * @param sessionMode options for the XR session
  43620. * @param referenceSpaceType frame of reference of the XR session
  43621. * @param renderTarget the output canvas that will be used to enter XR mode
  43622. * @returns promise that resolves after xr mode has entered
  43623. */
  43624. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  43625. /**
  43626. * Updates the global position of the camera by moving the camera's container
  43627. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43628. * @param position The desired global position of the camera
  43629. */
  43630. setPositionOfCameraUsingContainer(position: Vector3): void;
  43631. /**
  43632. * Rotates the xr camera by rotating the camera's container around the camera's position
  43633. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43634. * @param rotation the desired quaternion rotation to apply to the camera
  43635. */
  43636. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43637. /**
  43638. * Disposes of the experience helper
  43639. */
  43640. dispose(): void;
  43641. }
  43642. }
  43643. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43644. import { Nullable } from "babylonjs/types";
  43645. import { Observable } from "babylonjs/Misc/observable";
  43646. import { IDisposable, Scene } from "babylonjs/scene";
  43647. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43648. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43649. /**
  43650. * Button which can be used to enter a different mode of XR
  43651. */
  43652. export class WebXREnterExitUIButton {
  43653. /** button element */
  43654. element: HTMLElement;
  43655. /** XR initialization options for the button */
  43656. sessionMode: XRSessionMode;
  43657. /** Reference space type */
  43658. referenceSpaceType: XRReferenceSpaceType;
  43659. /**
  43660. * Creates a WebXREnterExitUIButton
  43661. * @param element button element
  43662. * @param sessionMode XR initialization session mode
  43663. * @param referenceSpaceType the type of reference space to be used
  43664. */
  43665. constructor(
  43666. /** button element */
  43667. element: HTMLElement,
  43668. /** XR initialization options for the button */
  43669. sessionMode: XRSessionMode,
  43670. /** Reference space type */
  43671. referenceSpaceType: XRReferenceSpaceType);
  43672. /**
  43673. * Overwritable function which can be used to update the button's visuals when the state changes
  43674. * @param activeButton the current active button in the UI
  43675. */
  43676. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43677. }
  43678. /**
  43679. * Options to create the webXR UI
  43680. */
  43681. export class WebXREnterExitUIOptions {
  43682. /**
  43683. * Context to enter xr with
  43684. */
  43685. renderTarget?: Nullable<WebXRRenderTarget>;
  43686. /**
  43687. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43688. */
  43689. customButtons?: Array<WebXREnterExitUIButton>;
  43690. }
  43691. /**
  43692. * UI to allow the user to enter/exit XR mode
  43693. */
  43694. export class WebXREnterExitUI implements IDisposable {
  43695. private scene;
  43696. private _overlay;
  43697. private _buttons;
  43698. private _activeButton;
  43699. /**
  43700. * Fired every time the active button is changed.
  43701. *
  43702. * When xr is entered via a button that launches xr that button will be the callback parameter
  43703. *
  43704. * When exiting xr the callback parameter will be null)
  43705. */
  43706. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43707. /**
  43708. * Creates UI to allow the user to enter/exit XR mode
  43709. * @param scene the scene to add the ui to
  43710. * @param helper the xr experience helper to enter/exit xr with
  43711. * @param options options to configure the UI
  43712. * @returns the created ui
  43713. */
  43714. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43715. private constructor();
  43716. private _updateButtons;
  43717. /**
  43718. * Disposes of the object
  43719. */
  43720. dispose(): void;
  43721. }
  43722. }
  43723. declare module "babylonjs/Cameras/XR/webXRController" {
  43724. import { Nullable } from "babylonjs/types";
  43725. import { Observable } from "babylonjs/Misc/observable";
  43726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43727. import { Ray } from "babylonjs/Culling/ray";
  43728. import { Scene } from "babylonjs/scene";
  43729. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43730. /**
  43731. * Represents an XR input
  43732. */
  43733. export class WebXRController {
  43734. private scene;
  43735. /** The underlying input source for the controller */
  43736. inputSource: XRInputSource;
  43737. private parentContainer;
  43738. /**
  43739. * 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
  43740. */
  43741. grip?: AbstractMesh;
  43742. /**
  43743. * Pointer which can be used to select objects or attach a visible laser to
  43744. */
  43745. pointer: AbstractMesh;
  43746. private _gamepadMode;
  43747. /**
  43748. * If available, this is the gamepad object related to this controller.
  43749. * Using this object it is possible to get click events and trackpad changes of the
  43750. * webxr controller that is currently being used.
  43751. */
  43752. gamepadController?: WebVRController;
  43753. /**
  43754. * Event that fires when the controller is removed/disposed
  43755. */
  43756. onDisposeObservable: Observable<{}>;
  43757. private _tmpMatrix;
  43758. private _tmpQuaternion;
  43759. private _tmpVector;
  43760. /**
  43761. * Creates the controller
  43762. * @see https://doc.babylonjs.com/how_to/webxr
  43763. * @param scene the scene which the controller should be associated to
  43764. * @param inputSource the underlying input source for the controller
  43765. * @param parentContainer parent that the controller meshes should be children of
  43766. */
  43767. constructor(scene: Scene,
  43768. /** The underlying input source for the controller */
  43769. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43770. /**
  43771. * Updates the controller pose based on the given XRFrame
  43772. * @param xrFrame xr frame to update the pose with
  43773. * @param referenceSpace reference space to use
  43774. */
  43775. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43776. /**
  43777. * Gets a world space ray coming from the controller
  43778. * @param result the resulting ray
  43779. */
  43780. getWorldPointerRayToRef(result: Ray): void;
  43781. /**
  43782. * Get the scene associated with this controller
  43783. * @returns the scene object
  43784. */
  43785. getScene(): Scene;
  43786. /**
  43787. * Disposes of the object
  43788. */
  43789. dispose(): void;
  43790. }
  43791. }
  43792. declare module "babylonjs/Cameras/XR/webXRInput" {
  43793. import { Observable } from "babylonjs/Misc/observable";
  43794. import { IDisposable } from "babylonjs/scene";
  43795. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43796. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43797. /**
  43798. * XR input used to track XR inputs such as controllers/rays
  43799. */
  43800. export class WebXRInput implements IDisposable {
  43801. /**
  43802. * Base experience the input listens to
  43803. */
  43804. baseExperience: WebXRExperienceHelper;
  43805. /**
  43806. * XR controllers being tracked
  43807. */
  43808. controllers: Array<WebXRController>;
  43809. private _frameObserver;
  43810. private _stateObserver;
  43811. /**
  43812. * Event when a controller has been connected/added
  43813. */
  43814. onControllerAddedObservable: Observable<WebXRController>;
  43815. /**
  43816. * Event when a controller has been removed/disconnected
  43817. */
  43818. onControllerRemovedObservable: Observable<WebXRController>;
  43819. /**
  43820. * Initializes the WebXRInput
  43821. * @param baseExperience experience helper which the input should be created for
  43822. */
  43823. constructor(
  43824. /**
  43825. * Base experience the input listens to
  43826. */
  43827. baseExperience: WebXRExperienceHelper);
  43828. private _onInputSourcesChange;
  43829. private _addAndRemoveControllers;
  43830. /**
  43831. * Disposes of the object
  43832. */
  43833. dispose(): void;
  43834. }
  43835. }
  43836. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43838. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43839. /**
  43840. * Enables teleportation
  43841. */
  43842. export class WebXRControllerTeleportation {
  43843. private _teleportationFillColor;
  43844. private _teleportationBorderColor;
  43845. private _tmpRay;
  43846. private _tmpVector;
  43847. /**
  43848. * Creates a WebXRControllerTeleportation
  43849. * @param input input manager to add teleportation to
  43850. * @param floorMeshes floormeshes which can be teleported to
  43851. */
  43852. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43853. }
  43854. }
  43855. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43856. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43857. /**
  43858. * Handles pointer input automatically for the pointer of XR controllers
  43859. */
  43860. export class WebXRControllerPointerSelection {
  43861. private static _idCounter;
  43862. private _tmpRay;
  43863. /**
  43864. * Creates a WebXRControllerPointerSelection
  43865. * @param input input manager to setup pointer selection
  43866. */
  43867. constructor(input: WebXRInput);
  43868. private _convertNormalToDirectionOfRay;
  43869. private _updatePointerDistance;
  43870. }
  43871. }
  43872. declare module "babylonjs/Loading/sceneLoader" {
  43873. import { Observable } from "babylonjs/Misc/observable";
  43874. import { Nullable } from "babylonjs/types";
  43875. import { Scene } from "babylonjs/scene";
  43876. import { Engine } from "babylonjs/Engines/engine";
  43877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43878. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43879. import { AssetContainer } from "babylonjs/assetContainer";
  43880. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43881. import { Skeleton } from "babylonjs/Bones/skeleton";
  43882. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43883. import { WebRequest } from "babylonjs/Misc/webRequest";
  43884. /**
  43885. * Class used to represent data loading progression
  43886. */
  43887. export class SceneLoaderProgressEvent {
  43888. /** defines if data length to load can be evaluated */
  43889. readonly lengthComputable: boolean;
  43890. /** defines the loaded data length */
  43891. readonly loaded: number;
  43892. /** defines the data length to load */
  43893. readonly total: number;
  43894. /**
  43895. * Create a new progress event
  43896. * @param lengthComputable defines if data length to load can be evaluated
  43897. * @param loaded defines the loaded data length
  43898. * @param total defines the data length to load
  43899. */
  43900. constructor(
  43901. /** defines if data length to load can be evaluated */
  43902. lengthComputable: boolean,
  43903. /** defines the loaded data length */
  43904. loaded: number,
  43905. /** defines the data length to load */
  43906. total: number);
  43907. /**
  43908. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43909. * @param event defines the source event
  43910. * @returns a new SceneLoaderProgressEvent
  43911. */
  43912. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43913. }
  43914. /**
  43915. * Interface used by SceneLoader plugins to define supported file extensions
  43916. */
  43917. export interface ISceneLoaderPluginExtensions {
  43918. /**
  43919. * Defines the list of supported extensions
  43920. */
  43921. [extension: string]: {
  43922. isBinary: boolean;
  43923. };
  43924. }
  43925. /**
  43926. * Interface used by SceneLoader plugin factory
  43927. */
  43928. export interface ISceneLoaderPluginFactory {
  43929. /**
  43930. * Defines the name of the factory
  43931. */
  43932. name: string;
  43933. /**
  43934. * Function called to create a new plugin
  43935. * @return the new plugin
  43936. */
  43937. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43938. /**
  43939. * The callback that returns true if the data can be directly loaded.
  43940. * @param data string containing the file data
  43941. * @returns if the data can be loaded directly
  43942. */
  43943. canDirectLoad?(data: string): boolean;
  43944. }
  43945. /**
  43946. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43947. */
  43948. export interface ISceneLoaderPluginBase {
  43949. /**
  43950. * The friendly name of this plugin.
  43951. */
  43952. name: string;
  43953. /**
  43954. * The file extensions supported by this plugin.
  43955. */
  43956. extensions: string | ISceneLoaderPluginExtensions;
  43957. /**
  43958. * The callback called when loading from a url.
  43959. * @param scene scene loading this url
  43960. * @param url url to load
  43961. * @param onSuccess callback called when the file successfully loads
  43962. * @param onProgress callback called while file is loading (if the server supports this mode)
  43963. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43964. * @param onError callback called when the file fails to load
  43965. * @returns a file request object
  43966. */
  43967. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43968. /**
  43969. * The callback called when loading from a file object.
  43970. * @param scene scene loading this file
  43971. * @param file defines the file to load
  43972. * @param onSuccess defines the callback to call when data is loaded
  43973. * @param onProgress defines the callback to call during loading process
  43974. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43975. * @param onError defines the callback to call when an error occurs
  43976. * @returns a file request object
  43977. */
  43978. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43979. /**
  43980. * The callback that returns true if the data can be directly loaded.
  43981. * @param data string containing the file data
  43982. * @returns if the data can be loaded directly
  43983. */
  43984. canDirectLoad?(data: string): boolean;
  43985. /**
  43986. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43987. * @param scene scene loading this data
  43988. * @param data string containing the data
  43989. * @returns data to pass to the plugin
  43990. */
  43991. directLoad?(scene: Scene, data: string): any;
  43992. /**
  43993. * The callback that allows custom handling of the root url based on the response url.
  43994. * @param rootUrl the original root url
  43995. * @param responseURL the response url if available
  43996. * @returns the new root url
  43997. */
  43998. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43999. }
  44000. /**
  44001. * Interface used to define a SceneLoader plugin
  44002. */
  44003. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44004. /**
  44005. * Import meshes into a scene.
  44006. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44007. * @param scene The scene to import into
  44008. * @param data The data to import
  44009. * @param rootUrl The root url for scene and resources
  44010. * @param meshes The meshes array to import into
  44011. * @param particleSystems The particle systems array to import into
  44012. * @param skeletons The skeletons array to import into
  44013. * @param onError The callback when import fails
  44014. * @returns True if successful or false otherwise
  44015. */
  44016. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44017. /**
  44018. * Load into a scene.
  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 True if successful or false otherwise
  44024. */
  44025. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44026. /**
  44027. * Load into an asset container.
  44028. * @param scene The scene to load into
  44029. * @param data The data to import
  44030. * @param rootUrl The root url for scene and resources
  44031. * @param onError The callback when import fails
  44032. * @returns The loaded asset container
  44033. */
  44034. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44035. }
  44036. /**
  44037. * Interface used to define an async SceneLoader plugin
  44038. */
  44039. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44040. /**
  44041. * Import meshes into a scene.
  44042. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44043. * @param scene The scene to import into
  44044. * @param data The data to import
  44045. * @param rootUrl The root url for scene and resources
  44046. * @param onProgress The callback when the load progresses
  44047. * @param fileName Defines the name of the file to load
  44048. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44049. */
  44050. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44051. meshes: AbstractMesh[];
  44052. particleSystems: IParticleSystem[];
  44053. skeletons: Skeleton[];
  44054. animationGroups: AnimationGroup[];
  44055. }>;
  44056. /**
  44057. * Load into a scene.
  44058. * @param scene The scene to load into
  44059. * @param data The data to import
  44060. * @param rootUrl The root url for scene and resources
  44061. * @param onProgress The callback when the load progresses
  44062. * @param fileName Defines the name of the file to load
  44063. * @returns Nothing
  44064. */
  44065. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44066. /**
  44067. * Load into an asset container.
  44068. * @param scene The scene to load into
  44069. * @param data The data to import
  44070. * @param rootUrl The root url for scene and resources
  44071. * @param onProgress The callback when the load progresses
  44072. * @param fileName Defines the name of the file to load
  44073. * @returns The loaded asset container
  44074. */
  44075. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44076. }
  44077. /**
  44078. * Class used to load scene from various file formats using registered plugins
  44079. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44080. */
  44081. export class SceneLoader {
  44082. /**
  44083. * No logging while loading
  44084. */
  44085. static readonly NO_LOGGING: number;
  44086. /**
  44087. * Minimal logging while loading
  44088. */
  44089. static readonly MINIMAL_LOGGING: number;
  44090. /**
  44091. * Summary logging while loading
  44092. */
  44093. static readonly SUMMARY_LOGGING: number;
  44094. /**
  44095. * Detailled logging while loading
  44096. */
  44097. static readonly DETAILED_LOGGING: number;
  44098. /**
  44099. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44100. */
  44101. static ForceFullSceneLoadingForIncremental: boolean;
  44102. /**
  44103. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44104. */
  44105. static ShowLoadingScreen: boolean;
  44106. /**
  44107. * Defines the current logging level (while loading the scene)
  44108. * @ignorenaming
  44109. */
  44110. static loggingLevel: number;
  44111. /**
  44112. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44113. */
  44114. static CleanBoneMatrixWeights: boolean;
  44115. /**
  44116. * Event raised when a plugin is used to load a scene
  44117. */
  44118. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44119. private static _registeredPlugins;
  44120. private static _getDefaultPlugin;
  44121. private static _getPluginForExtension;
  44122. private static _getPluginForDirectLoad;
  44123. private static _getPluginForFilename;
  44124. private static _getDirectLoad;
  44125. private static _loadData;
  44126. private static _getFileInfo;
  44127. /**
  44128. * Gets a plugin that can load the given extension
  44129. * @param extension defines the extension to load
  44130. * @returns a plugin or null if none works
  44131. */
  44132. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44133. /**
  44134. * Gets a boolean indicating that the given extension can be loaded
  44135. * @param extension defines the extension to load
  44136. * @returns true if the extension is supported
  44137. */
  44138. static IsPluginForExtensionAvailable(extension: string): boolean;
  44139. /**
  44140. * Adds a new plugin to the list of registered plugins
  44141. * @param plugin defines the plugin to add
  44142. */
  44143. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44144. /**
  44145. * Import meshes into a scene
  44146. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44147. * @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)
  44148. * @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)
  44149. * @param scene the instance of BABYLON.Scene to append to
  44150. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44151. * @param onProgress a callback with a progress event for each file being loaded
  44152. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44153. * @param pluginExtension the extension used to determine the plugin
  44154. * @returns The loaded plugin
  44155. */
  44156. 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>;
  44157. /**
  44158. * Import meshes into a scene
  44159. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44160. * @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)
  44161. * @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)
  44162. * @param scene the instance of BABYLON.Scene to append to
  44163. * @param onProgress a callback with a progress event for each file being loaded
  44164. * @param pluginExtension the extension used to determine the plugin
  44165. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44166. */
  44167. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44168. meshes: AbstractMesh[];
  44169. particleSystems: IParticleSystem[];
  44170. skeletons: Skeleton[];
  44171. animationGroups: AnimationGroup[];
  44172. }>;
  44173. /**
  44174. * Load a scene
  44175. * @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)
  44176. * @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)
  44177. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44178. * @param onSuccess a callback with the scene when import succeeds
  44179. * @param onProgress a callback with a progress event for each file being loaded
  44180. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44181. * @param pluginExtension the extension used to determine the plugin
  44182. * @returns The loaded plugin
  44183. */
  44184. 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>;
  44185. /**
  44186. * Load a scene
  44187. * @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)
  44188. * @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)
  44189. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44190. * @param onProgress a callback with a progress event for each file being loaded
  44191. * @param pluginExtension the extension used to determine the plugin
  44192. * @returns The loaded scene
  44193. */
  44194. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44195. /**
  44196. * Append a scene
  44197. * @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)
  44198. * @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)
  44199. * @param scene is the instance of BABYLON.Scene to append to
  44200. * @param onSuccess a callback with the scene when import succeeds
  44201. * @param onProgress a callback with a progress event for each file being loaded
  44202. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44203. * @param pluginExtension the extension used to determine the plugin
  44204. * @returns The loaded plugin
  44205. */
  44206. 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>;
  44207. /**
  44208. * Append a scene
  44209. * @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)
  44210. * @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)
  44211. * @param scene is the instance of BABYLON.Scene to append to
  44212. * @param onProgress a callback with a progress event for each file being loaded
  44213. * @param pluginExtension the extension used to determine the plugin
  44214. * @returns The given scene
  44215. */
  44216. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44217. /**
  44218. * Load a scene into an asset container
  44219. * @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)
  44220. * @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)
  44221. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44222. * @param onSuccess a callback with the scene when import succeeds
  44223. * @param onProgress a callback with a progress event for each file being loaded
  44224. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44225. * @param pluginExtension the extension used to determine the plugin
  44226. * @returns The loaded plugin
  44227. */
  44228. 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>;
  44229. /**
  44230. * Load a scene into an asset container
  44231. * @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)
  44232. * @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)
  44233. * @param scene is the instance of Scene to append to
  44234. * @param onProgress a callback with a progress event for each file being loaded
  44235. * @param pluginExtension the extension used to determine the plugin
  44236. * @returns The loaded asset container
  44237. */
  44238. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44239. }
  44240. }
  44241. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44242. import { Scene } from "babylonjs/scene";
  44243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44244. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44245. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44246. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44247. /**
  44248. * Generic Controller
  44249. */
  44250. export class GenericController extends WebVRController {
  44251. /**
  44252. * Base Url for the controller model.
  44253. */
  44254. static readonly MODEL_BASE_URL: string;
  44255. /**
  44256. * File name for the controller model.
  44257. */
  44258. static readonly MODEL_FILENAME: string;
  44259. /**
  44260. * Creates a new GenericController from a gamepad
  44261. * @param vrGamepad the gamepad that the controller should be created from
  44262. */
  44263. constructor(vrGamepad: any);
  44264. /**
  44265. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44266. * @param scene scene in which to add meshes
  44267. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44268. */
  44269. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44270. /**
  44271. * Called once for each button that changed state since the last frame
  44272. * @param buttonIdx Which button index changed
  44273. * @param state New state of the button
  44274. * @param changes Which properties on the state changed since last frame
  44275. */
  44276. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44277. }
  44278. }
  44279. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44280. import { Observable } from "babylonjs/Misc/observable";
  44281. import { Scene } from "babylonjs/scene";
  44282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44283. import { Ray } from "babylonjs/Culling/ray";
  44284. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44285. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44286. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44287. /**
  44288. * Defines the WindowsMotionController object that the state of the windows motion controller
  44289. */
  44290. export class WindowsMotionController extends WebVRController {
  44291. /**
  44292. * The base url used to load the left and right controller models
  44293. */
  44294. static MODEL_BASE_URL: string;
  44295. /**
  44296. * The name of the left controller model file
  44297. */
  44298. static MODEL_LEFT_FILENAME: string;
  44299. /**
  44300. * The name of the right controller model file
  44301. */
  44302. static MODEL_RIGHT_FILENAME: string;
  44303. /**
  44304. * The controller name prefix for this controller type
  44305. */
  44306. static readonly GAMEPAD_ID_PREFIX: string;
  44307. /**
  44308. * The controller id pattern for this controller type
  44309. */
  44310. private static readonly GAMEPAD_ID_PATTERN;
  44311. private _loadedMeshInfo;
  44312. private readonly _mapping;
  44313. /**
  44314. * Fired when the trackpad on this controller is clicked
  44315. */
  44316. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44317. /**
  44318. * Fired when the trackpad on this controller is modified
  44319. */
  44320. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44321. /**
  44322. * The current x and y values of this controller's trackpad
  44323. */
  44324. trackpad: StickValues;
  44325. /**
  44326. * Creates a new WindowsMotionController from a gamepad
  44327. * @param vrGamepad the gamepad that the controller should be created from
  44328. */
  44329. constructor(vrGamepad: any);
  44330. /**
  44331. * Fired when the trigger on this controller is modified
  44332. */
  44333. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44334. /**
  44335. * Fired when the menu button on this controller is modified
  44336. */
  44337. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44338. /**
  44339. * Fired when the grip button on this controller is modified
  44340. */
  44341. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44342. /**
  44343. * Fired when the thumbstick button on this controller is modified
  44344. */
  44345. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44346. /**
  44347. * Fired when the touchpad button on this controller is modified
  44348. */
  44349. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44350. /**
  44351. * Fired when the touchpad values on this controller are modified
  44352. */
  44353. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44354. private _updateTrackpad;
  44355. /**
  44356. * Called once per frame by the engine.
  44357. */
  44358. update(): void;
  44359. /**
  44360. * Called once for each button that changed state since the last frame
  44361. * @param buttonIdx Which button index changed
  44362. * @param state New state of the button
  44363. * @param changes Which properties on the state changed since last frame
  44364. */
  44365. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44366. /**
  44367. * Moves the buttons on the controller mesh based on their current state
  44368. * @param buttonName the name of the button to move
  44369. * @param buttonValue the value of the button which determines the buttons new position
  44370. */
  44371. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44372. /**
  44373. * Moves the axis on the controller mesh based on its current state
  44374. * @param axis the index of the axis
  44375. * @param axisValue the value of the axis which determines the meshes new position
  44376. * @hidden
  44377. */
  44378. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44379. /**
  44380. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44381. * @param scene scene in which to add meshes
  44382. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44383. */
  44384. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44385. /**
  44386. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44387. * can be transformed by button presses and axes values, based on this._mapping.
  44388. *
  44389. * @param scene scene in which the meshes exist
  44390. * @param meshes list of meshes that make up the controller model to process
  44391. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44392. */
  44393. private processModel;
  44394. private createMeshInfo;
  44395. /**
  44396. * Gets the ray of the controller in the direction the controller is pointing
  44397. * @param length the length the resulting ray should be
  44398. * @returns a ray in the direction the controller is pointing
  44399. */
  44400. getForwardRay(length?: number): Ray;
  44401. /**
  44402. * Disposes of the controller
  44403. */
  44404. dispose(): void;
  44405. }
  44406. }
  44407. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44408. import { Observable } from "babylonjs/Misc/observable";
  44409. import { Scene } from "babylonjs/scene";
  44410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44411. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44412. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44413. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44414. /**
  44415. * Oculus Touch Controller
  44416. */
  44417. export class OculusTouchController extends WebVRController {
  44418. /**
  44419. * Base Url for the controller model.
  44420. */
  44421. static MODEL_BASE_URL: string;
  44422. /**
  44423. * File name for the left controller model.
  44424. */
  44425. static MODEL_LEFT_FILENAME: string;
  44426. /**
  44427. * File name for the right controller model.
  44428. */
  44429. static MODEL_RIGHT_FILENAME: string;
  44430. /**
  44431. * Base Url for the Quest controller model.
  44432. */
  44433. static QUEST_MODEL_BASE_URL: string;
  44434. /**
  44435. * @hidden
  44436. * If the controllers are running on a device that needs the updated Quest controller models
  44437. */
  44438. static _IsQuest: boolean;
  44439. /**
  44440. * Fired when the secondary trigger on this controller is modified
  44441. */
  44442. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44443. /**
  44444. * Fired when the thumb rest on this controller is modified
  44445. */
  44446. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44447. /**
  44448. * Creates a new OculusTouchController from a gamepad
  44449. * @param vrGamepad the gamepad that the controller should be created from
  44450. */
  44451. constructor(vrGamepad: any);
  44452. /**
  44453. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44454. * @param scene scene in which to add meshes
  44455. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44456. */
  44457. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44458. /**
  44459. * Fired when the A button on this controller is modified
  44460. */
  44461. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44462. /**
  44463. * Fired when the B button on this controller is modified
  44464. */
  44465. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44466. /**
  44467. * Fired when the X button on this controller is modified
  44468. */
  44469. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44470. /**
  44471. * Fired when the Y button on this controller is modified
  44472. */
  44473. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44474. /**
  44475. * Called once for each button that changed state since the last frame
  44476. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44477. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44478. * 2) secondary trigger (same)
  44479. * 3) A (right) X (left), touch, pressed = value
  44480. * 4) B / Y
  44481. * 5) thumb rest
  44482. * @param buttonIdx Which button index changed
  44483. * @param state New state of the button
  44484. * @param changes Which properties on the state changed since last frame
  44485. */
  44486. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44487. }
  44488. }
  44489. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44490. import { Scene } from "babylonjs/scene";
  44491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44492. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44493. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44494. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44495. import { Observable } from "babylonjs/Misc/observable";
  44496. /**
  44497. * Vive Controller
  44498. */
  44499. export class ViveController extends WebVRController {
  44500. /**
  44501. * Base Url for the controller model.
  44502. */
  44503. static MODEL_BASE_URL: string;
  44504. /**
  44505. * File name for the controller model.
  44506. */
  44507. static MODEL_FILENAME: string;
  44508. /**
  44509. * Creates a new ViveController from a gamepad
  44510. * @param vrGamepad the gamepad that the controller should be created from
  44511. */
  44512. constructor(vrGamepad: any);
  44513. /**
  44514. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44515. * @param scene scene in which to add meshes
  44516. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44517. */
  44518. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44519. /**
  44520. * Fired when the left button on this controller is modified
  44521. */
  44522. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44523. /**
  44524. * Fired when the right button on this controller is modified
  44525. */
  44526. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44527. /**
  44528. * Fired when the menu button on this controller is modified
  44529. */
  44530. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44531. /**
  44532. * Called once for each button that changed state since the last frame
  44533. * Vive mapping:
  44534. * 0: touchpad
  44535. * 1: trigger
  44536. * 2: left AND right buttons
  44537. * 3: menu button
  44538. * @param buttonIdx Which button index changed
  44539. * @param state New state of the button
  44540. * @param changes Which properties on the state changed since last frame
  44541. */
  44542. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44543. }
  44544. }
  44545. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44546. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44547. /**
  44548. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44549. */
  44550. export class WebXRControllerModelLoader {
  44551. /**
  44552. * Creates the WebXRControllerModelLoader
  44553. * @param input xr input that creates the controllers
  44554. */
  44555. constructor(input: WebXRInput);
  44556. }
  44557. }
  44558. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  44559. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44560. import { Scene } from "babylonjs/scene";
  44561. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44562. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44563. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44564. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44565. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44566. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  44567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44568. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44569. /**
  44570. * Options for the default xr helper
  44571. */
  44572. export class WebXRDefaultExperienceOptions {
  44573. /**
  44574. * Floor meshes that should be used for teleporting
  44575. */
  44576. floorMeshes: Array<AbstractMesh>;
  44577. /**
  44578. * Enable or disable default UI to enter XR
  44579. */
  44580. disableDefaultUI: boolean;
  44581. /**
  44582. * optional configuration for the output canvas
  44583. */
  44584. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44585. }
  44586. /**
  44587. * Default experience which provides a similar setup to the previous webVRExperience
  44588. */
  44589. export class WebXRDefaultExperience {
  44590. /**
  44591. * Base experience
  44592. */
  44593. baseExperience: WebXRExperienceHelper;
  44594. /**
  44595. * Input experience extension
  44596. */
  44597. input: WebXRInput;
  44598. /**
  44599. * Loads the controller models
  44600. */
  44601. controllerModelLoader: WebXRControllerModelLoader;
  44602. /**
  44603. * Enables laser pointer and selection
  44604. */
  44605. pointerSelection: WebXRControllerPointerSelection;
  44606. /**
  44607. * Enables teleportation
  44608. */
  44609. teleportation: WebXRControllerTeleportation;
  44610. /**
  44611. * Enables ui for enetering/exiting xr
  44612. */
  44613. enterExitUI: WebXREnterExitUI;
  44614. /**
  44615. * Default target xr should render to
  44616. */
  44617. renderTarget: WebXRRenderTarget;
  44618. /**
  44619. * Creates the default xr experience
  44620. * @param scene scene
  44621. * @param options options for basic configuration
  44622. * @returns resulting WebXRDefaultExperience
  44623. */
  44624. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44625. private constructor();
  44626. /**
  44627. * DIsposes of the experience helper
  44628. */
  44629. dispose(): void;
  44630. }
  44631. }
  44632. declare module "babylonjs/Cameras/XR/index" {
  44633. export * from "babylonjs/Cameras/XR/webXRCamera";
  44634. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44635. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44636. export * from "babylonjs/Cameras/XR/webXRInput";
  44637. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44638. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44639. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44640. export * from "babylonjs/Cameras/XR/webXRController";
  44641. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44642. export * from "babylonjs/Cameras/XR/webXRTypes";
  44643. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44644. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  44645. }
  44646. declare module "babylonjs/Cameras/RigModes/index" {
  44647. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44648. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44649. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44650. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44651. }
  44652. declare module "babylonjs/Cameras/index" {
  44653. export * from "babylonjs/Cameras/Inputs/index";
  44654. export * from "babylonjs/Cameras/cameraInputsManager";
  44655. export * from "babylonjs/Cameras/camera";
  44656. export * from "babylonjs/Cameras/targetCamera";
  44657. export * from "babylonjs/Cameras/freeCamera";
  44658. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44659. export * from "babylonjs/Cameras/touchCamera";
  44660. export * from "babylonjs/Cameras/arcRotateCamera";
  44661. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44662. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44663. export * from "babylonjs/Cameras/flyCamera";
  44664. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44665. export * from "babylonjs/Cameras/followCamera";
  44666. export * from "babylonjs/Cameras/followCameraInputsManager";
  44667. export * from "babylonjs/Cameras/gamepadCamera";
  44668. export * from "babylonjs/Cameras/Stereoscopic/index";
  44669. export * from "babylonjs/Cameras/universalCamera";
  44670. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44671. export * from "babylonjs/Cameras/VR/index";
  44672. export * from "babylonjs/Cameras/XR/index";
  44673. export * from "babylonjs/Cameras/RigModes/index";
  44674. }
  44675. declare module "babylonjs/Collisions/index" {
  44676. export * from "babylonjs/Collisions/collider";
  44677. export * from "babylonjs/Collisions/collisionCoordinator";
  44678. export * from "babylonjs/Collisions/pickingInfo";
  44679. export * from "babylonjs/Collisions/intersectionInfo";
  44680. export * from "babylonjs/Collisions/meshCollisionData";
  44681. }
  44682. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44683. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44684. import { Vector3 } from "babylonjs/Maths/math.vector";
  44685. import { Ray } from "babylonjs/Culling/ray";
  44686. import { Plane } from "babylonjs/Maths/math.plane";
  44687. /**
  44688. * Contains an array of blocks representing the octree
  44689. */
  44690. export interface IOctreeContainer<T> {
  44691. /**
  44692. * Blocks within the octree
  44693. */
  44694. blocks: Array<OctreeBlock<T>>;
  44695. }
  44696. /**
  44697. * Class used to store a cell in an octree
  44698. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44699. */
  44700. export class OctreeBlock<T> {
  44701. /**
  44702. * Gets the content of the current block
  44703. */
  44704. entries: T[];
  44705. /**
  44706. * Gets the list of block children
  44707. */
  44708. blocks: Array<OctreeBlock<T>>;
  44709. private _depth;
  44710. private _maxDepth;
  44711. private _capacity;
  44712. private _minPoint;
  44713. private _maxPoint;
  44714. private _boundingVectors;
  44715. private _creationFunc;
  44716. /**
  44717. * Creates a new block
  44718. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44719. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44720. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44721. * @param depth defines the current depth of this block in the octree
  44722. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44723. * @param creationFunc defines a callback to call when an element is added to the block
  44724. */
  44725. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44726. /**
  44727. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44728. */
  44729. readonly capacity: number;
  44730. /**
  44731. * Gets the minimum vector (in world space) of the block's bounding box
  44732. */
  44733. readonly minPoint: Vector3;
  44734. /**
  44735. * Gets the maximum vector (in world space) of the block's bounding box
  44736. */
  44737. readonly maxPoint: Vector3;
  44738. /**
  44739. * Add a new element to this block
  44740. * @param entry defines the element to add
  44741. */
  44742. addEntry(entry: T): void;
  44743. /**
  44744. * Remove an element from this block
  44745. * @param entry defines the element to remove
  44746. */
  44747. removeEntry(entry: T): void;
  44748. /**
  44749. * Add an array of elements to this block
  44750. * @param entries defines the array of elements to add
  44751. */
  44752. addEntries(entries: T[]): void;
  44753. /**
  44754. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44755. * @param frustumPlanes defines the frustum planes to test
  44756. * @param selection defines the array to store current content if selection is positive
  44757. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44758. */
  44759. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44760. /**
  44761. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44762. * @param sphereCenter defines the bounding sphere center
  44763. * @param sphereRadius defines the bounding sphere radius
  44764. * @param selection defines the array to store current content if selection is positive
  44765. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44766. */
  44767. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44768. /**
  44769. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44770. * @param ray defines the ray to test with
  44771. * @param selection defines the array to store current content if selection is positive
  44772. */
  44773. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44774. /**
  44775. * Subdivide the content into child blocks (this block will then be empty)
  44776. */
  44777. createInnerBlocks(): void;
  44778. /**
  44779. * @hidden
  44780. */
  44781. 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;
  44782. }
  44783. }
  44784. declare module "babylonjs/Culling/Octrees/octree" {
  44785. import { SmartArray } from "babylonjs/Misc/smartArray";
  44786. import { Vector3 } from "babylonjs/Maths/math.vector";
  44787. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44788. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44789. import { Ray } from "babylonjs/Culling/ray";
  44790. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44791. import { Plane } from "babylonjs/Maths/math.plane";
  44792. /**
  44793. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44794. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44795. */
  44796. export class Octree<T> {
  44797. /** 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.) */
  44798. maxDepth: number;
  44799. /**
  44800. * Blocks within the octree containing objects
  44801. */
  44802. blocks: Array<OctreeBlock<T>>;
  44803. /**
  44804. * Content stored in the octree
  44805. */
  44806. dynamicContent: T[];
  44807. private _maxBlockCapacity;
  44808. private _selectionContent;
  44809. private _creationFunc;
  44810. /**
  44811. * Creates a octree
  44812. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44813. * @param creationFunc function to be used to instatiate the octree
  44814. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44815. * @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.)
  44816. */
  44817. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44818. /** 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.) */
  44819. maxDepth?: number);
  44820. /**
  44821. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44822. * @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);
  44823. * @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);
  44824. * @param entries meshes to be added to the octree blocks
  44825. */
  44826. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44827. /**
  44828. * Adds a mesh to the octree
  44829. * @param entry Mesh to add to the octree
  44830. */
  44831. addMesh(entry: T): void;
  44832. /**
  44833. * Remove an element from the octree
  44834. * @param entry defines the element to remove
  44835. */
  44836. removeMesh(entry: T): void;
  44837. /**
  44838. * Selects an array of meshes within the frustum
  44839. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44840. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44841. * @returns array of meshes within the frustum
  44842. */
  44843. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44844. /**
  44845. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44846. * @param sphereCenter defines the bounding sphere center
  44847. * @param sphereRadius defines the bounding sphere radius
  44848. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44849. * @returns an array of objects that intersect the sphere
  44850. */
  44851. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44852. /**
  44853. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44854. * @param ray defines the ray to test with
  44855. * @returns array of intersected objects
  44856. */
  44857. intersectsRay(ray: Ray): SmartArray<T>;
  44858. /**
  44859. * Adds a mesh into the octree block if it intersects the block
  44860. */
  44861. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44862. /**
  44863. * Adds a submesh into the octree block if it intersects the block
  44864. */
  44865. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44866. }
  44867. }
  44868. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44869. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44870. import { Scene } from "babylonjs/scene";
  44871. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44873. import { Ray } from "babylonjs/Culling/ray";
  44874. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44875. import { Collider } from "babylonjs/Collisions/collider";
  44876. module "babylonjs/scene" {
  44877. interface Scene {
  44878. /**
  44879. * @hidden
  44880. * Backing Filed
  44881. */
  44882. _selectionOctree: Octree<AbstractMesh>;
  44883. /**
  44884. * Gets the octree used to boost mesh selection (picking)
  44885. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44886. */
  44887. selectionOctree: Octree<AbstractMesh>;
  44888. /**
  44889. * Creates or updates the octree used to boost selection (picking)
  44890. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44891. * @param maxCapacity defines the maximum capacity per leaf
  44892. * @param maxDepth defines the maximum depth of the octree
  44893. * @returns an octree of AbstractMesh
  44894. */
  44895. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44896. }
  44897. }
  44898. module "babylonjs/Meshes/abstractMesh" {
  44899. interface AbstractMesh {
  44900. /**
  44901. * @hidden
  44902. * Backing Field
  44903. */
  44904. _submeshesOctree: Octree<SubMesh>;
  44905. /**
  44906. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44907. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44908. * @param maxCapacity defines the maximum size of each block (64 by default)
  44909. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44910. * @returns the new octree
  44911. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44912. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44913. */
  44914. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44915. }
  44916. }
  44917. /**
  44918. * Defines the octree scene component responsible to manage any octrees
  44919. * in a given scene.
  44920. */
  44921. export class OctreeSceneComponent {
  44922. /**
  44923. * The component name help to identify the component in the list of scene components.
  44924. */
  44925. readonly name: string;
  44926. /**
  44927. * The scene the component belongs to.
  44928. */
  44929. scene: Scene;
  44930. /**
  44931. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44932. */
  44933. readonly checksIsEnabled: boolean;
  44934. /**
  44935. * Creates a new instance of the component for the given scene
  44936. * @param scene Defines the scene to register the component in
  44937. */
  44938. constructor(scene: Scene);
  44939. /**
  44940. * Registers the component in a given scene
  44941. */
  44942. register(): void;
  44943. /**
  44944. * Return the list of active meshes
  44945. * @returns the list of active meshes
  44946. */
  44947. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44948. /**
  44949. * Return the list of active sub meshes
  44950. * @param mesh The mesh to get the candidates sub meshes from
  44951. * @returns the list of active sub meshes
  44952. */
  44953. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44954. private _tempRay;
  44955. /**
  44956. * Return the list of sub meshes intersecting with a given local ray
  44957. * @param mesh defines the mesh to find the submesh for
  44958. * @param localRay defines the ray in local space
  44959. * @returns the list of intersecting sub meshes
  44960. */
  44961. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44962. /**
  44963. * Return the list of sub meshes colliding with a collider
  44964. * @param mesh defines the mesh to find the submesh for
  44965. * @param collider defines the collider to evaluate the collision against
  44966. * @returns the list of colliding sub meshes
  44967. */
  44968. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44969. /**
  44970. * Rebuilds the elements related to this component in case of
  44971. * context lost for instance.
  44972. */
  44973. rebuild(): void;
  44974. /**
  44975. * Disposes the component and the associated ressources.
  44976. */
  44977. dispose(): void;
  44978. }
  44979. }
  44980. declare module "babylonjs/Culling/Octrees/index" {
  44981. export * from "babylonjs/Culling/Octrees/octree";
  44982. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44983. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44984. }
  44985. declare module "babylonjs/Culling/index" {
  44986. export * from "babylonjs/Culling/boundingBox";
  44987. export * from "babylonjs/Culling/boundingInfo";
  44988. export * from "babylonjs/Culling/boundingSphere";
  44989. export * from "babylonjs/Culling/Octrees/index";
  44990. export * from "babylonjs/Culling/ray";
  44991. }
  44992. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44993. import { IDisposable, Scene } from "babylonjs/scene";
  44994. import { Nullable } from "babylonjs/types";
  44995. import { Observable } from "babylonjs/Misc/observable";
  44996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44997. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44998. import { Camera } from "babylonjs/Cameras/camera";
  44999. /**
  45000. * Renders a layer on top of an existing scene
  45001. */
  45002. export class UtilityLayerRenderer implements IDisposable {
  45003. /** the original scene that will be rendered on top of */
  45004. originalScene: Scene;
  45005. private _pointerCaptures;
  45006. private _lastPointerEvents;
  45007. private static _DefaultUtilityLayer;
  45008. private static _DefaultKeepDepthUtilityLayer;
  45009. private _sharedGizmoLight;
  45010. private _renderCamera;
  45011. /**
  45012. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45013. * @returns the camera that is used when rendering the utility layer
  45014. */
  45015. getRenderCamera(): Nullable<Camera>;
  45016. /**
  45017. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45018. * @param cam the camera that should be used when rendering the utility layer
  45019. */
  45020. setRenderCamera(cam: Nullable<Camera>): void;
  45021. /**
  45022. * @hidden
  45023. * Light which used by gizmos to get light shading
  45024. */
  45025. _getSharedGizmoLight(): HemisphericLight;
  45026. /**
  45027. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45028. */
  45029. pickUtilitySceneFirst: boolean;
  45030. /**
  45031. * 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)
  45032. */
  45033. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  45034. /**
  45035. * 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)
  45036. */
  45037. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  45038. /**
  45039. * The scene that is rendered on top of the original scene
  45040. */
  45041. utilityLayerScene: Scene;
  45042. /**
  45043. * If the utility layer should automatically be rendered on top of existing scene
  45044. */
  45045. shouldRender: boolean;
  45046. /**
  45047. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45048. */
  45049. onlyCheckPointerDownEvents: boolean;
  45050. /**
  45051. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45052. */
  45053. processAllEvents: boolean;
  45054. /**
  45055. * Observable raised when the pointer move from the utility layer scene to the main scene
  45056. */
  45057. onPointerOutObservable: Observable<number>;
  45058. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45059. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45060. private _afterRenderObserver;
  45061. private _sceneDisposeObserver;
  45062. private _originalPointerObserver;
  45063. /**
  45064. * Instantiates a UtilityLayerRenderer
  45065. * @param originalScene the original scene that will be rendered on top of
  45066. * @param handleEvents boolean indicating if the utility layer should handle events
  45067. */
  45068. constructor(
  45069. /** the original scene that will be rendered on top of */
  45070. originalScene: Scene, handleEvents?: boolean);
  45071. private _notifyObservers;
  45072. /**
  45073. * Renders the utility layers scene on top of the original scene
  45074. */
  45075. render(): void;
  45076. /**
  45077. * Disposes of the renderer
  45078. */
  45079. dispose(): void;
  45080. private _updateCamera;
  45081. }
  45082. }
  45083. declare module "babylonjs/Gizmos/gizmo" {
  45084. import { Nullable } from "babylonjs/types";
  45085. import { IDisposable } from "babylonjs/scene";
  45086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45087. import { Mesh } from "babylonjs/Meshes/mesh";
  45088. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45089. /**
  45090. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45091. */
  45092. export class Gizmo implements IDisposable {
  45093. /** The utility layer the gizmo will be added to */
  45094. gizmoLayer: UtilityLayerRenderer;
  45095. /**
  45096. * The root mesh of the gizmo
  45097. */
  45098. _rootMesh: Mesh;
  45099. private _attachedMesh;
  45100. /**
  45101. * Ratio for the scale of the gizmo (Default: 1)
  45102. */
  45103. scaleRatio: number;
  45104. /**
  45105. * If a custom mesh has been set (Default: false)
  45106. */
  45107. protected _customMeshSet: boolean;
  45108. /**
  45109. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45110. * * When set, interactions will be enabled
  45111. */
  45112. attachedMesh: Nullable<AbstractMesh>;
  45113. /**
  45114. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45115. * @param mesh The mesh to replace the default mesh of the gizmo
  45116. */
  45117. setCustomMesh(mesh: Mesh): void;
  45118. /**
  45119. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45120. */
  45121. updateGizmoRotationToMatchAttachedMesh: boolean;
  45122. /**
  45123. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45124. */
  45125. updateGizmoPositionToMatchAttachedMesh: boolean;
  45126. /**
  45127. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45128. */
  45129. updateScale: boolean;
  45130. protected _interactionsEnabled: boolean;
  45131. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45132. private _beforeRenderObserver;
  45133. private _tempVector;
  45134. /**
  45135. * Creates a gizmo
  45136. * @param gizmoLayer The utility layer the gizmo will be added to
  45137. */
  45138. constructor(
  45139. /** The utility layer the gizmo will be added to */
  45140. gizmoLayer?: UtilityLayerRenderer);
  45141. /**
  45142. * Updates the gizmo to match the attached mesh's position/rotation
  45143. */
  45144. protected _update(): void;
  45145. /**
  45146. * Disposes of the gizmo
  45147. */
  45148. dispose(): void;
  45149. }
  45150. }
  45151. declare module "babylonjs/Gizmos/planeDragGizmo" {
  45152. import { Observable } from "babylonjs/Misc/observable";
  45153. import { Nullable } from "babylonjs/types";
  45154. import { Vector3 } from "babylonjs/Maths/math.vector";
  45155. import { Color3 } from "babylonjs/Maths/math.color";
  45156. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45158. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45159. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45160. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45161. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45162. import { Scene } from "babylonjs/scene";
  45163. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45164. /**
  45165. * Single plane drag gizmo
  45166. */
  45167. export class PlaneDragGizmo extends Gizmo {
  45168. /**
  45169. * Drag behavior responsible for the gizmos dragging interactions
  45170. */
  45171. dragBehavior: PointerDragBehavior;
  45172. private _pointerObserver;
  45173. /**
  45174. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45175. */
  45176. snapDistance: number;
  45177. /**
  45178. * Event that fires each time the gizmo snaps to a new location.
  45179. * * snapDistance is the the change in distance
  45180. */
  45181. onSnapObservable: Observable<{
  45182. snapDistance: number;
  45183. }>;
  45184. private _plane;
  45185. private _coloredMaterial;
  45186. private _hoverMaterial;
  45187. private _isEnabled;
  45188. private _parent;
  45189. /** @hidden */
  45190. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45191. /** @hidden */
  45192. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45193. /**
  45194. * Creates a PlaneDragGizmo
  45195. * @param gizmoLayer The utility layer the gizmo will be added to
  45196. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45197. * @param color The color of the gizmo
  45198. */
  45199. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45200. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45201. /**
  45202. * If the gizmo is enabled
  45203. */
  45204. isEnabled: boolean;
  45205. /**
  45206. * Disposes of the gizmo
  45207. */
  45208. dispose(): void;
  45209. }
  45210. }
  45211. declare module "babylonjs/Gizmos/positionGizmo" {
  45212. import { Observable } from "babylonjs/Misc/observable";
  45213. import { Nullable } from "babylonjs/types";
  45214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45215. import { Mesh } from "babylonjs/Meshes/mesh";
  45216. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45217. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  45218. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  45219. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45220. /**
  45221. * Gizmo that enables dragging a mesh along 3 axis
  45222. */
  45223. export class PositionGizmo extends Gizmo {
  45224. /**
  45225. * Internal gizmo used for interactions on the x axis
  45226. */
  45227. xGizmo: AxisDragGizmo;
  45228. /**
  45229. * Internal gizmo used for interactions on the y axis
  45230. */
  45231. yGizmo: AxisDragGizmo;
  45232. /**
  45233. * Internal gizmo used for interactions on the z axis
  45234. */
  45235. zGizmo: AxisDragGizmo;
  45236. /**
  45237. * Internal gizmo used for interactions on the yz plane
  45238. */
  45239. xPlaneGizmo: PlaneDragGizmo;
  45240. /**
  45241. * Internal gizmo used for interactions on the xz plane
  45242. */
  45243. yPlaneGizmo: PlaneDragGizmo;
  45244. /**
  45245. * Internal gizmo used for interactions on the xy plane
  45246. */
  45247. zPlaneGizmo: PlaneDragGizmo;
  45248. /**
  45249. * private variables
  45250. */
  45251. private _meshAttached;
  45252. private _updateGizmoRotationToMatchAttachedMesh;
  45253. private _snapDistance;
  45254. private _scaleRatio;
  45255. /** Fires an event when any of it's sub gizmos are dragged */
  45256. onDragStartObservable: Observable<unknown>;
  45257. /** Fires an event when any of it's sub gizmos are released from dragging */
  45258. onDragEndObservable: Observable<unknown>;
  45259. /**
  45260. * If set to true, planar drag is enabled
  45261. */
  45262. private _planarGizmoEnabled;
  45263. attachedMesh: Nullable<AbstractMesh>;
  45264. /**
  45265. * Creates a PositionGizmo
  45266. * @param gizmoLayer The utility layer the gizmo will be added to
  45267. */
  45268. constructor(gizmoLayer?: UtilityLayerRenderer);
  45269. /**
  45270. * If the planar drag gizmo is enabled
  45271. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45272. */
  45273. planarGizmoEnabled: boolean;
  45274. updateGizmoRotationToMatchAttachedMesh: boolean;
  45275. /**
  45276. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45277. */
  45278. snapDistance: number;
  45279. /**
  45280. * Ratio for the scale of the gizmo (Default: 1)
  45281. */
  45282. scaleRatio: number;
  45283. /**
  45284. * Disposes of the gizmo
  45285. */
  45286. dispose(): void;
  45287. /**
  45288. * CustomMeshes are not supported by this gizmo
  45289. * @param mesh The mesh to replace the default mesh of the gizmo
  45290. */
  45291. setCustomMesh(mesh: Mesh): void;
  45292. }
  45293. }
  45294. declare module "babylonjs/Gizmos/axisDragGizmo" {
  45295. import { Observable } from "babylonjs/Misc/observable";
  45296. import { Nullable } from "babylonjs/types";
  45297. import { Vector3 } from "babylonjs/Maths/math.vector";
  45298. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45300. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45301. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45302. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45303. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45304. import { Scene } from "babylonjs/scene";
  45305. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45306. import { Color3 } from "babylonjs/Maths/math.color";
  45307. /**
  45308. * Single axis drag gizmo
  45309. */
  45310. export class AxisDragGizmo extends Gizmo {
  45311. /**
  45312. * Drag behavior responsible for the gizmos dragging interactions
  45313. */
  45314. dragBehavior: PointerDragBehavior;
  45315. private _pointerObserver;
  45316. /**
  45317. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45318. */
  45319. snapDistance: number;
  45320. /**
  45321. * Event that fires each time the gizmo snaps to a new location.
  45322. * * snapDistance is the the change in distance
  45323. */
  45324. onSnapObservable: Observable<{
  45325. snapDistance: number;
  45326. }>;
  45327. private _isEnabled;
  45328. private _parent;
  45329. private _arrow;
  45330. private _coloredMaterial;
  45331. private _hoverMaterial;
  45332. /** @hidden */
  45333. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45334. /** @hidden */
  45335. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45336. /**
  45337. * Creates an AxisDragGizmo
  45338. * @param gizmoLayer The utility layer the gizmo will be added to
  45339. * @param dragAxis The axis which the gizmo will be able to drag on
  45340. * @param color The color of the gizmo
  45341. */
  45342. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45343. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45344. /**
  45345. * If the gizmo is enabled
  45346. */
  45347. isEnabled: boolean;
  45348. /**
  45349. * Disposes of the gizmo
  45350. */
  45351. dispose(): void;
  45352. }
  45353. }
  45354. declare module "babylonjs/Debug/axesViewer" {
  45355. import { Vector3 } from "babylonjs/Maths/math.vector";
  45356. import { Nullable } from "babylonjs/types";
  45357. import { Scene } from "babylonjs/scene";
  45358. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45359. /**
  45360. * The Axes viewer will show 3 axes in a specific point in space
  45361. */
  45362. export class AxesViewer {
  45363. private _xAxis;
  45364. private _yAxis;
  45365. private _zAxis;
  45366. private _scaleLinesFactor;
  45367. private _instanced;
  45368. /**
  45369. * Gets the hosting scene
  45370. */
  45371. scene: Scene;
  45372. /**
  45373. * Gets or sets a number used to scale line length
  45374. */
  45375. scaleLines: number;
  45376. /** Gets the node hierarchy used to render x-axis */
  45377. readonly xAxis: TransformNode;
  45378. /** Gets the node hierarchy used to render y-axis */
  45379. readonly yAxis: TransformNode;
  45380. /** Gets the node hierarchy used to render z-axis */
  45381. readonly zAxis: TransformNode;
  45382. /**
  45383. * Creates a new AxesViewer
  45384. * @param scene defines the hosting scene
  45385. * @param scaleLines defines a number used to scale line length (1 by default)
  45386. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45387. * @param xAxis defines the node hierarchy used to render the x-axis
  45388. * @param yAxis defines the node hierarchy used to render the y-axis
  45389. * @param zAxis defines the node hierarchy used to render the z-axis
  45390. */
  45391. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45392. /**
  45393. * Force the viewer to update
  45394. * @param position defines the position of the viewer
  45395. * @param xaxis defines the x axis of the viewer
  45396. * @param yaxis defines the y axis of the viewer
  45397. * @param zaxis defines the z axis of the viewer
  45398. */
  45399. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45400. /**
  45401. * Creates an instance of this axes viewer.
  45402. * @returns a new axes viewer with instanced meshes
  45403. */
  45404. createInstance(): AxesViewer;
  45405. /** Releases resources */
  45406. dispose(): void;
  45407. private static _SetRenderingGroupId;
  45408. }
  45409. }
  45410. declare module "babylonjs/Debug/boneAxesViewer" {
  45411. import { Nullable } from "babylonjs/types";
  45412. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  45413. import { Vector3 } from "babylonjs/Maths/math.vector";
  45414. import { Mesh } from "babylonjs/Meshes/mesh";
  45415. import { Bone } from "babylonjs/Bones/bone";
  45416. import { Scene } from "babylonjs/scene";
  45417. /**
  45418. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45419. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45420. */
  45421. export class BoneAxesViewer extends AxesViewer {
  45422. /**
  45423. * Gets or sets the target mesh where to display the axes viewer
  45424. */
  45425. mesh: Nullable<Mesh>;
  45426. /**
  45427. * Gets or sets the target bone where to display the axes viewer
  45428. */
  45429. bone: Nullable<Bone>;
  45430. /** Gets current position */
  45431. pos: Vector3;
  45432. /** Gets direction of X axis */
  45433. xaxis: Vector3;
  45434. /** Gets direction of Y axis */
  45435. yaxis: Vector3;
  45436. /** Gets direction of Z axis */
  45437. zaxis: Vector3;
  45438. /**
  45439. * Creates a new BoneAxesViewer
  45440. * @param scene defines the hosting scene
  45441. * @param bone defines the target bone
  45442. * @param mesh defines the target mesh
  45443. * @param scaleLines defines a scaling factor for line length (1 by default)
  45444. */
  45445. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45446. /**
  45447. * Force the viewer to update
  45448. */
  45449. update(): void;
  45450. /** Releases resources */
  45451. dispose(): void;
  45452. }
  45453. }
  45454. declare module "babylonjs/Debug/debugLayer" {
  45455. import { Scene } from "babylonjs/scene";
  45456. /**
  45457. * Interface used to define scene explorer extensibility option
  45458. */
  45459. export interface IExplorerExtensibilityOption {
  45460. /**
  45461. * Define the option label
  45462. */
  45463. label: string;
  45464. /**
  45465. * Defines the action to execute on click
  45466. */
  45467. action: (entity: any) => void;
  45468. }
  45469. /**
  45470. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45471. */
  45472. export interface IExplorerExtensibilityGroup {
  45473. /**
  45474. * Defines a predicate to test if a given type mut be extended
  45475. */
  45476. predicate: (entity: any) => boolean;
  45477. /**
  45478. * Gets the list of options added to a type
  45479. */
  45480. entries: IExplorerExtensibilityOption[];
  45481. }
  45482. /**
  45483. * Interface used to define the options to use to create the Inspector
  45484. */
  45485. export interface IInspectorOptions {
  45486. /**
  45487. * Display in overlay mode (default: false)
  45488. */
  45489. overlay?: boolean;
  45490. /**
  45491. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45492. */
  45493. globalRoot?: HTMLElement;
  45494. /**
  45495. * Display the Scene explorer
  45496. */
  45497. showExplorer?: boolean;
  45498. /**
  45499. * Display the property inspector
  45500. */
  45501. showInspector?: boolean;
  45502. /**
  45503. * Display in embed mode (both panes on the right)
  45504. */
  45505. embedMode?: boolean;
  45506. /**
  45507. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45508. */
  45509. handleResize?: boolean;
  45510. /**
  45511. * Allow the panes to popup (default: true)
  45512. */
  45513. enablePopup?: boolean;
  45514. /**
  45515. * Allow the panes to be closed by users (default: true)
  45516. */
  45517. enableClose?: boolean;
  45518. /**
  45519. * Optional list of extensibility entries
  45520. */
  45521. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45522. /**
  45523. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45524. */
  45525. inspectorURL?: string;
  45526. }
  45527. module "babylonjs/scene" {
  45528. interface Scene {
  45529. /**
  45530. * @hidden
  45531. * Backing field
  45532. */
  45533. _debugLayer: DebugLayer;
  45534. /**
  45535. * Gets the debug layer (aka Inspector) associated with the scene
  45536. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45537. */
  45538. debugLayer: DebugLayer;
  45539. }
  45540. }
  45541. /**
  45542. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45543. * what is happening in your scene
  45544. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45545. */
  45546. export class DebugLayer {
  45547. /**
  45548. * Define the url to get the inspector script from.
  45549. * By default it uses the babylonjs CDN.
  45550. * @ignoreNaming
  45551. */
  45552. static InspectorURL: string;
  45553. private _scene;
  45554. private BJSINSPECTOR;
  45555. private _onPropertyChangedObservable?;
  45556. /**
  45557. * Observable triggered when a property is changed through the inspector.
  45558. */
  45559. readonly onPropertyChangedObservable: any;
  45560. /**
  45561. * Instantiates a new debug layer.
  45562. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45563. * what is happening in your scene
  45564. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45565. * @param scene Defines the scene to inspect
  45566. */
  45567. constructor(scene: Scene);
  45568. /** Creates the inspector window. */
  45569. private _createInspector;
  45570. /**
  45571. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45572. * @param entity defines the entity to select
  45573. * @param lineContainerTitle defines the specific block to highlight
  45574. */
  45575. select(entity: any, lineContainerTitle?: string): void;
  45576. /** Get the inspector from bundle or global */
  45577. private _getGlobalInspector;
  45578. /**
  45579. * Get if the inspector is visible or not.
  45580. * @returns true if visible otherwise, false
  45581. */
  45582. isVisible(): boolean;
  45583. /**
  45584. * Hide the inspector and close its window.
  45585. */
  45586. hide(): void;
  45587. /**
  45588. * Launch the debugLayer.
  45589. * @param config Define the configuration of the inspector
  45590. * @return a promise fulfilled when the debug layer is visible
  45591. */
  45592. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45593. }
  45594. }
  45595. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45596. import { Nullable } from "babylonjs/types";
  45597. import { Scene } from "babylonjs/scene";
  45598. import { Vector4 } from "babylonjs/Maths/math.vector";
  45599. import { Color4 } from "babylonjs/Maths/math.color";
  45600. import { Mesh } from "babylonjs/Meshes/mesh";
  45601. /**
  45602. * Class containing static functions to help procedurally build meshes
  45603. */
  45604. export class BoxBuilder {
  45605. /**
  45606. * Creates a box mesh
  45607. * * The parameter `size` sets the size (float) of each box side (default 1)
  45608. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45609. * * 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)
  45610. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45612. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45614. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45615. * @param name defines the name of the mesh
  45616. * @param options defines the options used to create the mesh
  45617. * @param scene defines the hosting scene
  45618. * @returns the box mesh
  45619. */
  45620. static CreateBox(name: string, options: {
  45621. size?: number;
  45622. width?: number;
  45623. height?: number;
  45624. depth?: number;
  45625. faceUV?: Vector4[];
  45626. faceColors?: Color4[];
  45627. sideOrientation?: number;
  45628. frontUVs?: Vector4;
  45629. backUVs?: Vector4;
  45630. wrap?: boolean;
  45631. topBaseAt?: number;
  45632. bottomBaseAt?: number;
  45633. updatable?: boolean;
  45634. }, scene?: Nullable<Scene>): Mesh;
  45635. }
  45636. }
  45637. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45638. import { Vector4 } from "babylonjs/Maths/math.vector";
  45639. import { Mesh } from "babylonjs/Meshes/mesh";
  45640. import { Scene } from "babylonjs/scene";
  45641. import { Nullable } from "babylonjs/types";
  45642. /**
  45643. * Class containing static functions to help procedurally build meshes
  45644. */
  45645. export class SphereBuilder {
  45646. /**
  45647. * Creates a sphere mesh
  45648. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45649. * * 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`)
  45650. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45651. * * 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
  45652. * * 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)
  45653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45654. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45656. * @param name defines the name of the mesh
  45657. * @param options defines the options used to create the mesh
  45658. * @param scene defines the hosting scene
  45659. * @returns the sphere mesh
  45660. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45661. */
  45662. static CreateSphere(name: string, options: {
  45663. segments?: number;
  45664. diameter?: number;
  45665. diameterX?: number;
  45666. diameterY?: number;
  45667. diameterZ?: number;
  45668. arc?: number;
  45669. slice?: number;
  45670. sideOrientation?: number;
  45671. frontUVs?: Vector4;
  45672. backUVs?: Vector4;
  45673. updatable?: boolean;
  45674. }, scene?: Nullable<Scene>): Mesh;
  45675. }
  45676. }
  45677. declare module "babylonjs/Debug/physicsViewer" {
  45678. import { Nullable } from "babylonjs/types";
  45679. import { Scene } from "babylonjs/scene";
  45680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45681. import { Mesh } from "babylonjs/Meshes/mesh";
  45682. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45683. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45684. /**
  45685. * Used to show the physics impostor around the specific mesh
  45686. */
  45687. export class PhysicsViewer {
  45688. /** @hidden */
  45689. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45690. /** @hidden */
  45691. protected _meshes: Array<Nullable<AbstractMesh>>;
  45692. /** @hidden */
  45693. protected _scene: Nullable<Scene>;
  45694. /** @hidden */
  45695. protected _numMeshes: number;
  45696. /** @hidden */
  45697. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45698. private _renderFunction;
  45699. private _utilityLayer;
  45700. private _debugBoxMesh;
  45701. private _debugSphereMesh;
  45702. private _debugCylinderMesh;
  45703. private _debugMaterial;
  45704. private _debugMeshMeshes;
  45705. /**
  45706. * Creates a new PhysicsViewer
  45707. * @param scene defines the hosting scene
  45708. */
  45709. constructor(scene: Scene);
  45710. /** @hidden */
  45711. protected _updateDebugMeshes(): void;
  45712. /**
  45713. * Renders a specified physic impostor
  45714. * @param impostor defines the impostor to render
  45715. * @param targetMesh defines the mesh represented by the impostor
  45716. * @returns the new debug mesh used to render the impostor
  45717. */
  45718. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45719. /**
  45720. * Hides a specified physic impostor
  45721. * @param impostor defines the impostor to hide
  45722. */
  45723. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45724. private _getDebugMaterial;
  45725. private _getDebugBoxMesh;
  45726. private _getDebugSphereMesh;
  45727. private _getDebugCylinderMesh;
  45728. private _getDebugMeshMesh;
  45729. private _getDebugMesh;
  45730. /** Releases all resources */
  45731. dispose(): void;
  45732. }
  45733. }
  45734. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45735. import { Vector3 } from "babylonjs/Maths/math.vector";
  45736. import { Color4 } from "babylonjs/Maths/math.color";
  45737. import { Nullable } from "babylonjs/types";
  45738. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45739. import { Scene } from "babylonjs/scene";
  45740. /**
  45741. * Class containing static functions to help procedurally build meshes
  45742. */
  45743. export class LinesBuilder {
  45744. /**
  45745. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45746. * * 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
  45747. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45748. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45749. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45750. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45751. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45752. * * 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
  45753. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45755. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45756. * @param name defines the name of the new line system
  45757. * @param options defines the options used to create the line system
  45758. * @param scene defines the hosting scene
  45759. * @returns a new line system mesh
  45760. */
  45761. static CreateLineSystem(name: string, options: {
  45762. lines: Vector3[][];
  45763. updatable?: boolean;
  45764. instance?: Nullable<LinesMesh>;
  45765. colors?: Nullable<Color4[][]>;
  45766. useVertexAlpha?: boolean;
  45767. }, scene: Nullable<Scene>): LinesMesh;
  45768. /**
  45769. * Creates a line mesh
  45770. * 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
  45771. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45772. * * The parameter `points` is an array successive Vector3
  45773. * * 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
  45774. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45775. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45776. * * When updating an instance, remember that only point positions can change, not the number of points
  45777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45778. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45779. * @param name defines the name of the new line system
  45780. * @param options defines the options used to create the line system
  45781. * @param scene defines the hosting scene
  45782. * @returns a new line mesh
  45783. */
  45784. static CreateLines(name: string, options: {
  45785. points: Vector3[];
  45786. updatable?: boolean;
  45787. instance?: Nullable<LinesMesh>;
  45788. colors?: Color4[];
  45789. useVertexAlpha?: boolean;
  45790. }, scene?: Nullable<Scene>): LinesMesh;
  45791. /**
  45792. * Creates a dashed line mesh
  45793. * * 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
  45794. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45795. * * The parameter `points` is an array successive Vector3
  45796. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45797. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45798. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45799. * * 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
  45800. * * When updating an instance, remember that only point positions can change, not the number of points
  45801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45802. * @param name defines the name of the mesh
  45803. * @param options defines the options used to create the mesh
  45804. * @param scene defines the hosting scene
  45805. * @returns the dashed line mesh
  45806. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45807. */
  45808. static CreateDashedLines(name: string, options: {
  45809. points: Vector3[];
  45810. dashSize?: number;
  45811. gapSize?: number;
  45812. dashNb?: number;
  45813. updatable?: boolean;
  45814. instance?: LinesMesh;
  45815. }, scene?: Nullable<Scene>): LinesMesh;
  45816. }
  45817. }
  45818. declare module "babylonjs/Debug/rayHelper" {
  45819. import { Nullable } from "babylonjs/types";
  45820. import { Ray } from "babylonjs/Culling/ray";
  45821. import { Vector3 } from "babylonjs/Maths/math.vector";
  45822. import { Color3 } from "babylonjs/Maths/math.color";
  45823. import { Scene } from "babylonjs/scene";
  45824. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45825. import "babylonjs/Meshes/Builders/linesBuilder";
  45826. /**
  45827. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45828. * in order to better appreciate the issue one might have.
  45829. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45830. */
  45831. export class RayHelper {
  45832. /**
  45833. * Defines the ray we are currently tryin to visualize.
  45834. */
  45835. ray: Nullable<Ray>;
  45836. private _renderPoints;
  45837. private _renderLine;
  45838. private _renderFunction;
  45839. private _scene;
  45840. private _updateToMeshFunction;
  45841. private _attachedToMesh;
  45842. private _meshSpaceDirection;
  45843. private _meshSpaceOrigin;
  45844. /**
  45845. * Helper function to create a colored helper in a scene in one line.
  45846. * @param ray Defines the ray we are currently tryin to visualize
  45847. * @param scene Defines the scene the ray is used in
  45848. * @param color Defines the color we want to see the ray in
  45849. * @returns The newly created ray helper.
  45850. */
  45851. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45852. /**
  45853. * Instantiate a new ray helper.
  45854. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45855. * in order to better appreciate the issue one might have.
  45856. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45857. * @param ray Defines the ray we are currently tryin to visualize
  45858. */
  45859. constructor(ray: Ray);
  45860. /**
  45861. * Shows the ray we are willing to debug.
  45862. * @param scene Defines the scene the ray needs to be rendered in
  45863. * @param color Defines the color the ray needs to be rendered in
  45864. */
  45865. show(scene: Scene, color?: Color3): void;
  45866. /**
  45867. * Hides the ray we are debugging.
  45868. */
  45869. hide(): void;
  45870. private _render;
  45871. /**
  45872. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45873. * @param mesh Defines the mesh we want the helper attached to
  45874. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45875. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45876. * @param length Defines the length of the ray
  45877. */
  45878. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45879. /**
  45880. * Detach the ray helper from the mesh it has previously been attached to.
  45881. */
  45882. detachFromMesh(): void;
  45883. private _updateToMesh;
  45884. /**
  45885. * Dispose the helper and release its associated resources.
  45886. */
  45887. dispose(): void;
  45888. }
  45889. }
  45890. declare module "babylonjs/Debug/skeletonViewer" {
  45891. import { Color3 } from "babylonjs/Maths/math.color";
  45892. import { Scene } from "babylonjs/scene";
  45893. import { Nullable } from "babylonjs/types";
  45894. import { Skeleton } from "babylonjs/Bones/skeleton";
  45895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45896. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45897. /**
  45898. * Class used to render a debug view of a given skeleton
  45899. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45900. */
  45901. export class SkeletonViewer {
  45902. /** defines the skeleton to render */
  45903. skeleton: Skeleton;
  45904. /** defines the mesh attached to the skeleton */
  45905. mesh: AbstractMesh;
  45906. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45907. autoUpdateBonesMatrices: boolean;
  45908. /** defines the rendering group id to use with the viewer */
  45909. renderingGroupId: number;
  45910. /** Gets or sets the color used to render the skeleton */
  45911. color: Color3;
  45912. private _scene;
  45913. private _debugLines;
  45914. private _debugMesh;
  45915. private _isEnabled;
  45916. private _renderFunction;
  45917. private _utilityLayer;
  45918. /**
  45919. * Returns the mesh used to render the bones
  45920. */
  45921. readonly debugMesh: Nullable<LinesMesh>;
  45922. /**
  45923. * Creates a new SkeletonViewer
  45924. * @param skeleton defines the skeleton to render
  45925. * @param mesh defines the mesh attached to the skeleton
  45926. * @param scene defines the hosting scene
  45927. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45928. * @param renderingGroupId defines the rendering group id to use with the viewer
  45929. */
  45930. constructor(
  45931. /** defines the skeleton to render */
  45932. skeleton: Skeleton,
  45933. /** defines the mesh attached to the skeleton */
  45934. mesh: AbstractMesh, scene: Scene,
  45935. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45936. autoUpdateBonesMatrices?: boolean,
  45937. /** defines the rendering group id to use with the viewer */
  45938. renderingGroupId?: number);
  45939. /** Gets or sets a boolean indicating if the viewer is enabled */
  45940. isEnabled: boolean;
  45941. private _getBonePosition;
  45942. private _getLinesForBonesWithLength;
  45943. private _getLinesForBonesNoLength;
  45944. /** Update the viewer to sync with current skeleton state */
  45945. update(): void;
  45946. /** Release associated resources */
  45947. dispose(): void;
  45948. }
  45949. }
  45950. declare module "babylonjs/Debug/index" {
  45951. export * from "babylonjs/Debug/axesViewer";
  45952. export * from "babylonjs/Debug/boneAxesViewer";
  45953. export * from "babylonjs/Debug/debugLayer";
  45954. export * from "babylonjs/Debug/physicsViewer";
  45955. export * from "babylonjs/Debug/rayHelper";
  45956. export * from "babylonjs/Debug/skeletonViewer";
  45957. }
  45958. declare module "babylonjs/Engines/nullEngine" {
  45959. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45960. import { Scene } from "babylonjs/scene";
  45961. import { Engine } from "babylonjs/Engines/engine";
  45962. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45963. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45964. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45965. import { Effect } from "babylonjs/Materials/effect";
  45966. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45967. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45968. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45969. /**
  45970. * Options to create the null engine
  45971. */
  45972. export class NullEngineOptions {
  45973. /**
  45974. * Render width (Default: 512)
  45975. */
  45976. renderWidth: number;
  45977. /**
  45978. * Render height (Default: 256)
  45979. */
  45980. renderHeight: number;
  45981. /**
  45982. * Texture size (Default: 512)
  45983. */
  45984. textureSize: number;
  45985. /**
  45986. * If delta time between frames should be constant
  45987. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45988. */
  45989. deterministicLockstep: boolean;
  45990. /**
  45991. * Maximum about of steps between frames (Default: 4)
  45992. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45993. */
  45994. lockstepMaxSteps: number;
  45995. }
  45996. /**
  45997. * The null engine class provides support for headless version of babylon.js.
  45998. * This can be used in server side scenario or for testing purposes
  45999. */
  46000. export class NullEngine extends Engine {
  46001. private _options;
  46002. /**
  46003. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46004. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46005. * @returns true if engine is in deterministic lock step mode
  46006. */
  46007. isDeterministicLockStep(): boolean;
  46008. /**
  46009. * Gets the max steps when engine is running in deterministic lock step
  46010. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46011. * @returns the max steps
  46012. */
  46013. getLockstepMaxSteps(): number;
  46014. /**
  46015. * Gets the current hardware scaling level.
  46016. * By default the hardware scaling level is computed from the window device ratio.
  46017. * 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.
  46018. * @returns a number indicating the current hardware scaling level
  46019. */
  46020. getHardwareScalingLevel(): number;
  46021. constructor(options?: NullEngineOptions);
  46022. /**
  46023. * Creates a vertex buffer
  46024. * @param vertices the data for the vertex buffer
  46025. * @returns the new WebGL static buffer
  46026. */
  46027. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46028. /**
  46029. * Creates a new index buffer
  46030. * @param indices defines the content of the index buffer
  46031. * @param updatable defines if the index buffer must be updatable
  46032. * @returns a new webGL buffer
  46033. */
  46034. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46035. /**
  46036. * Clear the current render buffer or the current render target (if any is set up)
  46037. * @param color defines the color to use
  46038. * @param backBuffer defines if the back buffer must be cleared
  46039. * @param depth defines if the depth buffer must be cleared
  46040. * @param stencil defines if the stencil buffer must be cleared
  46041. */
  46042. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46043. /**
  46044. * Gets the current render width
  46045. * @param useScreen defines if screen size must be used (or the current render target if any)
  46046. * @returns a number defining the current render width
  46047. */
  46048. getRenderWidth(useScreen?: boolean): number;
  46049. /**
  46050. * Gets the current render height
  46051. * @param useScreen defines if screen size must be used (or the current render target if any)
  46052. * @returns a number defining the current render height
  46053. */
  46054. getRenderHeight(useScreen?: boolean): number;
  46055. /**
  46056. * Set the WebGL's viewport
  46057. * @param viewport defines the viewport element to be used
  46058. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46059. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46060. */
  46061. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46062. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46063. /**
  46064. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46065. * @param pipelineContext defines the pipeline context to use
  46066. * @param uniformsNames defines the list of uniform names
  46067. * @returns an array of webGL uniform locations
  46068. */
  46069. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46070. /**
  46071. * Gets the lsit of active attributes for a given webGL program
  46072. * @param pipelineContext defines the pipeline context to use
  46073. * @param attributesNames defines the list of attribute names to get
  46074. * @returns an array of indices indicating the offset of each attribute
  46075. */
  46076. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46077. /**
  46078. * Binds an effect to the webGL context
  46079. * @param effect defines the effect to bind
  46080. */
  46081. bindSamplers(effect: Effect): void;
  46082. /**
  46083. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46084. * @param effect defines the effect to activate
  46085. */
  46086. enableEffect(effect: Effect): void;
  46087. /**
  46088. * Set various states to the webGL context
  46089. * @param culling defines backface culling state
  46090. * @param zOffset defines the value to apply to zOffset (0 by default)
  46091. * @param force defines if states must be applied even if cache is up to date
  46092. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46093. */
  46094. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46095. /**
  46096. * Set the value of an uniform to an array of int32
  46097. * @param uniform defines the webGL uniform location where to store the value
  46098. * @param array defines the array of int32 to store
  46099. */
  46100. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46101. /**
  46102. * Set the value of an uniform to an array of int32 (stored as vec2)
  46103. * @param uniform defines the webGL uniform location where to store the value
  46104. * @param array defines the array of int32 to store
  46105. */
  46106. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46107. /**
  46108. * Set the value of an uniform to an array of int32 (stored as vec3)
  46109. * @param uniform defines the webGL uniform location where to store the value
  46110. * @param array defines the array of int32 to store
  46111. */
  46112. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46113. /**
  46114. * Set the value of an uniform to an array of int32 (stored as vec4)
  46115. * @param uniform defines the webGL uniform location where to store the value
  46116. * @param array defines the array of int32 to store
  46117. */
  46118. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46119. /**
  46120. * Set the value of an uniform to an array of float32
  46121. * @param uniform defines the webGL uniform location where to store the value
  46122. * @param array defines the array of float32 to store
  46123. */
  46124. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46125. /**
  46126. * Set the value of an uniform to an array of float32 (stored as vec2)
  46127. * @param uniform defines the webGL uniform location where to store the value
  46128. * @param array defines the array of float32 to store
  46129. */
  46130. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46131. /**
  46132. * Set the value of an uniform to an array of float32 (stored as vec3)
  46133. * @param uniform defines the webGL uniform location where to store the value
  46134. * @param array defines the array of float32 to store
  46135. */
  46136. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46137. /**
  46138. * Set the value of an uniform to an array of float32 (stored as vec4)
  46139. * @param uniform defines the webGL uniform location where to store the value
  46140. * @param array defines the array of float32 to store
  46141. */
  46142. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46143. /**
  46144. * Set the value of an uniform to an array of number
  46145. * @param uniform defines the webGL uniform location where to store the value
  46146. * @param array defines the array of number to store
  46147. */
  46148. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46149. /**
  46150. * Set the value of an uniform to an array of number (stored as vec2)
  46151. * @param uniform defines the webGL uniform location where to store the value
  46152. * @param array defines the array of number to store
  46153. */
  46154. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46155. /**
  46156. * Set the value of an uniform to an array of number (stored as vec3)
  46157. * @param uniform defines the webGL uniform location where to store the value
  46158. * @param array defines the array of number to store
  46159. */
  46160. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46161. /**
  46162. * Set the value of an uniform to an array of number (stored as vec4)
  46163. * @param uniform defines the webGL uniform location where to store the value
  46164. * @param array defines the array of number to store
  46165. */
  46166. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46167. /**
  46168. * Set the value of an uniform to an array of float32 (stored as matrices)
  46169. * @param uniform defines the webGL uniform location where to store the value
  46170. * @param matrices defines the array of float32 to store
  46171. */
  46172. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46173. /**
  46174. * Set the value of an uniform to a matrix (3x3)
  46175. * @param uniform defines the webGL uniform location where to store the value
  46176. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46177. */
  46178. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46179. /**
  46180. * Set the value of an uniform to a matrix (2x2)
  46181. * @param uniform defines the webGL uniform location where to store the value
  46182. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46183. */
  46184. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46185. /**
  46186. * Set the value of an uniform to a number (float)
  46187. * @param uniform defines the webGL uniform location where to store the value
  46188. * @param value defines the float number to store
  46189. */
  46190. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46191. /**
  46192. * Set the value of an uniform to a vec2
  46193. * @param uniform defines the webGL uniform location where to store the value
  46194. * @param x defines the 1st component of the value
  46195. * @param y defines the 2nd component of the value
  46196. */
  46197. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46198. /**
  46199. * Set the value of an uniform to a vec3
  46200. * @param uniform defines the webGL uniform location where to store the value
  46201. * @param x defines the 1st component of the value
  46202. * @param y defines the 2nd component of the value
  46203. * @param z defines the 3rd component of the value
  46204. */
  46205. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46206. /**
  46207. * Set the value of an uniform to a boolean
  46208. * @param uniform defines the webGL uniform location where to store the value
  46209. * @param bool defines the boolean to store
  46210. */
  46211. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46212. /**
  46213. * Set the value of an uniform to a vec4
  46214. * @param uniform defines the webGL uniform location where to store the value
  46215. * @param x defines the 1st component of the value
  46216. * @param y defines the 2nd component of the value
  46217. * @param z defines the 3rd component of the value
  46218. * @param w defines the 4th component of the value
  46219. */
  46220. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46221. /**
  46222. * Sets the current alpha mode
  46223. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46224. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46225. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46226. */
  46227. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46228. /**
  46229. * Bind webGl buffers directly to the webGL context
  46230. * @param vertexBuffers defines the vertex buffer to bind
  46231. * @param indexBuffer defines the index buffer to bind
  46232. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46233. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46234. * @param effect defines the effect associated with the vertex buffer
  46235. */
  46236. bindBuffers(vertexBuffers: {
  46237. [key: string]: VertexBuffer;
  46238. }, indexBuffer: DataBuffer, effect: Effect): void;
  46239. /**
  46240. * Force the entire cache to be cleared
  46241. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46242. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46243. */
  46244. wipeCaches(bruteForce?: boolean): void;
  46245. /**
  46246. * Send a draw order
  46247. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46248. * @param indexStart defines the starting index
  46249. * @param indexCount defines the number of index to draw
  46250. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46251. */
  46252. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46253. /**
  46254. * Draw a list of indexed primitives
  46255. * @param fillMode defines the primitive to use
  46256. * @param indexStart defines the starting index
  46257. * @param indexCount defines the number of index to draw
  46258. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46259. */
  46260. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46261. /**
  46262. * Draw a list of unindexed primitives
  46263. * @param fillMode defines the primitive to use
  46264. * @param verticesStart defines the index of first vertex to draw
  46265. * @param verticesCount defines the count of vertices to draw
  46266. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46267. */
  46268. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46269. /** @hidden */
  46270. _createTexture(): WebGLTexture;
  46271. /** @hidden */
  46272. _releaseTexture(texture: InternalTexture): void;
  46273. /**
  46274. * Usually called from Texture.ts.
  46275. * Passed information to create a WebGLTexture
  46276. * @param urlArg defines a value which contains one of the following:
  46277. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46278. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46279. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46280. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46281. * @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)
  46282. * @param scene needed for loading to the correct scene
  46283. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46284. * @param onLoad optional callback to be called upon successful completion
  46285. * @param onError optional callback to be called upon failure
  46286. * @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
  46287. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46288. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46289. * @param forcedExtension defines the extension to use to pick the right loader
  46290. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46291. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46292. */
  46293. 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;
  46294. /**
  46295. * Creates a new render target texture
  46296. * @param size defines the size of the texture
  46297. * @param options defines the options used to create the texture
  46298. * @returns a new render target texture stored in an InternalTexture
  46299. */
  46300. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46301. /**
  46302. * Update the sampling mode of a given texture
  46303. * @param samplingMode defines the required sampling mode
  46304. * @param texture defines the texture to update
  46305. */
  46306. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46307. /**
  46308. * Binds the frame buffer to the specified texture.
  46309. * @param texture The texture to render to or null for the default canvas
  46310. * @param faceIndex The face of the texture to render to in case of cube texture
  46311. * @param requiredWidth The width of the target to render to
  46312. * @param requiredHeight The height of the target to render to
  46313. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46314. * @param depthStencilTexture The depth stencil texture to use to render
  46315. * @param lodLevel defines le lod level to bind to the frame buffer
  46316. */
  46317. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46318. /**
  46319. * Unbind the current render target texture from the webGL context
  46320. * @param texture defines the render target texture to unbind
  46321. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46322. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46323. */
  46324. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46325. /**
  46326. * Creates a dynamic vertex buffer
  46327. * @param vertices the data for the dynamic vertex buffer
  46328. * @returns the new WebGL dynamic buffer
  46329. */
  46330. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46331. /**
  46332. * Update the content of a dynamic texture
  46333. * @param texture defines the texture to update
  46334. * @param canvas defines the canvas containing the source
  46335. * @param invertY defines if data must be stored with Y axis inverted
  46336. * @param premulAlpha defines if alpha is stored as premultiplied
  46337. * @param format defines the format of the data
  46338. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46339. */
  46340. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46341. /**
  46342. * Gets a boolean indicating if all created effects are ready
  46343. * @returns true if all effects are ready
  46344. */
  46345. areAllEffectsReady(): boolean;
  46346. /**
  46347. * @hidden
  46348. * Get the current error code of the webGL context
  46349. * @returns the error code
  46350. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46351. */
  46352. getError(): number;
  46353. /** @hidden */
  46354. _getUnpackAlignement(): number;
  46355. /** @hidden */
  46356. _unpackFlipY(value: boolean): void;
  46357. /**
  46358. * Update a dynamic index buffer
  46359. * @param indexBuffer defines the target index buffer
  46360. * @param indices defines the data to update
  46361. * @param offset defines the offset in the target index buffer where update should start
  46362. */
  46363. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46364. /**
  46365. * Updates a dynamic vertex buffer.
  46366. * @param vertexBuffer the vertex buffer to update
  46367. * @param vertices the data used to update the vertex buffer
  46368. * @param byteOffset the byte offset of the data (optional)
  46369. * @param byteLength the byte length of the data (optional)
  46370. */
  46371. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46372. /** @hidden */
  46373. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46374. /** @hidden */
  46375. _bindTexture(channel: number, texture: InternalTexture): void;
  46376. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46377. /**
  46378. * 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
  46379. */
  46380. releaseEffects(): void;
  46381. displayLoadingUI(): void;
  46382. hideLoadingUI(): void;
  46383. /** @hidden */
  46384. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46385. /** @hidden */
  46386. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46387. /** @hidden */
  46388. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46389. /** @hidden */
  46390. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46391. }
  46392. }
  46393. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  46394. import { Nullable, int } from "babylonjs/types";
  46395. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  46396. /** @hidden */
  46397. export class _OcclusionDataStorage {
  46398. /** @hidden */
  46399. occlusionInternalRetryCounter: number;
  46400. /** @hidden */
  46401. isOcclusionQueryInProgress: boolean;
  46402. /** @hidden */
  46403. isOccluded: boolean;
  46404. /** @hidden */
  46405. occlusionRetryCount: number;
  46406. /** @hidden */
  46407. occlusionType: number;
  46408. /** @hidden */
  46409. occlusionQueryAlgorithmType: number;
  46410. }
  46411. module "babylonjs/Engines/engine" {
  46412. interface Engine {
  46413. /**
  46414. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46415. * @return the new query
  46416. */
  46417. createQuery(): WebGLQuery;
  46418. /**
  46419. * Delete and release a webGL query
  46420. * @param query defines the query to delete
  46421. * @return the current engine
  46422. */
  46423. deleteQuery(query: WebGLQuery): Engine;
  46424. /**
  46425. * Check if a given query has resolved and got its value
  46426. * @param query defines the query to check
  46427. * @returns true if the query got its value
  46428. */
  46429. isQueryResultAvailable(query: WebGLQuery): boolean;
  46430. /**
  46431. * Gets the value of a given query
  46432. * @param query defines the query to check
  46433. * @returns the value of the query
  46434. */
  46435. getQueryResult(query: WebGLQuery): number;
  46436. /**
  46437. * Initiates an occlusion query
  46438. * @param algorithmType defines the algorithm to use
  46439. * @param query defines the query to use
  46440. * @returns the current engine
  46441. * @see http://doc.babylonjs.com/features/occlusionquery
  46442. */
  46443. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46444. /**
  46445. * Ends an occlusion query
  46446. * @see http://doc.babylonjs.com/features/occlusionquery
  46447. * @param algorithmType defines the algorithm to use
  46448. * @returns the current engine
  46449. */
  46450. endOcclusionQuery(algorithmType: number): Engine;
  46451. /**
  46452. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46453. * Please note that only one query can be issued at a time
  46454. * @returns a time token used to track the time span
  46455. */
  46456. startTimeQuery(): Nullable<_TimeToken>;
  46457. /**
  46458. * Ends a time query
  46459. * @param token defines the token used to measure the time span
  46460. * @returns the time spent (in ns)
  46461. */
  46462. endTimeQuery(token: _TimeToken): int;
  46463. /** @hidden */
  46464. _currentNonTimestampToken: Nullable<_TimeToken>;
  46465. /** @hidden */
  46466. _createTimeQuery(): WebGLQuery;
  46467. /** @hidden */
  46468. _deleteTimeQuery(query: WebGLQuery): void;
  46469. /** @hidden */
  46470. _getGlAlgorithmType(algorithmType: number): number;
  46471. /** @hidden */
  46472. _getTimeQueryResult(query: WebGLQuery): any;
  46473. /** @hidden */
  46474. _getTimeQueryAvailability(query: WebGLQuery): any;
  46475. }
  46476. }
  46477. module "babylonjs/Meshes/abstractMesh" {
  46478. interface AbstractMesh {
  46479. /**
  46480. * Backing filed
  46481. * @hidden
  46482. */
  46483. __occlusionDataStorage: _OcclusionDataStorage;
  46484. /**
  46485. * Access property
  46486. * @hidden
  46487. */
  46488. _occlusionDataStorage: _OcclusionDataStorage;
  46489. /**
  46490. * 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.
  46491. * The default value is -1 which means don't break the query and wait till the result
  46492. * @see http://doc.babylonjs.com/features/occlusionquery
  46493. */
  46494. occlusionRetryCount: number;
  46495. /**
  46496. * 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:
  46497. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46498. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46499. * * 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.
  46500. * @see http://doc.babylonjs.com/features/occlusionquery
  46501. */
  46502. occlusionType: number;
  46503. /**
  46504. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46505. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46506. * * 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.
  46507. * @see http://doc.babylonjs.com/features/occlusionquery
  46508. */
  46509. occlusionQueryAlgorithmType: number;
  46510. /**
  46511. * 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
  46512. * @see http://doc.babylonjs.com/features/occlusionquery
  46513. */
  46514. isOccluded: boolean;
  46515. /**
  46516. * Flag to check the progress status of the query
  46517. * @see http://doc.babylonjs.com/features/occlusionquery
  46518. */
  46519. isOcclusionQueryInProgress: boolean;
  46520. }
  46521. }
  46522. }
  46523. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  46524. import { Nullable } from "babylonjs/types";
  46525. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46526. /** @hidden */
  46527. export var _forceTransformFeedbackToBundle: boolean;
  46528. module "babylonjs/Engines/engine" {
  46529. interface Engine {
  46530. /**
  46531. * Creates a webGL transform feedback object
  46532. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46533. * @returns the webGL transform feedback object
  46534. */
  46535. createTransformFeedback(): WebGLTransformFeedback;
  46536. /**
  46537. * Delete a webGL transform feedback object
  46538. * @param value defines the webGL transform feedback object to delete
  46539. */
  46540. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46541. /**
  46542. * Bind a webGL transform feedback object to the webgl context
  46543. * @param value defines the webGL transform feedback object to bind
  46544. */
  46545. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46546. /**
  46547. * Begins a transform feedback operation
  46548. * @param usePoints defines if points or triangles must be used
  46549. */
  46550. beginTransformFeedback(usePoints: boolean): void;
  46551. /**
  46552. * Ends a transform feedback operation
  46553. */
  46554. endTransformFeedback(): void;
  46555. /**
  46556. * Specify the varyings to use with transform feedback
  46557. * @param program defines the associated webGL program
  46558. * @param value defines the list of strings representing the varying names
  46559. */
  46560. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46561. /**
  46562. * Bind a webGL buffer for a transform feedback operation
  46563. * @param value defines the webGL buffer to bind
  46564. */
  46565. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46566. }
  46567. }
  46568. }
  46569. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46570. import { Scene } from "babylonjs/scene";
  46571. import { Engine } from "babylonjs/Engines/engine";
  46572. import { Texture } from "babylonjs/Materials/Textures/texture";
  46573. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46574. import "babylonjs/Engines/Extensions/engine.multiRender";
  46575. /**
  46576. * Creation options of the multi render target texture.
  46577. */
  46578. export interface IMultiRenderTargetOptions {
  46579. /**
  46580. * Define if the texture needs to create mip maps after render.
  46581. */
  46582. generateMipMaps?: boolean;
  46583. /**
  46584. * Define the types of all the draw buffers we want to create
  46585. */
  46586. types?: number[];
  46587. /**
  46588. * Define the sampling modes of all the draw buffers we want to create
  46589. */
  46590. samplingModes?: number[];
  46591. /**
  46592. * Define if a depth buffer is required
  46593. */
  46594. generateDepthBuffer?: boolean;
  46595. /**
  46596. * Define if a stencil buffer is required
  46597. */
  46598. generateStencilBuffer?: boolean;
  46599. /**
  46600. * Define if a depth texture is required instead of a depth buffer
  46601. */
  46602. generateDepthTexture?: boolean;
  46603. /**
  46604. * Define the number of desired draw buffers
  46605. */
  46606. textureCount?: number;
  46607. /**
  46608. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46609. */
  46610. doNotChangeAspectRatio?: boolean;
  46611. /**
  46612. * Define the default type of the buffers we are creating
  46613. */
  46614. defaultType?: number;
  46615. }
  46616. /**
  46617. * A multi render target, like a render target provides the ability to render to a texture.
  46618. * Unlike the render target, it can render to several draw buffers in one draw.
  46619. * This is specially interesting in deferred rendering or for any effects requiring more than
  46620. * just one color from a single pass.
  46621. */
  46622. export class MultiRenderTarget extends RenderTargetTexture {
  46623. private _internalTextures;
  46624. private _textures;
  46625. private _multiRenderTargetOptions;
  46626. /**
  46627. * Get if draw buffers are currently supported by the used hardware and browser.
  46628. */
  46629. readonly isSupported: boolean;
  46630. /**
  46631. * Get the list of textures generated by the multi render target.
  46632. */
  46633. readonly textures: Texture[];
  46634. /**
  46635. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46636. */
  46637. readonly depthTexture: Texture;
  46638. /**
  46639. * Set the wrapping mode on U of all the textures we are rendering to.
  46640. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46641. */
  46642. wrapU: number;
  46643. /**
  46644. * Set the wrapping mode on V of all the textures we are rendering to.
  46645. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46646. */
  46647. wrapV: number;
  46648. /**
  46649. * Instantiate a new multi render target texture.
  46650. * A multi render target, like a render target provides the ability to render to a texture.
  46651. * Unlike the render target, it can render to several draw buffers in one draw.
  46652. * This is specially interesting in deferred rendering or for any effects requiring more than
  46653. * just one color from a single pass.
  46654. * @param name Define the name of the texture
  46655. * @param size Define the size of the buffers to render to
  46656. * @param count Define the number of target we are rendering into
  46657. * @param scene Define the scene the texture belongs to
  46658. * @param options Define the options used to create the multi render target
  46659. */
  46660. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46661. /** @hidden */
  46662. _rebuild(): void;
  46663. private _createInternalTextures;
  46664. private _createTextures;
  46665. /**
  46666. * Define the number of samples used if MSAA is enabled.
  46667. */
  46668. samples: number;
  46669. /**
  46670. * Resize all the textures in the multi render target.
  46671. * Be carrefull as it will recreate all the data in the new texture.
  46672. * @param size Define the new size
  46673. */
  46674. resize(size: any): void;
  46675. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46676. /**
  46677. * Dispose the render targets and their associated resources
  46678. */
  46679. dispose(): void;
  46680. /**
  46681. * Release all the underlying texture used as draw buffers.
  46682. */
  46683. releaseInternalTextures(): void;
  46684. }
  46685. }
  46686. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46687. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46688. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46689. import { Nullable } from "babylonjs/types";
  46690. module "babylonjs/Engines/thinEngine" {
  46691. interface ThinEngine {
  46692. /**
  46693. * Unbind a list of render target textures from the webGL context
  46694. * This is used only when drawBuffer extension or webGL2 are active
  46695. * @param textures defines the render target textures to unbind
  46696. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46697. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46698. */
  46699. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46700. /**
  46701. * Create a multi render target texture
  46702. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46703. * @param size defines the size of the texture
  46704. * @param options defines the creation options
  46705. * @returns the cube texture as an InternalTexture
  46706. */
  46707. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46708. /**
  46709. * Update the sample count for a given multiple render target texture
  46710. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46711. * @param textures defines the textures to update
  46712. * @param samples defines the sample count to set
  46713. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46714. */
  46715. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46716. }
  46717. }
  46718. }
  46719. declare module "babylonjs/Engines/Extensions/engine.views" {
  46720. import { Camera } from "babylonjs/Cameras/camera";
  46721. import { Nullable } from "babylonjs/types";
  46722. /**
  46723. * Class used to define an additional view for the engine
  46724. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46725. */
  46726. export class EngineView {
  46727. /** Defines the canvas where to render the view */
  46728. target: HTMLCanvasElement;
  46729. /** Defines an optional camera used to render the view (will use active camera else) */
  46730. camera?: Camera;
  46731. }
  46732. module "babylonjs/Engines/engine" {
  46733. interface Engine {
  46734. /**
  46735. * Gets or sets the HTML element to use for attaching events
  46736. */
  46737. inputElement: Nullable<HTMLElement>;
  46738. /**
  46739. * Gets the current engine view
  46740. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46741. */
  46742. activeView: Nullable<EngineView>;
  46743. /** Gets or sets the list of views */
  46744. views: EngineView[];
  46745. /**
  46746. * Register a new child canvas
  46747. * @param canvas defines the canvas to register
  46748. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46749. * @returns the associated view
  46750. */
  46751. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46752. /**
  46753. * Remove a registered child canvas
  46754. * @param canvas defines the canvas to remove
  46755. * @returns the current engine
  46756. */
  46757. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46758. }
  46759. }
  46760. }
  46761. declare module "babylonjs/Engines/Extensions/index" {
  46762. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46763. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46764. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46765. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46766. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46767. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46768. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46769. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46770. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46771. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46772. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46773. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46774. export * from "babylonjs/Engines/Extensions/engine.views";
  46775. }
  46776. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46777. import { Nullable } from "babylonjs/types";
  46778. /**
  46779. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46780. */
  46781. export interface CubeMapInfo {
  46782. /**
  46783. * The pixel array for the front face.
  46784. * This is stored in format, left to right, up to down format.
  46785. */
  46786. front: Nullable<ArrayBufferView>;
  46787. /**
  46788. * The pixel array for the back face.
  46789. * This is stored in format, left to right, up to down format.
  46790. */
  46791. back: Nullable<ArrayBufferView>;
  46792. /**
  46793. * The pixel array for the left face.
  46794. * This is stored in format, left to right, up to down format.
  46795. */
  46796. left: Nullable<ArrayBufferView>;
  46797. /**
  46798. * The pixel array for the right face.
  46799. * This is stored in format, left to right, up to down format.
  46800. */
  46801. right: Nullable<ArrayBufferView>;
  46802. /**
  46803. * The pixel array for the up face.
  46804. * This is stored in format, left to right, up to down format.
  46805. */
  46806. up: Nullable<ArrayBufferView>;
  46807. /**
  46808. * The pixel array for the down face.
  46809. * This is stored in format, left to right, up to down format.
  46810. */
  46811. down: Nullable<ArrayBufferView>;
  46812. /**
  46813. * The size of the cubemap stored.
  46814. *
  46815. * Each faces will be size * size pixels.
  46816. */
  46817. size: number;
  46818. /**
  46819. * The format of the texture.
  46820. *
  46821. * RGBA, RGB.
  46822. */
  46823. format: number;
  46824. /**
  46825. * The type of the texture data.
  46826. *
  46827. * UNSIGNED_INT, FLOAT.
  46828. */
  46829. type: number;
  46830. /**
  46831. * Specifies whether the texture is in gamma space.
  46832. */
  46833. gammaSpace: boolean;
  46834. }
  46835. /**
  46836. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46837. */
  46838. export class PanoramaToCubeMapTools {
  46839. private static FACE_FRONT;
  46840. private static FACE_BACK;
  46841. private static FACE_RIGHT;
  46842. private static FACE_LEFT;
  46843. private static FACE_DOWN;
  46844. private static FACE_UP;
  46845. /**
  46846. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46847. *
  46848. * @param float32Array The source data.
  46849. * @param inputWidth The width of the input panorama.
  46850. * @param inputHeight The height of the input panorama.
  46851. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46852. * @return The cubemap data
  46853. */
  46854. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46855. private static CreateCubemapTexture;
  46856. private static CalcProjectionSpherical;
  46857. }
  46858. }
  46859. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46860. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46861. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46862. import { Nullable } from "babylonjs/types";
  46863. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46864. /**
  46865. * Helper class dealing with the extraction of spherical polynomial dataArray
  46866. * from a cube map.
  46867. */
  46868. export class CubeMapToSphericalPolynomialTools {
  46869. private static FileFaces;
  46870. /**
  46871. * Converts a texture to the according Spherical Polynomial data.
  46872. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46873. *
  46874. * @param texture The texture to extract the information from.
  46875. * @return The Spherical Polynomial data.
  46876. */
  46877. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46878. /**
  46879. * Converts a cubemap to the according Spherical Polynomial data.
  46880. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46881. *
  46882. * @param cubeInfo The Cube map to extract the information from.
  46883. * @return The Spherical Polynomial data.
  46884. */
  46885. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46886. }
  46887. }
  46888. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46889. import { Nullable } from "babylonjs/types";
  46890. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46891. module "babylonjs/Materials/Textures/baseTexture" {
  46892. interface BaseTexture {
  46893. /**
  46894. * Get the polynomial representation of the texture data.
  46895. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46896. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46897. */
  46898. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46899. }
  46900. }
  46901. }
  46902. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46903. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46904. /** @hidden */
  46905. export var rgbdEncodePixelShader: {
  46906. name: string;
  46907. shader: string;
  46908. };
  46909. }
  46910. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46911. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46912. /** @hidden */
  46913. export var rgbdDecodePixelShader: {
  46914. name: string;
  46915. shader: string;
  46916. };
  46917. }
  46918. declare module "babylonjs/Misc/environmentTextureTools" {
  46919. import { Nullable } from "babylonjs/types";
  46920. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46921. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46922. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46923. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46924. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46925. import "babylonjs/Shaders/rgbdEncode.fragment";
  46926. import "babylonjs/Shaders/rgbdDecode.fragment";
  46927. /**
  46928. * Raw texture data and descriptor sufficient for WebGL texture upload
  46929. */
  46930. export interface EnvironmentTextureInfo {
  46931. /**
  46932. * Version of the environment map
  46933. */
  46934. version: number;
  46935. /**
  46936. * Width of image
  46937. */
  46938. width: number;
  46939. /**
  46940. * Irradiance information stored in the file.
  46941. */
  46942. irradiance: any;
  46943. /**
  46944. * Specular information stored in the file.
  46945. */
  46946. specular: any;
  46947. }
  46948. /**
  46949. * Defines One Image in the file. It requires only the position in the file
  46950. * as well as the length.
  46951. */
  46952. interface BufferImageData {
  46953. /**
  46954. * Length of the image data.
  46955. */
  46956. length: number;
  46957. /**
  46958. * Position of the data from the null terminator delimiting the end of the JSON.
  46959. */
  46960. position: number;
  46961. }
  46962. /**
  46963. * Defines the specular data enclosed in the file.
  46964. * This corresponds to the version 1 of the data.
  46965. */
  46966. export interface EnvironmentTextureSpecularInfoV1 {
  46967. /**
  46968. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46969. */
  46970. specularDataPosition?: number;
  46971. /**
  46972. * This contains all the images data needed to reconstruct the cubemap.
  46973. */
  46974. mipmaps: Array<BufferImageData>;
  46975. /**
  46976. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46977. */
  46978. lodGenerationScale: number;
  46979. }
  46980. /**
  46981. * Sets of helpers addressing the serialization and deserialization of environment texture
  46982. * stored in a BabylonJS env file.
  46983. * Those files are usually stored as .env files.
  46984. */
  46985. export class EnvironmentTextureTools {
  46986. /**
  46987. * Magic number identifying the env file.
  46988. */
  46989. private static _MagicBytes;
  46990. /**
  46991. * Gets the environment info from an env file.
  46992. * @param data The array buffer containing the .env bytes.
  46993. * @returns the environment file info (the json header) if successfully parsed.
  46994. */
  46995. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46996. /**
  46997. * Creates an environment texture from a loaded cube texture.
  46998. * @param texture defines the cube texture to convert in env file
  46999. * @return a promise containing the environment data if succesfull.
  47000. */
  47001. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47002. /**
  47003. * Creates a JSON representation of the spherical data.
  47004. * @param texture defines the texture containing the polynomials
  47005. * @return the JSON representation of the spherical info
  47006. */
  47007. private static _CreateEnvTextureIrradiance;
  47008. /**
  47009. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47010. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  47011. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47012. * @return the views described by info providing access to the underlying buffer
  47013. */
  47014. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47015. /**
  47016. * Uploads the texture info contained in the env file to the GPU.
  47017. * @param texture defines the internal texture to upload to
  47018. * @param arrayBuffer defines the buffer cotaining the data to load
  47019. * @param info defines the texture info retrieved through the GetEnvInfo method
  47020. * @returns a promise
  47021. */
  47022. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47023. private static _OnImageReadyAsync;
  47024. /**
  47025. * Uploads the levels of image data to the GPU.
  47026. * @param texture defines the internal texture to upload to
  47027. * @param imageData defines the array buffer views of image data [mipmap][face]
  47028. * @returns a promise
  47029. */
  47030. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47031. /**
  47032. * Uploads spherical polynomials information to the texture.
  47033. * @param texture defines the texture we are trying to upload the information to
  47034. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47035. */
  47036. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47037. /** @hidden */
  47038. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47039. }
  47040. }
  47041. declare module "babylonjs/Maths/math.vertexFormat" {
  47042. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47043. /**
  47044. * Contains position and normal vectors for a vertex
  47045. */
  47046. export class PositionNormalVertex {
  47047. /** the position of the vertex (defaut: 0,0,0) */
  47048. position: Vector3;
  47049. /** the normal of the vertex (defaut: 0,1,0) */
  47050. normal: Vector3;
  47051. /**
  47052. * Creates a PositionNormalVertex
  47053. * @param position the position of the vertex (defaut: 0,0,0)
  47054. * @param normal the normal of the vertex (defaut: 0,1,0)
  47055. */
  47056. constructor(
  47057. /** the position of the vertex (defaut: 0,0,0) */
  47058. position?: Vector3,
  47059. /** the normal of the vertex (defaut: 0,1,0) */
  47060. normal?: Vector3);
  47061. /**
  47062. * Clones the PositionNormalVertex
  47063. * @returns the cloned PositionNormalVertex
  47064. */
  47065. clone(): PositionNormalVertex;
  47066. }
  47067. /**
  47068. * Contains position, normal and uv vectors for a vertex
  47069. */
  47070. export class PositionNormalTextureVertex {
  47071. /** the position of the vertex (defaut: 0,0,0) */
  47072. position: Vector3;
  47073. /** the normal of the vertex (defaut: 0,1,0) */
  47074. normal: Vector3;
  47075. /** the uv of the vertex (default: 0,0) */
  47076. uv: Vector2;
  47077. /**
  47078. * Creates a PositionNormalTextureVertex
  47079. * @param position the position of the vertex (defaut: 0,0,0)
  47080. * @param normal the normal of the vertex (defaut: 0,1,0)
  47081. * @param uv the uv of the vertex (default: 0,0)
  47082. */
  47083. constructor(
  47084. /** the position of the vertex (defaut: 0,0,0) */
  47085. position?: Vector3,
  47086. /** the normal of the vertex (defaut: 0,1,0) */
  47087. normal?: Vector3,
  47088. /** the uv of the vertex (default: 0,0) */
  47089. uv?: Vector2);
  47090. /**
  47091. * Clones the PositionNormalTextureVertex
  47092. * @returns the cloned PositionNormalTextureVertex
  47093. */
  47094. clone(): PositionNormalTextureVertex;
  47095. }
  47096. }
  47097. declare module "babylonjs/Maths/math" {
  47098. export * from "babylonjs/Maths/math.axis";
  47099. export * from "babylonjs/Maths/math.color";
  47100. export * from "babylonjs/Maths/math.constants";
  47101. export * from "babylonjs/Maths/math.frustum";
  47102. export * from "babylonjs/Maths/math.path";
  47103. export * from "babylonjs/Maths/math.plane";
  47104. export * from "babylonjs/Maths/math.size";
  47105. export * from "babylonjs/Maths/math.vector";
  47106. export * from "babylonjs/Maths/math.vertexFormat";
  47107. export * from "babylonjs/Maths/math.viewport";
  47108. }
  47109. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  47110. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47111. /** @hidden */
  47112. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47113. private _genericAttributeLocation;
  47114. private _varyingLocationCount;
  47115. private _varyingLocationMap;
  47116. private _replacements;
  47117. private _textureCount;
  47118. private _uniforms;
  47119. lineProcessor(line: string): string;
  47120. attributeProcessor(attribute: string): string;
  47121. varyingProcessor(varying: string, isFragment: boolean): string;
  47122. uniformProcessor(uniform: string): string;
  47123. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47124. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47125. }
  47126. }
  47127. declare module "babylonjs/Engines/nativeEngine" {
  47128. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  47129. import { Engine } from "babylonjs/Engines/engine";
  47130. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47131. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47132. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47133. import { Effect } from "babylonjs/Materials/effect";
  47134. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47135. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  47136. import { IColor4Like } from "babylonjs/Maths/math.like";
  47137. import { Scene } from "babylonjs/scene";
  47138. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47139. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47140. /**
  47141. * Container for accessors for natively-stored mesh data buffers.
  47142. */
  47143. class NativeDataBuffer extends DataBuffer {
  47144. /**
  47145. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47146. */
  47147. nativeIndexBuffer?: any;
  47148. /**
  47149. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47150. */
  47151. nativeVertexBuffer?: any;
  47152. }
  47153. /** @hidden */
  47154. class NativeTexture extends InternalTexture {
  47155. getInternalTexture(): InternalTexture;
  47156. getViewCount(): number;
  47157. }
  47158. /** @hidden */
  47159. export class NativeEngine extends Engine {
  47160. private readonly _native;
  47161. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47162. private readonly INVALID_HANDLE;
  47163. getHardwareScalingLevel(): number;
  47164. constructor();
  47165. /**
  47166. * Can be used to override the current requestAnimationFrame requester.
  47167. * @hidden
  47168. */
  47169. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47170. /**
  47171. * Override default engine behavior.
  47172. * @param color
  47173. * @param backBuffer
  47174. * @param depth
  47175. * @param stencil
  47176. */
  47177. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47178. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47179. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47180. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47181. recordVertexArrayObject(vertexBuffers: {
  47182. [key: string]: VertexBuffer;
  47183. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47184. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47185. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47186. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47187. /**
  47188. * Draw a list of indexed primitives
  47189. * @param fillMode defines the primitive to use
  47190. * @param indexStart defines the starting index
  47191. * @param indexCount defines the number of index to draw
  47192. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47193. */
  47194. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47195. /**
  47196. * Draw a list of unindexed primitives
  47197. * @param fillMode defines the primitive to use
  47198. * @param verticesStart defines the index of first vertex to draw
  47199. * @param verticesCount defines the count of vertices to draw
  47200. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47201. */
  47202. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47203. createPipelineContext(): IPipelineContext;
  47204. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47205. /** @hidden */
  47206. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47207. /** @hidden */
  47208. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47209. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47210. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47211. protected _setProgram(program: WebGLProgram): void;
  47212. _releaseEffect(effect: Effect): void;
  47213. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47214. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47215. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47216. bindSamplers(effect: Effect): void;
  47217. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47218. getRenderWidth(useScreen?: boolean): number;
  47219. getRenderHeight(useScreen?: boolean): number;
  47220. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47221. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47222. /**
  47223. * Set the z offset to apply to current rendering
  47224. * @param value defines the offset to apply
  47225. */
  47226. setZOffset(value: number): void;
  47227. /**
  47228. * Gets the current value of the zOffset
  47229. * @returns the current zOffset state
  47230. */
  47231. getZOffset(): number;
  47232. /**
  47233. * Enable or disable depth buffering
  47234. * @param enable defines the state to set
  47235. */
  47236. setDepthBuffer(enable: boolean): void;
  47237. /**
  47238. * Gets a boolean indicating if depth writing is enabled
  47239. * @returns the current depth writing state
  47240. */
  47241. getDepthWrite(): boolean;
  47242. /**
  47243. * Enable or disable depth writing
  47244. * @param enable defines the state to set
  47245. */
  47246. setDepthWrite(enable: boolean): void;
  47247. /**
  47248. * Enable or disable color writing
  47249. * @param enable defines the state to set
  47250. */
  47251. setColorWrite(enable: boolean): void;
  47252. /**
  47253. * Gets a boolean indicating if color writing is enabled
  47254. * @returns the current color writing state
  47255. */
  47256. getColorWrite(): boolean;
  47257. /**
  47258. * Sets alpha constants used by some alpha blending modes
  47259. * @param r defines the red component
  47260. * @param g defines the green component
  47261. * @param b defines the blue component
  47262. * @param a defines the alpha component
  47263. */
  47264. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47265. /**
  47266. * Sets the current alpha mode
  47267. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47268. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47269. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47270. */
  47271. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47272. /**
  47273. * Gets the current alpha mode
  47274. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47275. * @returns the current alpha mode
  47276. */
  47277. getAlphaMode(): number;
  47278. setInt(uniform: WebGLUniformLocation, int: number): void;
  47279. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47280. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47281. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47282. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47283. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47284. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47285. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47286. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47287. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47288. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47289. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47290. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47291. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47292. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47293. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47294. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47295. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47296. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47297. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47298. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47299. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47300. wipeCaches(bruteForce?: boolean): void;
  47301. _createTexture(): WebGLTexture;
  47302. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47303. /**
  47304. * Usually called from BABYLON.Texture.ts.
  47305. * Passed information to create a WebGLTexture
  47306. * @param urlArg defines a value which contains one of the following:
  47307. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47308. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47309. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47310. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47311. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47312. * @param scene needed for loading to the correct scene
  47313. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47314. * @param onLoad optional callback to be called upon successful completion
  47315. * @param onError optional callback to be called upon failure
  47316. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47317. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47318. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47319. * @param forcedExtension defines the extension to use to pick the right loader
  47320. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47321. */
  47322. 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;
  47323. /**
  47324. * Creates a cube texture
  47325. * @param rootUrl defines the url where the files to load is located
  47326. * @param scene defines the current scene
  47327. * @param files defines the list of files to load (1 per face)
  47328. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47329. * @param onLoad defines an optional callback raised when the texture is loaded
  47330. * @param onError defines an optional callback raised if there is an issue to load the texture
  47331. * @param format defines the format of the data
  47332. * @param forcedExtension defines the extension to use to pick the right loader
  47333. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47334. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47335. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47336. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47337. * @returns the cube texture as an InternalTexture
  47338. */
  47339. 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;
  47340. private _getSamplingFilter;
  47341. private static _GetNativeTextureFormat;
  47342. createRenderTargetTexture(size: number | {
  47343. width: number;
  47344. height: number;
  47345. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47346. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47347. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47348. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47349. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47350. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47351. /**
  47352. * Updates a dynamic vertex buffer.
  47353. * @param vertexBuffer the vertex buffer to update
  47354. * @param data the data used to update the vertex buffer
  47355. * @param byteOffset the byte offset of the data (optional)
  47356. * @param byteLength the byte length of the data (optional)
  47357. */
  47358. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47359. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47360. private _updateAnisotropicLevel;
  47361. private _getAddressMode;
  47362. /** @hidden */
  47363. _bindTexture(channel: number, texture: InternalTexture): void;
  47364. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47365. releaseEffects(): void;
  47366. /** @hidden */
  47367. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47368. /** @hidden */
  47369. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47370. /** @hidden */
  47371. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47372. /** @hidden */
  47373. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47374. }
  47375. }
  47376. declare module "babylonjs/Engines/index" {
  47377. export * from "babylonjs/Engines/constants";
  47378. export * from "babylonjs/Engines/engineCapabilities";
  47379. export * from "babylonjs/Engines/instancingAttributeInfo";
  47380. export * from "babylonjs/Engines/thinEngine";
  47381. export * from "babylonjs/Engines/engine";
  47382. export * from "babylonjs/Engines/engineStore";
  47383. export * from "babylonjs/Engines/nullEngine";
  47384. export * from "babylonjs/Engines/Extensions/index";
  47385. export * from "babylonjs/Engines/IPipelineContext";
  47386. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  47387. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47388. export * from "babylonjs/Engines/nativeEngine";
  47389. }
  47390. declare module "babylonjs/Events/clipboardEvents" {
  47391. /**
  47392. * Gather the list of clipboard event types as constants.
  47393. */
  47394. export class ClipboardEventTypes {
  47395. /**
  47396. * The clipboard event is fired when a copy command is active (pressed).
  47397. */
  47398. static readonly COPY: number;
  47399. /**
  47400. * The clipboard event is fired when a cut command is active (pressed).
  47401. */
  47402. static readonly CUT: number;
  47403. /**
  47404. * The clipboard event is fired when a paste command is active (pressed).
  47405. */
  47406. static readonly PASTE: number;
  47407. }
  47408. /**
  47409. * This class is used to store clipboard related info for the onClipboardObservable event.
  47410. */
  47411. export class ClipboardInfo {
  47412. /**
  47413. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47414. */
  47415. type: number;
  47416. /**
  47417. * Defines the related dom event
  47418. */
  47419. event: ClipboardEvent;
  47420. /**
  47421. *Creates an instance of ClipboardInfo.
  47422. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47423. * @param event Defines the related dom event
  47424. */
  47425. constructor(
  47426. /**
  47427. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47428. */
  47429. type: number,
  47430. /**
  47431. * Defines the related dom event
  47432. */
  47433. event: ClipboardEvent);
  47434. /**
  47435. * Get the clipboard event's type from the keycode.
  47436. * @param keyCode Defines the keyCode for the current keyboard event.
  47437. * @return {number}
  47438. */
  47439. static GetTypeFromCharacter(keyCode: number): number;
  47440. }
  47441. }
  47442. declare module "babylonjs/Events/index" {
  47443. export * from "babylonjs/Events/keyboardEvents";
  47444. export * from "babylonjs/Events/pointerEvents";
  47445. export * from "babylonjs/Events/clipboardEvents";
  47446. }
  47447. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  47448. import { Scene } from "babylonjs/scene";
  47449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47450. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47451. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47452. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47453. /**
  47454. * Google Daydream controller
  47455. */
  47456. export class DaydreamController extends WebVRController {
  47457. /**
  47458. * Base Url for the controller model.
  47459. */
  47460. static MODEL_BASE_URL: string;
  47461. /**
  47462. * File name for the controller model.
  47463. */
  47464. static MODEL_FILENAME: string;
  47465. /**
  47466. * Gamepad Id prefix used to identify Daydream Controller.
  47467. */
  47468. static readonly GAMEPAD_ID_PREFIX: string;
  47469. /**
  47470. * Creates a new DaydreamController from a gamepad
  47471. * @param vrGamepad the gamepad that the controller should be created from
  47472. */
  47473. constructor(vrGamepad: any);
  47474. /**
  47475. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47476. * @param scene scene in which to add meshes
  47477. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47478. */
  47479. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47480. /**
  47481. * Called once for each button that changed state since the last frame
  47482. * @param buttonIdx Which button index changed
  47483. * @param state New state of the button
  47484. * @param changes Which properties on the state changed since last frame
  47485. */
  47486. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47487. }
  47488. }
  47489. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  47490. import { Scene } from "babylonjs/scene";
  47491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47492. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47493. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47494. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47495. /**
  47496. * Gear VR Controller
  47497. */
  47498. export class GearVRController extends WebVRController {
  47499. /**
  47500. * Base Url for the controller model.
  47501. */
  47502. static MODEL_BASE_URL: string;
  47503. /**
  47504. * File name for the controller model.
  47505. */
  47506. static MODEL_FILENAME: string;
  47507. /**
  47508. * Gamepad Id prefix used to identify this controller.
  47509. */
  47510. static readonly GAMEPAD_ID_PREFIX: string;
  47511. private readonly _buttonIndexToObservableNameMap;
  47512. /**
  47513. * Creates a new GearVRController from a gamepad
  47514. * @param vrGamepad the gamepad that the controller should be created from
  47515. */
  47516. constructor(vrGamepad: any);
  47517. /**
  47518. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47519. * @param scene scene in which to add meshes
  47520. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47521. */
  47522. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47523. /**
  47524. * Called once for each button that changed state since the last frame
  47525. * @param buttonIdx Which button index changed
  47526. * @param state New state of the button
  47527. * @param changes Which properties on the state changed since last frame
  47528. */
  47529. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47530. }
  47531. }
  47532. declare module "babylonjs/Gamepads/Controllers/index" {
  47533. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  47534. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  47535. export * from "babylonjs/Gamepads/Controllers/genericController";
  47536. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  47537. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47538. export * from "babylonjs/Gamepads/Controllers/viveController";
  47539. export * from "babylonjs/Gamepads/Controllers/webVRController";
  47540. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  47541. }
  47542. declare module "babylonjs/Gamepads/index" {
  47543. export * from "babylonjs/Gamepads/Controllers/index";
  47544. export * from "babylonjs/Gamepads/gamepad";
  47545. export * from "babylonjs/Gamepads/gamepadManager";
  47546. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  47547. export * from "babylonjs/Gamepads/xboxGamepad";
  47548. export * from "babylonjs/Gamepads/dualShockGamepad";
  47549. }
  47550. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  47551. import { Scene } from "babylonjs/scene";
  47552. import { Vector4 } from "babylonjs/Maths/math.vector";
  47553. import { Color4 } from "babylonjs/Maths/math.color";
  47554. import { Mesh } from "babylonjs/Meshes/mesh";
  47555. import { Nullable } from "babylonjs/types";
  47556. /**
  47557. * Class containing static functions to help procedurally build meshes
  47558. */
  47559. export class PolyhedronBuilder {
  47560. /**
  47561. * Creates a polyhedron mesh
  47562. * * 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
  47563. * * The parameter `size` (positive float, default 1) sets the polygon size
  47564. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47565. * * 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`
  47566. * * 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
  47567. * * 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)`)
  47568. * * 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
  47569. * * 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
  47570. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47571. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47573. * @param name defines the name of the mesh
  47574. * @param options defines the options used to create the mesh
  47575. * @param scene defines the hosting scene
  47576. * @returns the polyhedron mesh
  47577. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47578. */
  47579. static CreatePolyhedron(name: string, options: {
  47580. type?: number;
  47581. size?: number;
  47582. sizeX?: number;
  47583. sizeY?: number;
  47584. sizeZ?: number;
  47585. custom?: any;
  47586. faceUV?: Vector4[];
  47587. faceColors?: Color4[];
  47588. flat?: boolean;
  47589. updatable?: boolean;
  47590. sideOrientation?: number;
  47591. frontUVs?: Vector4;
  47592. backUVs?: Vector4;
  47593. }, scene?: Nullable<Scene>): Mesh;
  47594. }
  47595. }
  47596. declare module "babylonjs/Gizmos/scaleGizmo" {
  47597. import { Observable } from "babylonjs/Misc/observable";
  47598. import { Nullable } from "babylonjs/types";
  47599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47600. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47601. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47602. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47603. /**
  47604. * Gizmo that enables scaling a mesh along 3 axis
  47605. */
  47606. export class ScaleGizmo extends Gizmo {
  47607. /**
  47608. * Internal gizmo used for interactions on the x axis
  47609. */
  47610. xGizmo: AxisScaleGizmo;
  47611. /**
  47612. * Internal gizmo used for interactions on the y axis
  47613. */
  47614. yGizmo: AxisScaleGizmo;
  47615. /**
  47616. * Internal gizmo used for interactions on the z axis
  47617. */
  47618. zGizmo: AxisScaleGizmo;
  47619. /**
  47620. * Internal gizmo used to scale all axis equally
  47621. */
  47622. uniformScaleGizmo: AxisScaleGizmo;
  47623. private _meshAttached;
  47624. private _updateGizmoRotationToMatchAttachedMesh;
  47625. private _snapDistance;
  47626. private _scaleRatio;
  47627. private _uniformScalingMesh;
  47628. private _octahedron;
  47629. /** Fires an event when any of it's sub gizmos are dragged */
  47630. onDragStartObservable: Observable<unknown>;
  47631. /** Fires an event when any of it's sub gizmos are released from dragging */
  47632. onDragEndObservable: Observable<unknown>;
  47633. attachedMesh: Nullable<AbstractMesh>;
  47634. /**
  47635. * Creates a ScaleGizmo
  47636. * @param gizmoLayer The utility layer the gizmo will be added to
  47637. */
  47638. constructor(gizmoLayer?: UtilityLayerRenderer);
  47639. updateGizmoRotationToMatchAttachedMesh: boolean;
  47640. /**
  47641. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47642. */
  47643. snapDistance: number;
  47644. /**
  47645. * Ratio for the scale of the gizmo (Default: 1)
  47646. */
  47647. scaleRatio: number;
  47648. /**
  47649. * Disposes of the gizmo
  47650. */
  47651. dispose(): void;
  47652. }
  47653. }
  47654. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  47655. import { Observable } from "babylonjs/Misc/observable";
  47656. import { Nullable } from "babylonjs/types";
  47657. import { Vector3 } from "babylonjs/Maths/math.vector";
  47658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47659. import { Mesh } from "babylonjs/Meshes/mesh";
  47660. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47661. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47662. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47663. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47664. import { Color3 } from "babylonjs/Maths/math.color";
  47665. /**
  47666. * Single axis scale gizmo
  47667. */
  47668. export class AxisScaleGizmo extends Gizmo {
  47669. /**
  47670. * Drag behavior responsible for the gizmos dragging interactions
  47671. */
  47672. dragBehavior: PointerDragBehavior;
  47673. private _pointerObserver;
  47674. /**
  47675. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47676. */
  47677. snapDistance: number;
  47678. /**
  47679. * Event that fires each time the gizmo snaps to a new location.
  47680. * * snapDistance is the the change in distance
  47681. */
  47682. onSnapObservable: Observable<{
  47683. snapDistance: number;
  47684. }>;
  47685. /**
  47686. * If the scaling operation should be done on all axis (default: false)
  47687. */
  47688. uniformScaling: boolean;
  47689. private _isEnabled;
  47690. private _parent;
  47691. private _arrow;
  47692. private _coloredMaterial;
  47693. private _hoverMaterial;
  47694. /**
  47695. * Creates an AxisScaleGizmo
  47696. * @param gizmoLayer The utility layer the gizmo will be added to
  47697. * @param dragAxis The axis which the gizmo will be able to scale on
  47698. * @param color The color of the gizmo
  47699. */
  47700. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47701. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47702. /**
  47703. * If the gizmo is enabled
  47704. */
  47705. isEnabled: boolean;
  47706. /**
  47707. * Disposes of the gizmo
  47708. */
  47709. dispose(): void;
  47710. /**
  47711. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47712. * @param mesh The mesh to replace the default mesh of the gizmo
  47713. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47714. */
  47715. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47716. }
  47717. }
  47718. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  47719. import { Observable } from "babylonjs/Misc/observable";
  47720. import { Nullable } from "babylonjs/types";
  47721. import { Vector3 } from "babylonjs/Maths/math.vector";
  47722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47723. import { Mesh } from "babylonjs/Meshes/mesh";
  47724. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47725. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47726. import { Color3 } from "babylonjs/Maths/math.color";
  47727. import "babylonjs/Meshes/Builders/boxBuilder";
  47728. /**
  47729. * Bounding box gizmo
  47730. */
  47731. export class BoundingBoxGizmo extends Gizmo {
  47732. private _lineBoundingBox;
  47733. private _rotateSpheresParent;
  47734. private _scaleBoxesParent;
  47735. private _boundingDimensions;
  47736. private _renderObserver;
  47737. private _pointerObserver;
  47738. private _scaleDragSpeed;
  47739. private _tmpQuaternion;
  47740. private _tmpVector;
  47741. private _tmpRotationMatrix;
  47742. /**
  47743. * 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)
  47744. */
  47745. ignoreChildren: boolean;
  47746. /**
  47747. * 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)
  47748. */
  47749. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47750. /**
  47751. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47752. */
  47753. rotationSphereSize: number;
  47754. /**
  47755. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47756. */
  47757. scaleBoxSize: number;
  47758. /**
  47759. * 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)
  47760. */
  47761. fixedDragMeshScreenSize: boolean;
  47762. /**
  47763. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47764. */
  47765. fixedDragMeshScreenSizeDistanceFactor: number;
  47766. /**
  47767. * Fired when a rotation sphere or scale box is dragged
  47768. */
  47769. onDragStartObservable: Observable<{}>;
  47770. /**
  47771. * Fired when a scale box is dragged
  47772. */
  47773. onScaleBoxDragObservable: Observable<{}>;
  47774. /**
  47775. * Fired when a scale box drag is ended
  47776. */
  47777. onScaleBoxDragEndObservable: Observable<{}>;
  47778. /**
  47779. * Fired when a rotation sphere is dragged
  47780. */
  47781. onRotationSphereDragObservable: Observable<{}>;
  47782. /**
  47783. * Fired when a rotation sphere drag is ended
  47784. */
  47785. onRotationSphereDragEndObservable: Observable<{}>;
  47786. /**
  47787. * 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)
  47788. */
  47789. scalePivot: Nullable<Vector3>;
  47790. /**
  47791. * Mesh used as a pivot to rotate the attached mesh
  47792. */
  47793. private _anchorMesh;
  47794. private _existingMeshScale;
  47795. private _dragMesh;
  47796. private pointerDragBehavior;
  47797. private coloredMaterial;
  47798. private hoverColoredMaterial;
  47799. /**
  47800. * Sets the color of the bounding box gizmo
  47801. * @param color the color to set
  47802. */
  47803. setColor(color: Color3): void;
  47804. /**
  47805. * Creates an BoundingBoxGizmo
  47806. * @param gizmoLayer The utility layer the gizmo will be added to
  47807. * @param color The color of the gizmo
  47808. */
  47809. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47810. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47811. private _selectNode;
  47812. /**
  47813. * Updates the bounding box information for the Gizmo
  47814. */
  47815. updateBoundingBox(): void;
  47816. private _updateRotationSpheres;
  47817. private _updateScaleBoxes;
  47818. /**
  47819. * Enables rotation on the specified axis and disables rotation on the others
  47820. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47821. */
  47822. setEnabledRotationAxis(axis: string): void;
  47823. /**
  47824. * Enables/disables scaling
  47825. * @param enable if scaling should be enabled
  47826. */
  47827. setEnabledScaling(enable: boolean): void;
  47828. private _updateDummy;
  47829. /**
  47830. * Enables a pointer drag behavior on the bounding box of the gizmo
  47831. */
  47832. enableDragBehavior(): void;
  47833. /**
  47834. * Disposes of the gizmo
  47835. */
  47836. dispose(): void;
  47837. /**
  47838. * 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)
  47839. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47840. * @returns the bounding box mesh with the passed in mesh as a child
  47841. */
  47842. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47843. /**
  47844. * CustomMeshes are not supported by this gizmo
  47845. * @param mesh The mesh to replace the default mesh of the gizmo
  47846. */
  47847. setCustomMesh(mesh: Mesh): void;
  47848. }
  47849. }
  47850. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47851. import { Observable } from "babylonjs/Misc/observable";
  47852. import { Nullable } from "babylonjs/types";
  47853. import { Vector3 } from "babylonjs/Maths/math.vector";
  47854. import { Color3 } from "babylonjs/Maths/math.color";
  47855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47856. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47857. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47858. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47859. import "babylonjs/Meshes/Builders/linesBuilder";
  47860. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47861. /**
  47862. * Single plane rotation gizmo
  47863. */
  47864. export class PlaneRotationGizmo extends Gizmo {
  47865. /**
  47866. * Drag behavior responsible for the gizmos dragging interactions
  47867. */
  47868. dragBehavior: PointerDragBehavior;
  47869. private _pointerObserver;
  47870. /**
  47871. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47872. */
  47873. snapDistance: number;
  47874. /**
  47875. * Event that fires each time the gizmo snaps to a new location.
  47876. * * snapDistance is the the change in distance
  47877. */
  47878. onSnapObservable: Observable<{
  47879. snapDistance: number;
  47880. }>;
  47881. private _isEnabled;
  47882. private _parent;
  47883. /**
  47884. * Creates a PlaneRotationGizmo
  47885. * @param gizmoLayer The utility layer the gizmo will be added to
  47886. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47887. * @param color The color of the gizmo
  47888. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47889. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47890. */
  47891. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47892. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47893. /**
  47894. * If the gizmo is enabled
  47895. */
  47896. isEnabled: boolean;
  47897. /**
  47898. * Disposes of the gizmo
  47899. */
  47900. dispose(): void;
  47901. }
  47902. }
  47903. declare module "babylonjs/Gizmos/rotationGizmo" {
  47904. import { Observable } from "babylonjs/Misc/observable";
  47905. import { Nullable } from "babylonjs/types";
  47906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47907. import { Mesh } from "babylonjs/Meshes/mesh";
  47908. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47909. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47910. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47911. /**
  47912. * Gizmo that enables rotating a mesh along 3 axis
  47913. */
  47914. export class RotationGizmo extends Gizmo {
  47915. /**
  47916. * Internal gizmo used for interactions on the x axis
  47917. */
  47918. xGizmo: PlaneRotationGizmo;
  47919. /**
  47920. * Internal gizmo used for interactions on the y axis
  47921. */
  47922. yGizmo: PlaneRotationGizmo;
  47923. /**
  47924. * Internal gizmo used for interactions on the z axis
  47925. */
  47926. zGizmo: PlaneRotationGizmo;
  47927. /** Fires an event when any of it's sub gizmos are dragged */
  47928. onDragStartObservable: Observable<unknown>;
  47929. /** Fires an event when any of it's sub gizmos are released from dragging */
  47930. onDragEndObservable: Observable<unknown>;
  47931. private _meshAttached;
  47932. attachedMesh: Nullable<AbstractMesh>;
  47933. /**
  47934. * Creates a RotationGizmo
  47935. * @param gizmoLayer The utility layer the gizmo will be added to
  47936. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47937. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47938. */
  47939. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47940. updateGizmoRotationToMatchAttachedMesh: boolean;
  47941. /**
  47942. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47943. */
  47944. snapDistance: number;
  47945. /**
  47946. * Ratio for the scale of the gizmo (Default: 1)
  47947. */
  47948. scaleRatio: number;
  47949. /**
  47950. * Disposes of the gizmo
  47951. */
  47952. dispose(): void;
  47953. /**
  47954. * CustomMeshes are not supported by this gizmo
  47955. * @param mesh The mesh to replace the default mesh of the gizmo
  47956. */
  47957. setCustomMesh(mesh: Mesh): void;
  47958. }
  47959. }
  47960. declare module "babylonjs/Gizmos/gizmoManager" {
  47961. import { Observable } from "babylonjs/Misc/observable";
  47962. import { Nullable } from "babylonjs/types";
  47963. import { Scene, IDisposable } from "babylonjs/scene";
  47964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47965. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47966. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47967. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47968. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47969. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47970. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47971. /**
  47972. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47973. */
  47974. export class GizmoManager implements IDisposable {
  47975. private scene;
  47976. /**
  47977. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47978. */
  47979. gizmos: {
  47980. positionGizmo: Nullable<PositionGizmo>;
  47981. rotationGizmo: Nullable<RotationGizmo>;
  47982. scaleGizmo: Nullable<ScaleGizmo>;
  47983. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47984. };
  47985. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47986. clearGizmoOnEmptyPointerEvent: boolean;
  47987. /** Fires an event when the manager is attached to a mesh */
  47988. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47989. private _gizmosEnabled;
  47990. private _pointerObserver;
  47991. private _attachedMesh;
  47992. private _boundingBoxColor;
  47993. private _defaultUtilityLayer;
  47994. private _defaultKeepDepthUtilityLayer;
  47995. /**
  47996. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47997. */
  47998. boundingBoxDragBehavior: SixDofDragBehavior;
  47999. /**
  48000. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48001. */
  48002. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48003. /**
  48004. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48005. */
  48006. usePointerToAttachGizmos: boolean;
  48007. /**
  48008. * Utility layer that the bounding box gizmo belongs to
  48009. */
  48010. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  48011. /**
  48012. * Utility layer that all gizmos besides bounding box belong to
  48013. */
  48014. readonly utilityLayer: UtilityLayerRenderer;
  48015. /**
  48016. * Instatiates a gizmo manager
  48017. * @param scene the scene to overlay the gizmos on top of
  48018. */
  48019. constructor(scene: Scene);
  48020. /**
  48021. * Attaches a set of gizmos to the specified mesh
  48022. * @param mesh The mesh the gizmo's should be attached to
  48023. */
  48024. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48025. /**
  48026. * If the position gizmo is enabled
  48027. */
  48028. positionGizmoEnabled: boolean;
  48029. /**
  48030. * If the rotation gizmo is enabled
  48031. */
  48032. rotationGizmoEnabled: boolean;
  48033. /**
  48034. * If the scale gizmo is enabled
  48035. */
  48036. scaleGizmoEnabled: boolean;
  48037. /**
  48038. * If the boundingBox gizmo is enabled
  48039. */
  48040. boundingBoxGizmoEnabled: boolean;
  48041. /**
  48042. * Disposes of the gizmo manager
  48043. */
  48044. dispose(): void;
  48045. }
  48046. }
  48047. declare module "babylonjs/Lights/directionalLight" {
  48048. import { Camera } from "babylonjs/Cameras/camera";
  48049. import { Scene } from "babylonjs/scene";
  48050. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48051. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48052. import { Light } from "babylonjs/Lights/light";
  48053. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48054. import { Effect } from "babylonjs/Materials/effect";
  48055. /**
  48056. * A directional light is defined by a direction (what a surprise!).
  48057. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48058. * 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.
  48059. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48060. */
  48061. export class DirectionalLight extends ShadowLight {
  48062. private _shadowFrustumSize;
  48063. /**
  48064. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48065. */
  48066. /**
  48067. * Specifies a fix frustum size for the shadow generation.
  48068. */
  48069. shadowFrustumSize: number;
  48070. private _shadowOrthoScale;
  48071. /**
  48072. * Gets the shadow projection scale against the optimal computed one.
  48073. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48074. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48075. */
  48076. /**
  48077. * Sets the shadow projection scale against the optimal computed one.
  48078. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48079. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48080. */
  48081. shadowOrthoScale: number;
  48082. /**
  48083. * Automatically compute the projection matrix to best fit (including all the casters)
  48084. * on each frame.
  48085. */
  48086. autoUpdateExtends: boolean;
  48087. private _orthoLeft;
  48088. private _orthoRight;
  48089. private _orthoTop;
  48090. private _orthoBottom;
  48091. /**
  48092. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48093. * The directional light is emitted from everywhere in the given direction.
  48094. * It can cast shadows.
  48095. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48096. * @param name The friendly name of the light
  48097. * @param direction The direction of the light
  48098. * @param scene The scene the light belongs to
  48099. */
  48100. constructor(name: string, direction: Vector3, scene: Scene);
  48101. /**
  48102. * Returns the string "DirectionalLight".
  48103. * @return The class name
  48104. */
  48105. getClassName(): string;
  48106. /**
  48107. * Returns the integer 1.
  48108. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48109. */
  48110. getTypeID(): number;
  48111. /**
  48112. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48113. * Returns the DirectionalLight Shadow projection matrix.
  48114. */
  48115. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48116. /**
  48117. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48118. * Returns the DirectionalLight Shadow projection matrix.
  48119. */
  48120. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48121. /**
  48122. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48123. * Returns the DirectionalLight Shadow projection matrix.
  48124. */
  48125. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48126. protected _buildUniformLayout(): void;
  48127. /**
  48128. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48129. * @param effect The effect to update
  48130. * @param lightIndex The index of the light in the effect to update
  48131. * @returns The directional light
  48132. */
  48133. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48134. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48135. /**
  48136. * Gets the minZ 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 min for
  48141. * @returns the depth min z
  48142. */
  48143. getDepthMinZ(activeCamera: Camera): number;
  48144. /**
  48145. * Gets the maxZ used for shadow according to both the scene and the light.
  48146. *
  48147. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48148. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48149. * @param activeCamera The camera we are returning the max for
  48150. * @returns the depth max z
  48151. */
  48152. getDepthMaxZ(activeCamera: Camera): number;
  48153. /**
  48154. * Prepares the list of defines specific to the light type.
  48155. * @param defines the list of defines
  48156. * @param lightIndex defines the index of the light for the effect
  48157. */
  48158. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48159. }
  48160. }
  48161. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  48162. import { Mesh } from "babylonjs/Meshes/mesh";
  48163. /**
  48164. * Class containing static functions to help procedurally build meshes
  48165. */
  48166. export class HemisphereBuilder {
  48167. /**
  48168. * Creates a hemisphere mesh
  48169. * @param name defines the name of the mesh
  48170. * @param options defines the options used to create the mesh
  48171. * @param scene defines the hosting scene
  48172. * @returns the hemisphere mesh
  48173. */
  48174. static CreateHemisphere(name: string, options: {
  48175. segments?: number;
  48176. diameter?: number;
  48177. sideOrientation?: number;
  48178. }, scene: any): Mesh;
  48179. }
  48180. }
  48181. declare module "babylonjs/Lights/spotLight" {
  48182. import { Nullable } from "babylonjs/types";
  48183. import { Scene } from "babylonjs/scene";
  48184. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48186. import { Effect } from "babylonjs/Materials/effect";
  48187. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48188. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48189. /**
  48190. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48191. * These values define a cone of light starting from the position, emitting toward the direction.
  48192. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48193. * and the exponent defines the speed of the decay of the light with distance (reach).
  48194. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48195. */
  48196. export class SpotLight extends ShadowLight {
  48197. private _angle;
  48198. private _innerAngle;
  48199. private _cosHalfAngle;
  48200. private _lightAngleScale;
  48201. private _lightAngleOffset;
  48202. /**
  48203. * Gets the cone angle of the spot light in Radians.
  48204. */
  48205. /**
  48206. * Sets the cone angle of the spot light in Radians.
  48207. */
  48208. angle: number;
  48209. /**
  48210. * Only used in gltf falloff mode, this defines the angle where
  48211. * the directional falloff will start before cutting at angle which could be seen
  48212. * as outer angle.
  48213. */
  48214. /**
  48215. * Only used in gltf falloff mode, this defines the angle where
  48216. * the directional falloff will start before cutting at angle which could be seen
  48217. * as outer angle.
  48218. */
  48219. innerAngle: number;
  48220. private _shadowAngleScale;
  48221. /**
  48222. * Allows scaling the angle of the light for shadow generation only.
  48223. */
  48224. /**
  48225. * Allows scaling the angle of the light for shadow generation only.
  48226. */
  48227. shadowAngleScale: number;
  48228. /**
  48229. * The light decay speed with the distance from the emission spot.
  48230. */
  48231. exponent: number;
  48232. private _projectionTextureMatrix;
  48233. /**
  48234. * Allows reading the projecton texture
  48235. */
  48236. readonly projectionTextureMatrix: Matrix;
  48237. protected _projectionTextureLightNear: number;
  48238. /**
  48239. * Gets the near clip of the Spotlight for texture projection.
  48240. */
  48241. /**
  48242. * Sets the near clip of the Spotlight for texture projection.
  48243. */
  48244. projectionTextureLightNear: number;
  48245. protected _projectionTextureLightFar: number;
  48246. /**
  48247. * Gets the far clip of the Spotlight for texture projection.
  48248. */
  48249. /**
  48250. * Sets the far clip of the Spotlight for texture projection.
  48251. */
  48252. projectionTextureLightFar: number;
  48253. protected _projectionTextureUpDirection: Vector3;
  48254. /**
  48255. * Gets the Up vector of the Spotlight for texture projection.
  48256. */
  48257. /**
  48258. * Sets the Up vector of the Spotlight for texture projection.
  48259. */
  48260. projectionTextureUpDirection: Vector3;
  48261. private _projectionTexture;
  48262. /**
  48263. * Gets the projection texture of the light.
  48264. */
  48265. /**
  48266. * Sets the projection texture of the light.
  48267. */
  48268. projectionTexture: Nullable<BaseTexture>;
  48269. private _projectionTextureViewLightDirty;
  48270. private _projectionTextureProjectionLightDirty;
  48271. private _projectionTextureDirty;
  48272. private _projectionTextureViewTargetVector;
  48273. private _projectionTextureViewLightMatrix;
  48274. private _projectionTextureProjectionLightMatrix;
  48275. private _projectionTextureScalingMatrix;
  48276. /**
  48277. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48278. * It can cast shadows.
  48279. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48280. * @param name The light friendly name
  48281. * @param position The position of the spot light in the scene
  48282. * @param direction The direction of the light in the scene
  48283. * @param angle The cone angle of the light in Radians
  48284. * @param exponent The light decay speed with the distance from the emission spot
  48285. * @param scene The scene the lights belongs to
  48286. */
  48287. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48288. /**
  48289. * Returns the string "SpotLight".
  48290. * @returns the class name
  48291. */
  48292. getClassName(): string;
  48293. /**
  48294. * Returns the integer 2.
  48295. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48296. */
  48297. getTypeID(): number;
  48298. /**
  48299. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48300. */
  48301. protected _setDirection(value: Vector3): void;
  48302. /**
  48303. * Overrides the position setter to recompute the projection texture view light Matrix.
  48304. */
  48305. protected _setPosition(value: Vector3): void;
  48306. /**
  48307. * 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.
  48308. * Returns the SpotLight.
  48309. */
  48310. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48311. protected _computeProjectionTextureViewLightMatrix(): void;
  48312. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48313. /**
  48314. * Main function for light texture projection matrix computing.
  48315. */
  48316. protected _computeProjectionTextureMatrix(): void;
  48317. protected _buildUniformLayout(): void;
  48318. private _computeAngleValues;
  48319. /**
  48320. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48321. * @param effect The effect to update
  48322. * @param lightIndex The index of the light in the effect to update
  48323. * @returns The spot light
  48324. */
  48325. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48326. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48327. /**
  48328. * Disposes the light and the associated resources.
  48329. */
  48330. dispose(): void;
  48331. /**
  48332. * Prepares the list of defines specific to the light type.
  48333. * @param defines the list of defines
  48334. * @param lightIndex defines the index of the light for the effect
  48335. */
  48336. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48337. }
  48338. }
  48339. declare module "babylonjs/Gizmos/lightGizmo" {
  48340. import { Nullable } from "babylonjs/types";
  48341. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48342. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48343. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48344. import { Light } from "babylonjs/Lights/light";
  48345. /**
  48346. * Gizmo that enables viewing a light
  48347. */
  48348. export class LightGizmo extends Gizmo {
  48349. private _lightMesh;
  48350. private _material;
  48351. private _cachedPosition;
  48352. private _cachedForward;
  48353. private _attachedMeshParent;
  48354. /**
  48355. * Creates a LightGizmo
  48356. * @param gizmoLayer The utility layer the gizmo will be added to
  48357. */
  48358. constructor(gizmoLayer?: UtilityLayerRenderer);
  48359. private _light;
  48360. /**
  48361. * The light that the gizmo is attached to
  48362. */
  48363. light: Nullable<Light>;
  48364. /**
  48365. * Gets the material used to render the light gizmo
  48366. */
  48367. readonly material: StandardMaterial;
  48368. /**
  48369. * @hidden
  48370. * Updates the gizmo to match the attached mesh's position/rotation
  48371. */
  48372. protected _update(): void;
  48373. private static _Scale;
  48374. /**
  48375. * Creates the lines for a light mesh
  48376. */
  48377. private static _CreateLightLines;
  48378. /**
  48379. * Disposes of the light gizmo
  48380. */
  48381. dispose(): void;
  48382. private static _CreateHemisphericLightMesh;
  48383. private static _CreatePointLightMesh;
  48384. private static _CreateSpotLightMesh;
  48385. private static _CreateDirectionalLightMesh;
  48386. }
  48387. }
  48388. declare module "babylonjs/Gizmos/index" {
  48389. export * from "babylonjs/Gizmos/axisDragGizmo";
  48390. export * from "babylonjs/Gizmos/axisScaleGizmo";
  48391. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  48392. export * from "babylonjs/Gizmos/gizmo";
  48393. export * from "babylonjs/Gizmos/gizmoManager";
  48394. export * from "babylonjs/Gizmos/planeRotationGizmo";
  48395. export * from "babylonjs/Gizmos/positionGizmo";
  48396. export * from "babylonjs/Gizmos/rotationGizmo";
  48397. export * from "babylonjs/Gizmos/scaleGizmo";
  48398. export * from "babylonjs/Gizmos/lightGizmo";
  48399. export * from "babylonjs/Gizmos/planeDragGizmo";
  48400. }
  48401. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  48402. /** @hidden */
  48403. export var backgroundFragmentDeclaration: {
  48404. name: string;
  48405. shader: string;
  48406. };
  48407. }
  48408. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  48409. /** @hidden */
  48410. export var backgroundUboDeclaration: {
  48411. name: string;
  48412. shader: string;
  48413. };
  48414. }
  48415. declare module "babylonjs/Shaders/background.fragment" {
  48416. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  48417. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48418. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48419. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48420. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48421. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48422. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48423. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  48424. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48425. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48426. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48427. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48428. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48429. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48430. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48431. /** @hidden */
  48432. export var backgroundPixelShader: {
  48433. name: string;
  48434. shader: string;
  48435. };
  48436. }
  48437. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  48438. /** @hidden */
  48439. export var backgroundVertexDeclaration: {
  48440. name: string;
  48441. shader: string;
  48442. };
  48443. }
  48444. declare module "babylonjs/Shaders/background.vertex" {
  48445. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  48446. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48447. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48448. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48449. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48450. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48451. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48452. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48453. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48454. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48455. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48456. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48457. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48458. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48459. /** @hidden */
  48460. export var backgroundVertexShader: {
  48461. name: string;
  48462. shader: string;
  48463. };
  48464. }
  48465. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  48466. import { Nullable, int, float } from "babylonjs/types";
  48467. import { Scene } from "babylonjs/scene";
  48468. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48469. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48470. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48471. import { Mesh } from "babylonjs/Meshes/mesh";
  48472. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48473. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48474. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48475. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48476. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  48477. import { Color3 } from "babylonjs/Maths/math.color";
  48478. import "babylonjs/Shaders/background.fragment";
  48479. import "babylonjs/Shaders/background.vertex";
  48480. /**
  48481. * Background material used to create an efficient environement around your scene.
  48482. */
  48483. export class BackgroundMaterial extends PushMaterial {
  48484. /**
  48485. * Standard reflectance value at parallel view angle.
  48486. */
  48487. static StandardReflectance0: number;
  48488. /**
  48489. * Standard reflectance value at grazing angle.
  48490. */
  48491. static StandardReflectance90: number;
  48492. protected _primaryColor: Color3;
  48493. /**
  48494. * Key light Color (multiply against the environement texture)
  48495. */
  48496. primaryColor: Color3;
  48497. protected __perceptualColor: Nullable<Color3>;
  48498. /**
  48499. * Experimental Internal Use Only.
  48500. *
  48501. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48502. * This acts as a helper to set the primary color to a more "human friendly" value.
  48503. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48504. * output color as close as possible from the chosen value.
  48505. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48506. * part of lighting setup.)
  48507. */
  48508. _perceptualColor: Nullable<Color3>;
  48509. protected _primaryColorShadowLevel: float;
  48510. /**
  48511. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48512. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48513. */
  48514. primaryColorShadowLevel: float;
  48515. protected _primaryColorHighlightLevel: float;
  48516. /**
  48517. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48518. * The primary color is used at the level chosen to define what the white area would look.
  48519. */
  48520. primaryColorHighlightLevel: float;
  48521. protected _reflectionTexture: Nullable<BaseTexture>;
  48522. /**
  48523. * Reflection Texture used in the material.
  48524. * Should be author in a specific way for the best result (refer to the documentation).
  48525. */
  48526. reflectionTexture: Nullable<BaseTexture>;
  48527. protected _reflectionBlur: float;
  48528. /**
  48529. * Reflection Texture level of blur.
  48530. *
  48531. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48532. * texture twice.
  48533. */
  48534. reflectionBlur: float;
  48535. protected _diffuseTexture: Nullable<BaseTexture>;
  48536. /**
  48537. * Diffuse Texture used in the material.
  48538. * Should be author in a specific way for the best result (refer to the documentation).
  48539. */
  48540. diffuseTexture: Nullable<BaseTexture>;
  48541. protected _shadowLights: Nullable<IShadowLight[]>;
  48542. /**
  48543. * Specify the list of lights casting shadow on the material.
  48544. * All scene shadow lights will be included if null.
  48545. */
  48546. shadowLights: Nullable<IShadowLight[]>;
  48547. protected _shadowLevel: float;
  48548. /**
  48549. * Helps adjusting the shadow to a softer level if required.
  48550. * 0 means black shadows and 1 means no shadows.
  48551. */
  48552. shadowLevel: float;
  48553. protected _sceneCenter: Vector3;
  48554. /**
  48555. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48556. * It is usually zero but might be interesting to modify according to your setup.
  48557. */
  48558. sceneCenter: Vector3;
  48559. protected _opacityFresnel: boolean;
  48560. /**
  48561. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48562. * This helps ensuring a nice transition when the camera goes under the ground.
  48563. */
  48564. opacityFresnel: boolean;
  48565. protected _reflectionFresnel: boolean;
  48566. /**
  48567. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48568. * This helps adding a mirror texture on the ground.
  48569. */
  48570. reflectionFresnel: boolean;
  48571. protected _reflectionFalloffDistance: number;
  48572. /**
  48573. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48574. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48575. */
  48576. reflectionFalloffDistance: number;
  48577. protected _reflectionAmount: number;
  48578. /**
  48579. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48580. */
  48581. reflectionAmount: number;
  48582. protected _reflectionReflectance0: number;
  48583. /**
  48584. * This specifies the weight of the reflection at grazing angle.
  48585. */
  48586. reflectionReflectance0: number;
  48587. protected _reflectionReflectance90: number;
  48588. /**
  48589. * This specifies the weight of the reflection at a perpendicular point of view.
  48590. */
  48591. reflectionReflectance90: number;
  48592. /**
  48593. * Sets the reflection reflectance fresnel values according to the default standard
  48594. * empirically know to work well :-)
  48595. */
  48596. reflectionStandardFresnelWeight: number;
  48597. protected _useRGBColor: boolean;
  48598. /**
  48599. * Helps to directly use the maps channels instead of their level.
  48600. */
  48601. useRGBColor: boolean;
  48602. protected _enableNoise: boolean;
  48603. /**
  48604. * This helps reducing the banding effect that could occur on the background.
  48605. */
  48606. enableNoise: boolean;
  48607. /**
  48608. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48609. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48610. * Recommended to be keep at 1.0 except for special cases.
  48611. */
  48612. fovMultiplier: number;
  48613. private _fovMultiplier;
  48614. /**
  48615. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48616. */
  48617. useEquirectangularFOV: boolean;
  48618. private _maxSimultaneousLights;
  48619. /**
  48620. * Number of Simultaneous lights allowed on the material.
  48621. */
  48622. maxSimultaneousLights: int;
  48623. /**
  48624. * Default configuration related to image processing available in the Background Material.
  48625. */
  48626. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48627. /**
  48628. * Keep track of the image processing observer to allow dispose and replace.
  48629. */
  48630. private _imageProcessingObserver;
  48631. /**
  48632. * Attaches a new image processing configuration to the PBR Material.
  48633. * @param configuration (if null the scene configuration will be use)
  48634. */
  48635. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48636. /**
  48637. * Gets the image processing configuration used either in this material.
  48638. */
  48639. /**
  48640. * Sets the Default image processing configuration used either in the this material.
  48641. *
  48642. * If sets to null, the scene one is in use.
  48643. */
  48644. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  48645. /**
  48646. * Gets wether the color curves effect is enabled.
  48647. */
  48648. /**
  48649. * Sets wether the color curves effect is enabled.
  48650. */
  48651. cameraColorCurvesEnabled: boolean;
  48652. /**
  48653. * Gets wether the color grading effect is enabled.
  48654. */
  48655. /**
  48656. * Gets wether the color grading effect is enabled.
  48657. */
  48658. cameraColorGradingEnabled: boolean;
  48659. /**
  48660. * Gets wether tonemapping is enabled or not.
  48661. */
  48662. /**
  48663. * Sets wether tonemapping is enabled or not
  48664. */
  48665. cameraToneMappingEnabled: boolean;
  48666. /**
  48667. * The camera exposure used on this material.
  48668. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48669. * This corresponds to a photographic exposure.
  48670. */
  48671. /**
  48672. * The camera exposure used on this material.
  48673. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48674. * This corresponds to a photographic exposure.
  48675. */
  48676. cameraExposure: float;
  48677. /**
  48678. * Gets The camera contrast used on this material.
  48679. */
  48680. /**
  48681. * Sets The camera contrast used on this material.
  48682. */
  48683. cameraContrast: float;
  48684. /**
  48685. * Gets the Color Grading 2D Lookup Texture.
  48686. */
  48687. /**
  48688. * Sets the Color Grading 2D Lookup Texture.
  48689. */
  48690. cameraColorGradingTexture: Nullable<BaseTexture>;
  48691. /**
  48692. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48693. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48694. * 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;
  48695. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48696. */
  48697. /**
  48698. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48699. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48700. * 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;
  48701. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48702. */
  48703. cameraColorCurves: Nullable<ColorCurves>;
  48704. /**
  48705. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48706. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48707. */
  48708. switchToBGR: boolean;
  48709. private _renderTargets;
  48710. private _reflectionControls;
  48711. private _white;
  48712. private _primaryShadowColor;
  48713. private _primaryHighlightColor;
  48714. /**
  48715. * Instantiates a Background Material in the given scene
  48716. * @param name The friendly name of the material
  48717. * @param scene The scene to add the material to
  48718. */
  48719. constructor(name: string, scene: Scene);
  48720. /**
  48721. * Gets a boolean indicating that current material needs to register RTT
  48722. */
  48723. readonly hasRenderTargetTextures: boolean;
  48724. /**
  48725. * The entire material has been created in order to prevent overdraw.
  48726. * @returns false
  48727. */
  48728. needAlphaTesting(): boolean;
  48729. /**
  48730. * The entire material has been created in order to prevent overdraw.
  48731. * @returns true if blending is enable
  48732. */
  48733. needAlphaBlending(): boolean;
  48734. /**
  48735. * Checks wether the material is ready to be rendered for a given mesh.
  48736. * @param mesh The mesh to render
  48737. * @param subMesh The submesh to check against
  48738. * @param useInstances Specify wether or not the material is used with instances
  48739. * @returns true if all the dependencies are ready (Textures, Effects...)
  48740. */
  48741. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48742. /**
  48743. * Compute the primary color according to the chosen perceptual color.
  48744. */
  48745. private _computePrimaryColorFromPerceptualColor;
  48746. /**
  48747. * Compute the highlights and shadow colors according to their chosen levels.
  48748. */
  48749. private _computePrimaryColors;
  48750. /**
  48751. * Build the uniform buffer used in the material.
  48752. */
  48753. buildUniformLayout(): void;
  48754. /**
  48755. * Unbind the material.
  48756. */
  48757. unbind(): void;
  48758. /**
  48759. * Bind only the world matrix to the material.
  48760. * @param world The world matrix to bind.
  48761. */
  48762. bindOnlyWorldMatrix(world: Matrix): void;
  48763. /**
  48764. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48765. * @param world The world matrix to bind.
  48766. * @param subMesh The submesh to bind for.
  48767. */
  48768. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48769. /**
  48770. * Checks to see if a texture is used in the material.
  48771. * @param texture - Base texture to use.
  48772. * @returns - Boolean specifying if a texture is used in the material.
  48773. */
  48774. hasTexture(texture: BaseTexture): boolean;
  48775. /**
  48776. * Dispose the material.
  48777. * @param forceDisposeEffect Force disposal of the associated effect.
  48778. * @param forceDisposeTextures Force disposal of the associated textures.
  48779. */
  48780. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48781. /**
  48782. * Clones the material.
  48783. * @param name The cloned name.
  48784. * @returns The cloned material.
  48785. */
  48786. clone(name: string): BackgroundMaterial;
  48787. /**
  48788. * Serializes the current material to its JSON representation.
  48789. * @returns The JSON representation.
  48790. */
  48791. serialize(): any;
  48792. /**
  48793. * Gets the class name of the material
  48794. * @returns "BackgroundMaterial"
  48795. */
  48796. getClassName(): string;
  48797. /**
  48798. * Parse a JSON input to create back a background material.
  48799. * @param source The JSON data to parse
  48800. * @param scene The scene to create the parsed material in
  48801. * @param rootUrl The root url of the assets the material depends upon
  48802. * @returns the instantiated BackgroundMaterial.
  48803. */
  48804. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48805. }
  48806. }
  48807. declare module "babylonjs/Helpers/environmentHelper" {
  48808. import { Observable } from "babylonjs/Misc/observable";
  48809. import { Nullable } from "babylonjs/types";
  48810. import { Scene } from "babylonjs/scene";
  48811. import { Vector3 } from "babylonjs/Maths/math.vector";
  48812. import { Color3 } from "babylonjs/Maths/math.color";
  48813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48814. import { Mesh } from "babylonjs/Meshes/mesh";
  48815. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48816. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48817. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48818. import "babylonjs/Meshes/Builders/planeBuilder";
  48819. import "babylonjs/Meshes/Builders/boxBuilder";
  48820. /**
  48821. * Represents the different options available during the creation of
  48822. * a Environment helper.
  48823. *
  48824. * This can control the default ground, skybox and image processing setup of your scene.
  48825. */
  48826. export interface IEnvironmentHelperOptions {
  48827. /**
  48828. * Specifies wether or not to create a ground.
  48829. * True by default.
  48830. */
  48831. createGround: boolean;
  48832. /**
  48833. * Specifies the ground size.
  48834. * 15 by default.
  48835. */
  48836. groundSize: number;
  48837. /**
  48838. * The texture used on the ground for the main color.
  48839. * Comes from the BabylonJS CDN by default.
  48840. *
  48841. * Remarks: Can be either a texture or a url.
  48842. */
  48843. groundTexture: string | BaseTexture;
  48844. /**
  48845. * The color mixed in the ground texture by default.
  48846. * BabylonJS clearColor by default.
  48847. */
  48848. groundColor: Color3;
  48849. /**
  48850. * Specifies the ground opacity.
  48851. * 1 by default.
  48852. */
  48853. groundOpacity: number;
  48854. /**
  48855. * Enables the ground to receive shadows.
  48856. * True by default.
  48857. */
  48858. enableGroundShadow: boolean;
  48859. /**
  48860. * Helps preventing the shadow to be fully black on the ground.
  48861. * 0.5 by default.
  48862. */
  48863. groundShadowLevel: number;
  48864. /**
  48865. * Creates a mirror texture attach to the ground.
  48866. * false by default.
  48867. */
  48868. enableGroundMirror: boolean;
  48869. /**
  48870. * Specifies the ground mirror size ratio.
  48871. * 0.3 by default as the default kernel is 64.
  48872. */
  48873. groundMirrorSizeRatio: number;
  48874. /**
  48875. * Specifies the ground mirror blur kernel size.
  48876. * 64 by default.
  48877. */
  48878. groundMirrorBlurKernel: number;
  48879. /**
  48880. * Specifies the ground mirror visibility amount.
  48881. * 1 by default
  48882. */
  48883. groundMirrorAmount: number;
  48884. /**
  48885. * Specifies the ground mirror reflectance weight.
  48886. * This uses the standard weight of the background material to setup the fresnel effect
  48887. * of the mirror.
  48888. * 1 by default.
  48889. */
  48890. groundMirrorFresnelWeight: number;
  48891. /**
  48892. * Specifies the ground mirror Falloff distance.
  48893. * This can helps reducing the size of the reflection.
  48894. * 0 by Default.
  48895. */
  48896. groundMirrorFallOffDistance: number;
  48897. /**
  48898. * Specifies the ground mirror texture type.
  48899. * Unsigned Int by Default.
  48900. */
  48901. groundMirrorTextureType: number;
  48902. /**
  48903. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48904. * the shown objects.
  48905. */
  48906. groundYBias: number;
  48907. /**
  48908. * Specifies wether or not to create a skybox.
  48909. * True by default.
  48910. */
  48911. createSkybox: boolean;
  48912. /**
  48913. * Specifies the skybox size.
  48914. * 20 by default.
  48915. */
  48916. skyboxSize: number;
  48917. /**
  48918. * The texture used on the skybox for the main color.
  48919. * Comes from the BabylonJS CDN by default.
  48920. *
  48921. * Remarks: Can be either a texture or a url.
  48922. */
  48923. skyboxTexture: string | BaseTexture;
  48924. /**
  48925. * The color mixed in the skybox texture by default.
  48926. * BabylonJS clearColor by default.
  48927. */
  48928. skyboxColor: Color3;
  48929. /**
  48930. * The background rotation around the Y axis of the scene.
  48931. * This helps aligning the key lights of your scene with the background.
  48932. * 0 by default.
  48933. */
  48934. backgroundYRotation: number;
  48935. /**
  48936. * Compute automatically the size of the elements to best fit with the scene.
  48937. */
  48938. sizeAuto: boolean;
  48939. /**
  48940. * Default position of the rootMesh if autoSize is not true.
  48941. */
  48942. rootPosition: Vector3;
  48943. /**
  48944. * Sets up the image processing in the scene.
  48945. * true by default.
  48946. */
  48947. setupImageProcessing: boolean;
  48948. /**
  48949. * The texture used as your environment texture in the scene.
  48950. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48951. *
  48952. * Remarks: Can be either a texture or a url.
  48953. */
  48954. environmentTexture: string | BaseTexture;
  48955. /**
  48956. * The value of the exposure to apply to the scene.
  48957. * 0.6 by default if setupImageProcessing is true.
  48958. */
  48959. cameraExposure: number;
  48960. /**
  48961. * The value of the contrast to apply to the scene.
  48962. * 1.6 by default if setupImageProcessing is true.
  48963. */
  48964. cameraContrast: number;
  48965. /**
  48966. * Specifies wether or not tonemapping should be enabled in the scene.
  48967. * true by default if setupImageProcessing is true.
  48968. */
  48969. toneMappingEnabled: boolean;
  48970. }
  48971. /**
  48972. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48973. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48974. * It also helps with the default setup of your imageProcessing configuration.
  48975. */
  48976. export class EnvironmentHelper {
  48977. /**
  48978. * Default ground texture URL.
  48979. */
  48980. private static _groundTextureCDNUrl;
  48981. /**
  48982. * Default skybox texture URL.
  48983. */
  48984. private static _skyboxTextureCDNUrl;
  48985. /**
  48986. * Default environment texture URL.
  48987. */
  48988. private static _environmentTextureCDNUrl;
  48989. /**
  48990. * Creates the default options for the helper.
  48991. */
  48992. private static _getDefaultOptions;
  48993. private _rootMesh;
  48994. /**
  48995. * Gets the root mesh created by the helper.
  48996. */
  48997. readonly rootMesh: Mesh;
  48998. private _skybox;
  48999. /**
  49000. * Gets the skybox created by the helper.
  49001. */
  49002. readonly skybox: Nullable<Mesh>;
  49003. private _skyboxTexture;
  49004. /**
  49005. * Gets the skybox texture created by the helper.
  49006. */
  49007. readonly skyboxTexture: Nullable<BaseTexture>;
  49008. private _skyboxMaterial;
  49009. /**
  49010. * Gets the skybox material created by the helper.
  49011. */
  49012. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  49013. private _ground;
  49014. /**
  49015. * Gets the ground mesh created by the helper.
  49016. */
  49017. readonly ground: Nullable<Mesh>;
  49018. private _groundTexture;
  49019. /**
  49020. * Gets the ground texture created by the helper.
  49021. */
  49022. readonly groundTexture: Nullable<BaseTexture>;
  49023. private _groundMirror;
  49024. /**
  49025. * Gets the ground mirror created by the helper.
  49026. */
  49027. readonly groundMirror: Nullable<MirrorTexture>;
  49028. /**
  49029. * Gets the ground mirror render list to helps pushing the meshes
  49030. * you wish in the ground reflection.
  49031. */
  49032. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  49033. private _groundMaterial;
  49034. /**
  49035. * Gets the ground material created by the helper.
  49036. */
  49037. readonly groundMaterial: Nullable<BackgroundMaterial>;
  49038. /**
  49039. * Stores the creation options.
  49040. */
  49041. private readonly _scene;
  49042. private _options;
  49043. /**
  49044. * This observable will be notified with any error during the creation of the environment,
  49045. * mainly texture creation errors.
  49046. */
  49047. onErrorObservable: Observable<{
  49048. message?: string;
  49049. exception?: any;
  49050. }>;
  49051. /**
  49052. * constructor
  49053. * @param options Defines the options we want to customize the helper
  49054. * @param scene The scene to add the material to
  49055. */
  49056. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49057. /**
  49058. * Updates the background according to the new options
  49059. * @param options
  49060. */
  49061. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49062. /**
  49063. * Sets the primary color of all the available elements.
  49064. * @param color the main color to affect to the ground and the background
  49065. */
  49066. setMainColor(color: Color3): void;
  49067. /**
  49068. * Setup the image processing according to the specified options.
  49069. */
  49070. private _setupImageProcessing;
  49071. /**
  49072. * Setup the environment texture according to the specified options.
  49073. */
  49074. private _setupEnvironmentTexture;
  49075. /**
  49076. * Setup the background according to the specified options.
  49077. */
  49078. private _setupBackground;
  49079. /**
  49080. * Get the scene sizes according to the setup.
  49081. */
  49082. private _getSceneSize;
  49083. /**
  49084. * Setup the ground according to the specified options.
  49085. */
  49086. private _setupGround;
  49087. /**
  49088. * Setup the ground material according to the specified options.
  49089. */
  49090. private _setupGroundMaterial;
  49091. /**
  49092. * Setup the ground diffuse texture according to the specified options.
  49093. */
  49094. private _setupGroundDiffuseTexture;
  49095. /**
  49096. * Setup the ground mirror texture according to the specified options.
  49097. */
  49098. private _setupGroundMirrorTexture;
  49099. /**
  49100. * Setup the ground to receive the mirror texture.
  49101. */
  49102. private _setupMirrorInGroundMaterial;
  49103. /**
  49104. * Setup the skybox according to the specified options.
  49105. */
  49106. private _setupSkybox;
  49107. /**
  49108. * Setup the skybox material according to the specified options.
  49109. */
  49110. private _setupSkyboxMaterial;
  49111. /**
  49112. * Setup the skybox reflection texture according to the specified options.
  49113. */
  49114. private _setupSkyboxReflectionTexture;
  49115. private _errorHandler;
  49116. /**
  49117. * Dispose all the elements created by the Helper.
  49118. */
  49119. dispose(): void;
  49120. }
  49121. }
  49122. declare module "babylonjs/Helpers/photoDome" {
  49123. import { Observable } from "babylonjs/Misc/observable";
  49124. import { Nullable } from "babylonjs/types";
  49125. import { Scene } from "babylonjs/scene";
  49126. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49127. import { Mesh } from "babylonjs/Meshes/mesh";
  49128. import { Texture } from "babylonjs/Materials/Textures/texture";
  49129. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49130. import "babylonjs/Meshes/Builders/sphereBuilder";
  49131. /**
  49132. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49133. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49134. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49135. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49136. */
  49137. export class PhotoDome extends TransformNode {
  49138. /**
  49139. * Define the image as a Monoscopic panoramic 360 image.
  49140. */
  49141. static readonly MODE_MONOSCOPIC: number;
  49142. /**
  49143. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49144. */
  49145. static readonly MODE_TOPBOTTOM: number;
  49146. /**
  49147. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49148. */
  49149. static readonly MODE_SIDEBYSIDE: number;
  49150. private _useDirectMapping;
  49151. /**
  49152. * The texture being displayed on the sphere
  49153. */
  49154. protected _photoTexture: Texture;
  49155. /**
  49156. * Gets or sets the texture being displayed on the sphere
  49157. */
  49158. photoTexture: Texture;
  49159. /**
  49160. * Observable raised when an error occured while loading the 360 image
  49161. */
  49162. onLoadErrorObservable: Observable<string>;
  49163. /**
  49164. * The skybox material
  49165. */
  49166. protected _material: BackgroundMaterial;
  49167. /**
  49168. * The surface used for the skybox
  49169. */
  49170. protected _mesh: Mesh;
  49171. /**
  49172. * Gets the mesh used for the skybox.
  49173. */
  49174. readonly mesh: Mesh;
  49175. /**
  49176. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49177. * Also see the options.resolution property.
  49178. */
  49179. fovMultiplier: number;
  49180. private _imageMode;
  49181. /**
  49182. * Gets or set the current video mode for the video. It can be:
  49183. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49184. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49185. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49186. */
  49187. imageMode: number;
  49188. /**
  49189. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49190. * @param name Element's name, child elements will append suffixes for their own names.
  49191. * @param urlsOfPhoto defines the url of the photo to display
  49192. * @param options defines an object containing optional or exposed sub element properties
  49193. * @param onError defines a callback called when an error occured while loading the texture
  49194. */
  49195. constructor(name: string, urlOfPhoto: string, options: {
  49196. resolution?: number;
  49197. size?: number;
  49198. useDirectMapping?: boolean;
  49199. faceForward?: boolean;
  49200. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49201. private _onBeforeCameraRenderObserver;
  49202. private _changeImageMode;
  49203. /**
  49204. * Releases resources associated with this node.
  49205. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49206. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49207. */
  49208. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49209. }
  49210. }
  49211. declare module "babylonjs/Misc/rgbdTextureTools" {
  49212. import "babylonjs/Shaders/rgbdDecode.fragment";
  49213. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49214. import { Texture } from "babylonjs/Materials/Textures/texture";
  49215. /**
  49216. * Class used to host RGBD texture specific utilities
  49217. */
  49218. export class RGBDTextureTools {
  49219. /**
  49220. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49221. * @param texture the texture to expand.
  49222. */
  49223. static ExpandRGBDTexture(texture: Texture): void;
  49224. }
  49225. }
  49226. declare module "babylonjs/Misc/brdfTextureTools" {
  49227. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49228. import { Scene } from "babylonjs/scene";
  49229. /**
  49230. * Class used to host texture specific utilities
  49231. */
  49232. export class BRDFTextureTools {
  49233. /**
  49234. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49235. * @param scene defines the hosting scene
  49236. * @returns the environment BRDF texture
  49237. */
  49238. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49239. private static _environmentBRDFBase64Texture;
  49240. }
  49241. }
  49242. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  49243. import { Nullable } from "babylonjs/types";
  49244. import { Color3 } from "babylonjs/Maths/math.color";
  49245. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49246. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49247. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49248. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49249. import { Engine } from "babylonjs/Engines/engine";
  49250. import { Scene } from "babylonjs/scene";
  49251. /**
  49252. * @hidden
  49253. */
  49254. export interface IMaterialClearCoatDefines {
  49255. CLEARCOAT: boolean;
  49256. CLEARCOAT_DEFAULTIOR: boolean;
  49257. CLEARCOAT_TEXTURE: boolean;
  49258. CLEARCOAT_TEXTUREDIRECTUV: number;
  49259. CLEARCOAT_BUMP: boolean;
  49260. CLEARCOAT_BUMPDIRECTUV: number;
  49261. CLEARCOAT_TINT: boolean;
  49262. CLEARCOAT_TINT_TEXTURE: boolean;
  49263. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49264. /** @hidden */
  49265. _areTexturesDirty: boolean;
  49266. }
  49267. /**
  49268. * Define the code related to the clear coat parameters of the pbr material.
  49269. */
  49270. export class PBRClearCoatConfiguration {
  49271. /**
  49272. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49273. * The default fits with a polyurethane material.
  49274. */
  49275. private static readonly _DefaultIndexOfRefraction;
  49276. private _isEnabled;
  49277. /**
  49278. * Defines if the clear coat is enabled in the material.
  49279. */
  49280. isEnabled: boolean;
  49281. /**
  49282. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49283. */
  49284. intensity: number;
  49285. /**
  49286. * Defines the clear coat layer roughness.
  49287. */
  49288. roughness: number;
  49289. private _indexOfRefraction;
  49290. /**
  49291. * Defines the index of refraction of the clear coat.
  49292. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49293. * The default fits with a polyurethane material.
  49294. * Changing the default value is more performance intensive.
  49295. */
  49296. indexOfRefraction: number;
  49297. private _texture;
  49298. /**
  49299. * Stores the clear coat values in a texture.
  49300. */
  49301. texture: Nullable<BaseTexture>;
  49302. private _bumpTexture;
  49303. /**
  49304. * Define the clear coat specific bump texture.
  49305. */
  49306. bumpTexture: Nullable<BaseTexture>;
  49307. private _isTintEnabled;
  49308. /**
  49309. * Defines if the clear coat tint is enabled in the material.
  49310. */
  49311. isTintEnabled: boolean;
  49312. /**
  49313. * Defines the clear coat tint of the material.
  49314. * This is only use if tint is enabled
  49315. */
  49316. tintColor: Color3;
  49317. /**
  49318. * Defines the distance at which the tint color should be found in the
  49319. * clear coat media.
  49320. * This is only use if tint is enabled
  49321. */
  49322. tintColorAtDistance: number;
  49323. /**
  49324. * Defines the clear coat layer thickness.
  49325. * This is only use if tint is enabled
  49326. */
  49327. tintThickness: number;
  49328. private _tintTexture;
  49329. /**
  49330. * Stores the clear tint values in a texture.
  49331. * rgb is tint
  49332. * a is a thickness factor
  49333. */
  49334. tintTexture: Nullable<BaseTexture>;
  49335. /** @hidden */
  49336. private _internalMarkAllSubMeshesAsTexturesDirty;
  49337. /** @hidden */
  49338. _markAllSubMeshesAsTexturesDirty(): void;
  49339. /**
  49340. * Instantiate a new istance of clear coat configuration.
  49341. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49342. */
  49343. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49344. /**
  49345. * Gets wehter the submesh is ready to be used or not.
  49346. * @param defines the list of "defines" to update.
  49347. * @param scene defines the scene the material belongs to.
  49348. * @param engine defines the engine the material belongs to.
  49349. * @param disableBumpMap defines wether the material disables bump or not.
  49350. * @returns - boolean indicating that the submesh is ready or not.
  49351. */
  49352. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49353. /**
  49354. * Checks to see if a texture is used in the material.
  49355. * @param defines the list of "defines" to update.
  49356. * @param scene defines the scene to the material belongs to.
  49357. */
  49358. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49359. /**
  49360. * Binds the material data.
  49361. * @param uniformBuffer defines the Uniform buffer to fill in.
  49362. * @param scene defines the scene the material belongs to.
  49363. * @param engine defines the engine the material belongs to.
  49364. * @param disableBumpMap defines wether the material disables bump or not.
  49365. * @param isFrozen defines wether the material is frozen or not.
  49366. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49367. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49368. */
  49369. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49370. /**
  49371. * Checks to see if a texture is used in the material.
  49372. * @param texture - Base texture to use.
  49373. * @returns - Boolean specifying if a texture is used in the material.
  49374. */
  49375. hasTexture(texture: BaseTexture): boolean;
  49376. /**
  49377. * Returns an array of the actively used textures.
  49378. * @param activeTextures Array of BaseTextures
  49379. */
  49380. getActiveTextures(activeTextures: BaseTexture[]): void;
  49381. /**
  49382. * Returns the animatable textures.
  49383. * @param animatables Array of animatable textures.
  49384. */
  49385. getAnimatables(animatables: IAnimatable[]): void;
  49386. /**
  49387. * Disposes the resources of the material.
  49388. * @param forceDisposeTextures - Forces the disposal of all textures.
  49389. */
  49390. dispose(forceDisposeTextures?: boolean): void;
  49391. /**
  49392. * Get the current class name of the texture useful for serialization or dynamic coding.
  49393. * @returns "PBRClearCoatConfiguration"
  49394. */
  49395. getClassName(): string;
  49396. /**
  49397. * Add fallbacks to the effect fallbacks list.
  49398. * @param defines defines the Base texture to use.
  49399. * @param fallbacks defines the current fallback list.
  49400. * @param currentRank defines the current fallback rank.
  49401. * @returns the new fallback rank.
  49402. */
  49403. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49404. /**
  49405. * Add the required uniforms to the current list.
  49406. * @param uniforms defines the current uniform list.
  49407. */
  49408. static AddUniforms(uniforms: string[]): void;
  49409. /**
  49410. * Add the required samplers to the current list.
  49411. * @param samplers defines the current sampler list.
  49412. */
  49413. static AddSamplers(samplers: string[]): void;
  49414. /**
  49415. * Add the required uniforms to the current buffer.
  49416. * @param uniformBuffer defines the current uniform buffer.
  49417. */
  49418. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49419. /**
  49420. * Makes a duplicate of the current configuration into another one.
  49421. * @param clearCoatConfiguration define the config where to copy the info
  49422. */
  49423. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49424. /**
  49425. * Serializes this clear coat configuration.
  49426. * @returns - An object with the serialized config.
  49427. */
  49428. serialize(): any;
  49429. /**
  49430. * Parses a anisotropy Configuration from a serialized object.
  49431. * @param source - Serialized object.
  49432. * @param scene Defines the scene we are parsing for
  49433. * @param rootUrl Defines the rootUrl to load from
  49434. */
  49435. parse(source: any, scene: Scene, rootUrl: string): void;
  49436. }
  49437. }
  49438. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  49439. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49440. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49441. import { Vector2 } from "babylonjs/Maths/math.vector";
  49442. import { Scene } from "babylonjs/scene";
  49443. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49444. import { Nullable } from "babylonjs/types";
  49445. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49446. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49447. /**
  49448. * @hidden
  49449. */
  49450. export interface IMaterialAnisotropicDefines {
  49451. ANISOTROPIC: boolean;
  49452. ANISOTROPIC_TEXTURE: boolean;
  49453. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49454. MAINUV1: boolean;
  49455. _areTexturesDirty: boolean;
  49456. _needUVs: boolean;
  49457. }
  49458. /**
  49459. * Define the code related to the anisotropic parameters of the pbr material.
  49460. */
  49461. export class PBRAnisotropicConfiguration {
  49462. private _isEnabled;
  49463. /**
  49464. * Defines if the anisotropy is enabled in the material.
  49465. */
  49466. isEnabled: boolean;
  49467. /**
  49468. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49469. */
  49470. intensity: number;
  49471. /**
  49472. * Defines if the effect is along the tangents, bitangents or in between.
  49473. * By default, the effect is "strectching" the highlights along the tangents.
  49474. */
  49475. direction: Vector2;
  49476. private _texture;
  49477. /**
  49478. * Stores the anisotropy values in a texture.
  49479. * rg is direction (like normal from -1 to 1)
  49480. * b is a intensity
  49481. */
  49482. texture: Nullable<BaseTexture>;
  49483. /** @hidden */
  49484. private _internalMarkAllSubMeshesAsTexturesDirty;
  49485. /** @hidden */
  49486. _markAllSubMeshesAsTexturesDirty(): void;
  49487. /**
  49488. * Instantiate a new istance of anisotropy configuration.
  49489. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49490. */
  49491. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49492. /**
  49493. * Specifies that the submesh is ready to be used.
  49494. * @param defines the list of "defines" to update.
  49495. * @param scene defines the scene the material belongs to.
  49496. * @returns - boolean indicating that the submesh is ready or not.
  49497. */
  49498. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49499. /**
  49500. * Checks to see if a texture is used in the material.
  49501. * @param defines the list of "defines" to update.
  49502. * @param mesh the mesh we are preparing the defines for.
  49503. * @param scene defines the scene the material belongs to.
  49504. */
  49505. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49506. /**
  49507. * Binds the material data.
  49508. * @param uniformBuffer defines the Uniform buffer to fill in.
  49509. * @param scene defines the scene the material belongs to.
  49510. * @param isFrozen defines wether the material is frozen or not.
  49511. */
  49512. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49513. /**
  49514. * Checks to see if a texture is used in the material.
  49515. * @param texture - Base texture to use.
  49516. * @returns - Boolean specifying if a texture is used in the material.
  49517. */
  49518. hasTexture(texture: BaseTexture): boolean;
  49519. /**
  49520. * Returns an array of the actively used textures.
  49521. * @param activeTextures Array of BaseTextures
  49522. */
  49523. getActiveTextures(activeTextures: BaseTexture[]): void;
  49524. /**
  49525. * Returns the animatable textures.
  49526. * @param animatables Array of animatable textures.
  49527. */
  49528. getAnimatables(animatables: IAnimatable[]): void;
  49529. /**
  49530. * Disposes the resources of the material.
  49531. * @param forceDisposeTextures - Forces the disposal of all textures.
  49532. */
  49533. dispose(forceDisposeTextures?: boolean): void;
  49534. /**
  49535. * Get the current class name of the texture useful for serialization or dynamic coding.
  49536. * @returns "PBRAnisotropicConfiguration"
  49537. */
  49538. getClassName(): string;
  49539. /**
  49540. * Add fallbacks to the effect fallbacks list.
  49541. * @param defines defines the Base texture to use.
  49542. * @param fallbacks defines the current fallback list.
  49543. * @param currentRank defines the current fallback rank.
  49544. * @returns the new fallback rank.
  49545. */
  49546. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49547. /**
  49548. * Add the required uniforms to the current list.
  49549. * @param uniforms defines the current uniform list.
  49550. */
  49551. static AddUniforms(uniforms: string[]): void;
  49552. /**
  49553. * Add the required uniforms to the current buffer.
  49554. * @param uniformBuffer defines the current uniform buffer.
  49555. */
  49556. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49557. /**
  49558. * Add the required samplers to the current list.
  49559. * @param samplers defines the current sampler list.
  49560. */
  49561. static AddSamplers(samplers: string[]): void;
  49562. /**
  49563. * Makes a duplicate of the current configuration into another one.
  49564. * @param anisotropicConfiguration define the config where to copy the info
  49565. */
  49566. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49567. /**
  49568. * Serializes this anisotropy configuration.
  49569. * @returns - An object with the serialized config.
  49570. */
  49571. serialize(): any;
  49572. /**
  49573. * Parses a anisotropy Configuration from a serialized object.
  49574. * @param source - Serialized object.
  49575. * @param scene Defines the scene we are parsing for
  49576. * @param rootUrl Defines the rootUrl to load from
  49577. */
  49578. parse(source: any, scene: Scene, rootUrl: string): void;
  49579. }
  49580. }
  49581. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  49582. import { Scene } from "babylonjs/scene";
  49583. /**
  49584. * @hidden
  49585. */
  49586. export interface IMaterialBRDFDefines {
  49587. BRDF_V_HEIGHT_CORRELATED: boolean;
  49588. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49589. SPHERICAL_HARMONICS: boolean;
  49590. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49591. /** @hidden */
  49592. _areMiscDirty: boolean;
  49593. }
  49594. /**
  49595. * Define the code related to the BRDF parameters of the pbr material.
  49596. */
  49597. export class PBRBRDFConfiguration {
  49598. /**
  49599. * Default value used for the energy conservation.
  49600. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49601. */
  49602. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49603. /**
  49604. * Default value used for the Smith Visibility Height Correlated mode.
  49605. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49606. */
  49607. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49608. /**
  49609. * Default value used for the IBL diffuse part.
  49610. * This can help switching back to the polynomials mode globally which is a tiny bit
  49611. * less GPU intensive at the drawback of a lower quality.
  49612. */
  49613. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49614. /**
  49615. * Default value used for activating energy conservation for the specular workflow.
  49616. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49617. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49618. */
  49619. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49620. private _useEnergyConservation;
  49621. /**
  49622. * Defines if the material uses energy conservation.
  49623. */
  49624. useEnergyConservation: boolean;
  49625. private _useSmithVisibilityHeightCorrelated;
  49626. /**
  49627. * LEGACY Mode set to false
  49628. * Defines if the material uses height smith correlated visibility term.
  49629. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49630. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49631. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49632. * Not relying on height correlated will also disable energy conservation.
  49633. */
  49634. useSmithVisibilityHeightCorrelated: boolean;
  49635. private _useSphericalHarmonics;
  49636. /**
  49637. * LEGACY Mode set to false
  49638. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49639. * diffuse part of the IBL.
  49640. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49641. * to the ground truth.
  49642. */
  49643. useSphericalHarmonics: boolean;
  49644. private _useSpecularGlossinessInputEnergyConservation;
  49645. /**
  49646. * Defines if the material uses energy conservation, when the specular workflow is active.
  49647. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49648. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49649. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49650. */
  49651. useSpecularGlossinessInputEnergyConservation: boolean;
  49652. /** @hidden */
  49653. private _internalMarkAllSubMeshesAsMiscDirty;
  49654. /** @hidden */
  49655. _markAllSubMeshesAsMiscDirty(): void;
  49656. /**
  49657. * Instantiate a new istance of clear coat configuration.
  49658. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49659. */
  49660. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49661. /**
  49662. * Checks to see if a texture is used in the material.
  49663. * @param defines the list of "defines" to update.
  49664. */
  49665. prepareDefines(defines: IMaterialBRDFDefines): void;
  49666. /**
  49667. * Get the current class name of the texture useful for serialization or dynamic coding.
  49668. * @returns "PBRClearCoatConfiguration"
  49669. */
  49670. getClassName(): string;
  49671. /**
  49672. * Makes a duplicate of the current configuration into another one.
  49673. * @param brdfConfiguration define the config where to copy the info
  49674. */
  49675. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49676. /**
  49677. * Serializes this BRDF configuration.
  49678. * @returns - An object with the serialized config.
  49679. */
  49680. serialize(): any;
  49681. /**
  49682. * Parses a anisotropy Configuration from a serialized object.
  49683. * @param source - Serialized object.
  49684. * @param scene Defines the scene we are parsing for
  49685. * @param rootUrl Defines the rootUrl to load from
  49686. */
  49687. parse(source: any, scene: Scene, rootUrl: string): void;
  49688. }
  49689. }
  49690. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  49691. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49692. import { Color3 } from "babylonjs/Maths/math.color";
  49693. import { Scene } from "babylonjs/scene";
  49694. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49695. import { Nullable } from "babylonjs/types";
  49696. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49697. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49698. /**
  49699. * @hidden
  49700. */
  49701. export interface IMaterialSheenDefines {
  49702. SHEEN: boolean;
  49703. SHEEN_TEXTURE: boolean;
  49704. SHEEN_TEXTUREDIRECTUV: number;
  49705. SHEEN_LINKWITHALBEDO: boolean;
  49706. /** @hidden */
  49707. _areTexturesDirty: boolean;
  49708. }
  49709. /**
  49710. * Define the code related to the Sheen parameters of the pbr material.
  49711. */
  49712. export class PBRSheenConfiguration {
  49713. private _isEnabled;
  49714. /**
  49715. * Defines if the material uses sheen.
  49716. */
  49717. isEnabled: boolean;
  49718. private _linkSheenWithAlbedo;
  49719. /**
  49720. * Defines if the sheen is linked to the sheen color.
  49721. */
  49722. linkSheenWithAlbedo: boolean;
  49723. /**
  49724. * Defines the sheen intensity.
  49725. */
  49726. intensity: number;
  49727. /**
  49728. * Defines the sheen color.
  49729. */
  49730. color: Color3;
  49731. private _texture;
  49732. /**
  49733. * Stores the sheen tint values in a texture.
  49734. * rgb is tint
  49735. * a is a intensity
  49736. */
  49737. texture: Nullable<BaseTexture>;
  49738. /** @hidden */
  49739. private _internalMarkAllSubMeshesAsTexturesDirty;
  49740. /** @hidden */
  49741. _markAllSubMeshesAsTexturesDirty(): void;
  49742. /**
  49743. * Instantiate a new istance of clear coat configuration.
  49744. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49745. */
  49746. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49747. /**
  49748. * Specifies that the submesh is ready to be used.
  49749. * @param defines the list of "defines" to update.
  49750. * @param scene defines the scene the material belongs to.
  49751. * @returns - boolean indicating that the submesh is ready or not.
  49752. */
  49753. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49754. /**
  49755. * Checks to see if a texture is used in the material.
  49756. * @param defines the list of "defines" to update.
  49757. * @param scene defines the scene the material belongs to.
  49758. */
  49759. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49760. /**
  49761. * Binds the material data.
  49762. * @param uniformBuffer defines the Uniform buffer to fill in.
  49763. * @param scene defines the scene the material belongs to.
  49764. * @param isFrozen defines wether the material is frozen or not.
  49765. */
  49766. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49767. /**
  49768. * Checks to see if a texture is used in the material.
  49769. * @param texture - Base texture to use.
  49770. * @returns - Boolean specifying if a texture is used in the material.
  49771. */
  49772. hasTexture(texture: BaseTexture): boolean;
  49773. /**
  49774. * Returns an array of the actively used textures.
  49775. * @param activeTextures Array of BaseTextures
  49776. */
  49777. getActiveTextures(activeTextures: BaseTexture[]): void;
  49778. /**
  49779. * Returns the animatable textures.
  49780. * @param animatables Array of animatable textures.
  49781. */
  49782. getAnimatables(animatables: IAnimatable[]): void;
  49783. /**
  49784. * Disposes the resources of the material.
  49785. * @param forceDisposeTextures - Forces the disposal of all textures.
  49786. */
  49787. dispose(forceDisposeTextures?: boolean): void;
  49788. /**
  49789. * Get the current class name of the texture useful for serialization or dynamic coding.
  49790. * @returns "PBRSheenConfiguration"
  49791. */
  49792. getClassName(): string;
  49793. /**
  49794. * Add fallbacks to the effect fallbacks list.
  49795. * @param defines defines the Base texture to use.
  49796. * @param fallbacks defines the current fallback list.
  49797. * @param currentRank defines the current fallback rank.
  49798. * @returns the new fallback rank.
  49799. */
  49800. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49801. /**
  49802. * Add the required uniforms to the current list.
  49803. * @param uniforms defines the current uniform list.
  49804. */
  49805. static AddUniforms(uniforms: string[]): void;
  49806. /**
  49807. * Add the required uniforms to the current buffer.
  49808. * @param uniformBuffer defines the current uniform buffer.
  49809. */
  49810. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49811. /**
  49812. * Add the required samplers to the current list.
  49813. * @param samplers defines the current sampler list.
  49814. */
  49815. static AddSamplers(samplers: string[]): void;
  49816. /**
  49817. * Makes a duplicate of the current configuration into another one.
  49818. * @param sheenConfiguration define the config where to copy the info
  49819. */
  49820. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49821. /**
  49822. * Serializes this BRDF configuration.
  49823. * @returns - An object with the serialized config.
  49824. */
  49825. serialize(): any;
  49826. /**
  49827. * Parses a anisotropy Configuration from a serialized object.
  49828. * @param source - Serialized object.
  49829. * @param scene Defines the scene we are parsing for
  49830. * @param rootUrl Defines the rootUrl to load from
  49831. */
  49832. parse(source: any, scene: Scene, rootUrl: string): void;
  49833. }
  49834. }
  49835. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49836. import { Nullable } from "babylonjs/types";
  49837. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49838. import { Color3 } from "babylonjs/Maths/math.color";
  49839. import { SmartArray } from "babylonjs/Misc/smartArray";
  49840. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49841. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49842. import { Effect } from "babylonjs/Materials/effect";
  49843. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49844. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49845. import { Engine } from "babylonjs/Engines/engine";
  49846. import { Scene } from "babylonjs/scene";
  49847. /**
  49848. * @hidden
  49849. */
  49850. export interface IMaterialSubSurfaceDefines {
  49851. SUBSURFACE: boolean;
  49852. SS_REFRACTION: boolean;
  49853. SS_TRANSLUCENCY: boolean;
  49854. SS_SCATERRING: boolean;
  49855. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49856. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49857. SS_REFRACTIONMAP_3D: boolean;
  49858. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49859. SS_LODINREFRACTIONALPHA: boolean;
  49860. SS_GAMMAREFRACTION: boolean;
  49861. SS_RGBDREFRACTION: boolean;
  49862. SS_LINEARSPECULARREFRACTION: boolean;
  49863. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49864. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49865. /** @hidden */
  49866. _areTexturesDirty: boolean;
  49867. }
  49868. /**
  49869. * Define the code related to the sub surface parameters of the pbr material.
  49870. */
  49871. export class PBRSubSurfaceConfiguration {
  49872. private _isRefractionEnabled;
  49873. /**
  49874. * Defines if the refraction is enabled in the material.
  49875. */
  49876. isRefractionEnabled: boolean;
  49877. private _isTranslucencyEnabled;
  49878. /**
  49879. * Defines if the translucency is enabled in the material.
  49880. */
  49881. isTranslucencyEnabled: boolean;
  49882. private _isScatteringEnabled;
  49883. /**
  49884. * Defines the refraction intensity of the material.
  49885. * The refraction when enabled replaces the Diffuse part of the material.
  49886. * The intensity helps transitionning between diffuse and refraction.
  49887. */
  49888. refractionIntensity: number;
  49889. /**
  49890. * Defines the translucency intensity of the material.
  49891. * When translucency has been enabled, this defines how much of the "translucency"
  49892. * is addded to the diffuse part of the material.
  49893. */
  49894. translucencyIntensity: number;
  49895. /**
  49896. * Defines the scattering intensity of the material.
  49897. * When scattering has been enabled, this defines how much of the "scattered light"
  49898. * is addded to the diffuse part of the material.
  49899. */
  49900. scatteringIntensity: number;
  49901. private _thicknessTexture;
  49902. /**
  49903. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49904. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49905. * 0 would mean minimumThickness
  49906. * 1 would mean maximumThickness
  49907. * The other channels might be use as a mask to vary the different effects intensity.
  49908. */
  49909. thicknessTexture: Nullable<BaseTexture>;
  49910. private _refractionTexture;
  49911. /**
  49912. * Defines the texture to use for refraction.
  49913. */
  49914. refractionTexture: Nullable<BaseTexture>;
  49915. private _indexOfRefraction;
  49916. /**
  49917. * Defines the index of refraction used in the material.
  49918. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49919. */
  49920. indexOfRefraction: number;
  49921. private _invertRefractionY;
  49922. /**
  49923. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49924. */
  49925. invertRefractionY: boolean;
  49926. private _linkRefractionWithTransparency;
  49927. /**
  49928. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49929. * Materials half opaque for instance using refraction could benefit from this control.
  49930. */
  49931. linkRefractionWithTransparency: boolean;
  49932. /**
  49933. * Defines the minimum thickness stored in the thickness map.
  49934. * If no thickness map is defined, this value will be used to simulate thickness.
  49935. */
  49936. minimumThickness: number;
  49937. /**
  49938. * Defines the maximum thickness stored in the thickness map.
  49939. */
  49940. maximumThickness: number;
  49941. /**
  49942. * Defines the volume tint of the material.
  49943. * This is used for both translucency and scattering.
  49944. */
  49945. tintColor: Color3;
  49946. /**
  49947. * Defines the distance at which the tint color should be found in the media.
  49948. * This is used for refraction only.
  49949. */
  49950. tintColorAtDistance: number;
  49951. /**
  49952. * Defines how far each channel transmit through the media.
  49953. * It is defined as a color to simplify it selection.
  49954. */
  49955. diffusionDistance: Color3;
  49956. private _useMaskFromThicknessTexture;
  49957. /**
  49958. * Stores the intensity of the different subsurface effects in the thickness texture.
  49959. * * the green channel is the translucency intensity.
  49960. * * the blue channel is the scattering intensity.
  49961. * * the alpha channel is the refraction intensity.
  49962. */
  49963. useMaskFromThicknessTexture: boolean;
  49964. /** @hidden */
  49965. private _internalMarkAllSubMeshesAsTexturesDirty;
  49966. /** @hidden */
  49967. _markAllSubMeshesAsTexturesDirty(): void;
  49968. /**
  49969. * Instantiate a new istance of sub surface configuration.
  49970. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49971. */
  49972. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49973. /**
  49974. * Gets wehter the submesh is ready to be used or not.
  49975. * @param defines the list of "defines" to update.
  49976. * @param scene defines the scene the material belongs to.
  49977. * @returns - boolean indicating that the submesh is ready or not.
  49978. */
  49979. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49980. /**
  49981. * Checks to see if a texture is used in the material.
  49982. * @param defines the list of "defines" to update.
  49983. * @param scene defines the scene to the material belongs to.
  49984. */
  49985. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49986. /**
  49987. * Binds the material data.
  49988. * @param uniformBuffer defines the Uniform buffer to fill in.
  49989. * @param scene defines the scene the material belongs to.
  49990. * @param engine defines the engine the material belongs to.
  49991. * @param isFrozen defines wether the material is frozen or not.
  49992. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49993. */
  49994. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49995. /**
  49996. * Unbinds the material from the mesh.
  49997. * @param activeEffect defines the effect that should be unbound from.
  49998. * @returns true if unbound, otherwise false
  49999. */
  50000. unbind(activeEffect: Effect): boolean;
  50001. /**
  50002. * Returns the texture used for refraction or null if none is used.
  50003. * @param scene defines the scene the material belongs to.
  50004. * @returns - Refraction texture if present. If no refraction texture and refraction
  50005. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50006. */
  50007. private _getRefractionTexture;
  50008. /**
  50009. * Returns true if alpha blending should be disabled.
  50010. */
  50011. readonly disableAlphaBlending: boolean;
  50012. /**
  50013. * Fills the list of render target textures.
  50014. * @param renderTargets the list of render targets to update
  50015. */
  50016. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50017. /**
  50018. * Checks to see if a texture is used in the material.
  50019. * @param texture - Base texture to use.
  50020. * @returns - Boolean specifying if a texture is used in the material.
  50021. */
  50022. hasTexture(texture: BaseTexture): boolean;
  50023. /**
  50024. * Gets a boolean indicating that current material needs to register RTT
  50025. * @returns true if this uses a render target otherwise false.
  50026. */
  50027. hasRenderTargetTextures(): boolean;
  50028. /**
  50029. * Returns an array of the actively used textures.
  50030. * @param activeTextures Array of BaseTextures
  50031. */
  50032. getActiveTextures(activeTextures: BaseTexture[]): void;
  50033. /**
  50034. * Returns the animatable textures.
  50035. * @param animatables Array of animatable textures.
  50036. */
  50037. getAnimatables(animatables: IAnimatable[]): void;
  50038. /**
  50039. * Disposes the resources of the material.
  50040. * @param forceDisposeTextures - Forces the disposal of all textures.
  50041. */
  50042. dispose(forceDisposeTextures?: boolean): void;
  50043. /**
  50044. * Get the current class name of the texture useful for serialization or dynamic coding.
  50045. * @returns "PBRSubSurfaceConfiguration"
  50046. */
  50047. getClassName(): string;
  50048. /**
  50049. * Add fallbacks to the effect fallbacks list.
  50050. * @param defines defines the Base texture to use.
  50051. * @param fallbacks defines the current fallback list.
  50052. * @param currentRank defines the current fallback rank.
  50053. * @returns the new fallback rank.
  50054. */
  50055. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50056. /**
  50057. * Add the required uniforms to the current list.
  50058. * @param uniforms defines the current uniform list.
  50059. */
  50060. static AddUniforms(uniforms: string[]): void;
  50061. /**
  50062. * Add the required samplers to the current list.
  50063. * @param samplers defines the current sampler list.
  50064. */
  50065. static AddSamplers(samplers: string[]): void;
  50066. /**
  50067. * Add the required uniforms to the current buffer.
  50068. * @param uniformBuffer defines the current uniform buffer.
  50069. */
  50070. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50071. /**
  50072. * Makes a duplicate of the current configuration into another one.
  50073. * @param configuration define the config where to copy the info
  50074. */
  50075. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50076. /**
  50077. * Serializes this Sub Surface configuration.
  50078. * @returns - An object with the serialized config.
  50079. */
  50080. serialize(): any;
  50081. /**
  50082. * Parses a anisotropy Configuration from a serialized object.
  50083. * @param source - Serialized object.
  50084. * @param scene Defines the scene we are parsing for
  50085. * @param rootUrl Defines the rootUrl to load from
  50086. */
  50087. parse(source: any, scene: Scene, rootUrl: string): void;
  50088. }
  50089. }
  50090. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  50091. /** @hidden */
  50092. export var pbrFragmentDeclaration: {
  50093. name: string;
  50094. shader: string;
  50095. };
  50096. }
  50097. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  50098. /** @hidden */
  50099. export var pbrUboDeclaration: {
  50100. name: string;
  50101. shader: string;
  50102. };
  50103. }
  50104. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  50105. /** @hidden */
  50106. export var pbrFragmentExtraDeclaration: {
  50107. name: string;
  50108. shader: string;
  50109. };
  50110. }
  50111. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  50112. /** @hidden */
  50113. export var pbrFragmentSamplersDeclaration: {
  50114. name: string;
  50115. shader: string;
  50116. };
  50117. }
  50118. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  50119. /** @hidden */
  50120. export var pbrHelperFunctions: {
  50121. name: string;
  50122. shader: string;
  50123. };
  50124. }
  50125. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  50126. /** @hidden */
  50127. export var harmonicsFunctions: {
  50128. name: string;
  50129. shader: string;
  50130. };
  50131. }
  50132. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  50133. /** @hidden */
  50134. export var pbrDirectLightingSetupFunctions: {
  50135. name: string;
  50136. shader: string;
  50137. };
  50138. }
  50139. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  50140. /** @hidden */
  50141. export var pbrDirectLightingFalloffFunctions: {
  50142. name: string;
  50143. shader: string;
  50144. };
  50145. }
  50146. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  50147. /** @hidden */
  50148. export var pbrBRDFFunctions: {
  50149. name: string;
  50150. shader: string;
  50151. };
  50152. }
  50153. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  50154. /** @hidden */
  50155. export var pbrDirectLightingFunctions: {
  50156. name: string;
  50157. shader: string;
  50158. };
  50159. }
  50160. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  50161. /** @hidden */
  50162. export var pbrIBLFunctions: {
  50163. name: string;
  50164. shader: string;
  50165. };
  50166. }
  50167. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  50168. /** @hidden */
  50169. export var pbrDebug: {
  50170. name: string;
  50171. shader: string;
  50172. };
  50173. }
  50174. declare module "babylonjs/Shaders/pbr.fragment" {
  50175. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  50176. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50177. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  50178. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50179. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50180. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  50181. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50182. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50183. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50184. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50185. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50186. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  50187. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50188. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50189. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50190. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  50191. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  50192. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  50193. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  50194. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  50195. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  50196. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50197. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50198. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  50199. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  50200. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50201. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  50202. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50203. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  50204. /** @hidden */
  50205. export var pbrPixelShader: {
  50206. name: string;
  50207. shader: string;
  50208. };
  50209. }
  50210. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  50211. /** @hidden */
  50212. export var pbrVertexDeclaration: {
  50213. name: string;
  50214. shader: string;
  50215. };
  50216. }
  50217. declare module "babylonjs/Shaders/pbr.vertex" {
  50218. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  50219. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50220. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50221. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50222. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50223. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50224. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  50225. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50226. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50227. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50228. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50229. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50230. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50231. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50232. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50233. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50234. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50235. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  50236. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50237. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50238. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50239. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  50240. /** @hidden */
  50241. export var pbrVertexShader: {
  50242. name: string;
  50243. shader: string;
  50244. };
  50245. }
  50246. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  50247. import { Nullable } from "babylonjs/types";
  50248. import { Scene } from "babylonjs/scene";
  50249. import { Matrix } from "babylonjs/Maths/math.vector";
  50250. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50252. import { Mesh } from "babylonjs/Meshes/mesh";
  50253. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  50254. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  50255. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  50256. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  50257. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  50258. import { Color3 } from "babylonjs/Maths/math.color";
  50259. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  50260. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  50261. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  50262. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50263. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50264. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50265. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  50266. import "babylonjs/Shaders/pbr.fragment";
  50267. import "babylonjs/Shaders/pbr.vertex";
  50268. /**
  50269. * Manages the defines for the PBR Material.
  50270. * @hidden
  50271. */
  50272. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50273. PBR: boolean;
  50274. MAINUV1: boolean;
  50275. MAINUV2: boolean;
  50276. UV1: boolean;
  50277. UV2: boolean;
  50278. ALBEDO: boolean;
  50279. ALBEDODIRECTUV: number;
  50280. VERTEXCOLOR: boolean;
  50281. AMBIENT: boolean;
  50282. AMBIENTDIRECTUV: number;
  50283. AMBIENTINGRAYSCALE: boolean;
  50284. OPACITY: boolean;
  50285. VERTEXALPHA: boolean;
  50286. OPACITYDIRECTUV: number;
  50287. OPACITYRGB: boolean;
  50288. ALPHATEST: boolean;
  50289. DEPTHPREPASS: boolean;
  50290. ALPHABLEND: boolean;
  50291. ALPHAFROMALBEDO: boolean;
  50292. ALPHATESTVALUE: string;
  50293. SPECULAROVERALPHA: boolean;
  50294. RADIANCEOVERALPHA: boolean;
  50295. ALPHAFRESNEL: boolean;
  50296. LINEARALPHAFRESNEL: boolean;
  50297. PREMULTIPLYALPHA: boolean;
  50298. EMISSIVE: boolean;
  50299. EMISSIVEDIRECTUV: number;
  50300. REFLECTIVITY: boolean;
  50301. REFLECTIVITYDIRECTUV: number;
  50302. SPECULARTERM: boolean;
  50303. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50304. MICROSURFACEAUTOMATIC: boolean;
  50305. LODBASEDMICROSFURACE: boolean;
  50306. MICROSURFACEMAP: boolean;
  50307. MICROSURFACEMAPDIRECTUV: number;
  50308. METALLICWORKFLOW: boolean;
  50309. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50310. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50311. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50312. AOSTOREINMETALMAPRED: boolean;
  50313. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50314. ENVIRONMENTBRDF: boolean;
  50315. ENVIRONMENTBRDF_RGBD: boolean;
  50316. NORMAL: boolean;
  50317. TANGENT: boolean;
  50318. BUMP: boolean;
  50319. BUMPDIRECTUV: number;
  50320. OBJECTSPACE_NORMALMAP: boolean;
  50321. PARALLAX: boolean;
  50322. PARALLAXOCCLUSION: boolean;
  50323. NORMALXYSCALE: boolean;
  50324. LIGHTMAP: boolean;
  50325. LIGHTMAPDIRECTUV: number;
  50326. USELIGHTMAPASSHADOWMAP: boolean;
  50327. GAMMALIGHTMAP: boolean;
  50328. RGBDLIGHTMAP: boolean;
  50329. REFLECTION: boolean;
  50330. REFLECTIONMAP_3D: boolean;
  50331. REFLECTIONMAP_SPHERICAL: boolean;
  50332. REFLECTIONMAP_PLANAR: boolean;
  50333. REFLECTIONMAP_CUBIC: boolean;
  50334. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50335. REFLECTIONMAP_PROJECTION: boolean;
  50336. REFLECTIONMAP_SKYBOX: boolean;
  50337. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50338. REFLECTIONMAP_EXPLICIT: boolean;
  50339. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50340. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50341. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50342. INVERTCUBICMAP: boolean;
  50343. USESPHERICALFROMREFLECTIONMAP: boolean;
  50344. USEIRRADIANCEMAP: boolean;
  50345. SPHERICAL_HARMONICS: boolean;
  50346. USESPHERICALINVERTEX: boolean;
  50347. REFLECTIONMAP_OPPOSITEZ: boolean;
  50348. LODINREFLECTIONALPHA: boolean;
  50349. GAMMAREFLECTION: boolean;
  50350. RGBDREFLECTION: boolean;
  50351. LINEARSPECULARREFLECTION: boolean;
  50352. RADIANCEOCCLUSION: boolean;
  50353. HORIZONOCCLUSION: boolean;
  50354. INSTANCES: boolean;
  50355. NUM_BONE_INFLUENCERS: number;
  50356. BonesPerMesh: number;
  50357. BONETEXTURE: boolean;
  50358. NONUNIFORMSCALING: boolean;
  50359. MORPHTARGETS: boolean;
  50360. MORPHTARGETS_NORMAL: boolean;
  50361. MORPHTARGETS_TANGENT: boolean;
  50362. MORPHTARGETS_UV: boolean;
  50363. NUM_MORPH_INFLUENCERS: number;
  50364. IMAGEPROCESSING: boolean;
  50365. VIGNETTE: boolean;
  50366. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50367. VIGNETTEBLENDMODEOPAQUE: boolean;
  50368. TONEMAPPING: boolean;
  50369. TONEMAPPING_ACES: boolean;
  50370. CONTRAST: boolean;
  50371. COLORCURVES: boolean;
  50372. COLORGRADING: boolean;
  50373. COLORGRADING3D: boolean;
  50374. SAMPLER3DGREENDEPTH: boolean;
  50375. SAMPLER3DBGRMAP: boolean;
  50376. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50377. EXPOSURE: boolean;
  50378. MULTIVIEW: boolean;
  50379. USEPHYSICALLIGHTFALLOFF: boolean;
  50380. USEGLTFLIGHTFALLOFF: boolean;
  50381. TWOSIDEDLIGHTING: boolean;
  50382. SHADOWFLOAT: boolean;
  50383. CLIPPLANE: boolean;
  50384. CLIPPLANE2: boolean;
  50385. CLIPPLANE3: boolean;
  50386. CLIPPLANE4: boolean;
  50387. POINTSIZE: boolean;
  50388. FOG: boolean;
  50389. LOGARITHMICDEPTH: boolean;
  50390. FORCENORMALFORWARD: boolean;
  50391. SPECULARAA: boolean;
  50392. CLEARCOAT: boolean;
  50393. CLEARCOAT_DEFAULTIOR: boolean;
  50394. CLEARCOAT_TEXTURE: boolean;
  50395. CLEARCOAT_TEXTUREDIRECTUV: number;
  50396. CLEARCOAT_BUMP: boolean;
  50397. CLEARCOAT_BUMPDIRECTUV: number;
  50398. CLEARCOAT_TINT: boolean;
  50399. CLEARCOAT_TINT_TEXTURE: boolean;
  50400. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50401. ANISOTROPIC: boolean;
  50402. ANISOTROPIC_TEXTURE: boolean;
  50403. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50404. BRDF_V_HEIGHT_CORRELATED: boolean;
  50405. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50406. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50407. SHEEN: boolean;
  50408. SHEEN_TEXTURE: boolean;
  50409. SHEEN_TEXTUREDIRECTUV: number;
  50410. SHEEN_LINKWITHALBEDO: boolean;
  50411. SUBSURFACE: boolean;
  50412. SS_REFRACTION: boolean;
  50413. SS_TRANSLUCENCY: boolean;
  50414. SS_SCATERRING: boolean;
  50415. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50416. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50417. SS_REFRACTIONMAP_3D: boolean;
  50418. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50419. SS_LODINREFRACTIONALPHA: boolean;
  50420. SS_GAMMAREFRACTION: boolean;
  50421. SS_RGBDREFRACTION: boolean;
  50422. SS_LINEARSPECULARREFRACTION: boolean;
  50423. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50424. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50425. UNLIT: boolean;
  50426. DEBUGMODE: number;
  50427. /**
  50428. * Initializes the PBR Material defines.
  50429. */
  50430. constructor();
  50431. /**
  50432. * Resets the PBR Material defines.
  50433. */
  50434. reset(): void;
  50435. }
  50436. /**
  50437. * The Physically based material base class of BJS.
  50438. *
  50439. * This offers the main features of a standard PBR material.
  50440. * For more information, please refer to the documentation :
  50441. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50442. */
  50443. export abstract class PBRBaseMaterial extends PushMaterial {
  50444. /**
  50445. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50446. */
  50447. static readonly PBRMATERIAL_OPAQUE: number;
  50448. /**
  50449. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50450. */
  50451. static readonly PBRMATERIAL_ALPHATEST: number;
  50452. /**
  50453. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50454. */
  50455. static readonly PBRMATERIAL_ALPHABLEND: number;
  50456. /**
  50457. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50458. * They are also discarded below the alpha cutoff threshold to improve performances.
  50459. */
  50460. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50461. /**
  50462. * Defines the default value of how much AO map is occluding the analytical lights
  50463. * (point spot...).
  50464. */
  50465. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50466. /**
  50467. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50468. */
  50469. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50470. /**
  50471. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50472. * to enhance interoperability with other engines.
  50473. */
  50474. static readonly LIGHTFALLOFF_GLTF: number;
  50475. /**
  50476. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50477. * to enhance interoperability with other materials.
  50478. */
  50479. static readonly LIGHTFALLOFF_STANDARD: number;
  50480. /**
  50481. * Intensity of the direct lights e.g. the four lights available in your scene.
  50482. * This impacts both the direct diffuse and specular highlights.
  50483. */
  50484. protected _directIntensity: number;
  50485. /**
  50486. * Intensity of the emissive part of the material.
  50487. * This helps controlling the emissive effect without modifying the emissive color.
  50488. */
  50489. protected _emissiveIntensity: number;
  50490. /**
  50491. * Intensity of the environment e.g. how much the environment will light the object
  50492. * either through harmonics for rough material or through the refelction for shiny ones.
  50493. */
  50494. protected _environmentIntensity: number;
  50495. /**
  50496. * This is a special control allowing the reduction of the specular highlights coming from the
  50497. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50498. */
  50499. protected _specularIntensity: number;
  50500. /**
  50501. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50502. */
  50503. private _lightingInfos;
  50504. /**
  50505. * Debug Control allowing disabling the bump map on this material.
  50506. */
  50507. protected _disableBumpMap: boolean;
  50508. /**
  50509. * AKA Diffuse Texture in standard nomenclature.
  50510. */
  50511. protected _albedoTexture: Nullable<BaseTexture>;
  50512. /**
  50513. * AKA Occlusion Texture in other nomenclature.
  50514. */
  50515. protected _ambientTexture: Nullable<BaseTexture>;
  50516. /**
  50517. * AKA Occlusion Texture Intensity in other nomenclature.
  50518. */
  50519. protected _ambientTextureStrength: number;
  50520. /**
  50521. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50522. * 1 means it completely occludes it
  50523. * 0 mean it has no impact
  50524. */
  50525. protected _ambientTextureImpactOnAnalyticalLights: number;
  50526. /**
  50527. * Stores the alpha values in a texture.
  50528. */
  50529. protected _opacityTexture: Nullable<BaseTexture>;
  50530. /**
  50531. * Stores the reflection values in a texture.
  50532. */
  50533. protected _reflectionTexture: Nullable<BaseTexture>;
  50534. /**
  50535. * Stores the emissive values in a texture.
  50536. */
  50537. protected _emissiveTexture: Nullable<BaseTexture>;
  50538. /**
  50539. * AKA Specular texture in other nomenclature.
  50540. */
  50541. protected _reflectivityTexture: Nullable<BaseTexture>;
  50542. /**
  50543. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50544. */
  50545. protected _metallicTexture: Nullable<BaseTexture>;
  50546. /**
  50547. * Specifies the metallic scalar of the metallic/roughness workflow.
  50548. * Can also be used to scale the metalness values of the metallic texture.
  50549. */
  50550. protected _metallic: Nullable<number>;
  50551. /**
  50552. * Specifies the roughness scalar of the metallic/roughness workflow.
  50553. * Can also be used to scale the roughness values of the metallic texture.
  50554. */
  50555. protected _roughness: Nullable<number>;
  50556. /**
  50557. * Specifies the an F0 factor to help configuring the material F0.
  50558. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50559. * to 0.5 the previously hard coded value stays the same.
  50560. * Can also be used to scale the F0 values of the metallic texture.
  50561. */
  50562. protected _metallicF0Factor: number;
  50563. /**
  50564. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50565. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50566. * your expectation as it multiplies with the texture data.
  50567. */
  50568. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50569. /**
  50570. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50571. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50572. */
  50573. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50574. /**
  50575. * Stores surface normal data used to displace a mesh in a texture.
  50576. */
  50577. protected _bumpTexture: Nullable<BaseTexture>;
  50578. /**
  50579. * Stores the pre-calculated light information of a mesh in a texture.
  50580. */
  50581. protected _lightmapTexture: Nullable<BaseTexture>;
  50582. /**
  50583. * The color of a material in ambient lighting.
  50584. */
  50585. protected _ambientColor: Color3;
  50586. /**
  50587. * AKA Diffuse Color in other nomenclature.
  50588. */
  50589. protected _albedoColor: Color3;
  50590. /**
  50591. * AKA Specular Color in other nomenclature.
  50592. */
  50593. protected _reflectivityColor: Color3;
  50594. /**
  50595. * The color applied when light is reflected from a material.
  50596. */
  50597. protected _reflectionColor: Color3;
  50598. /**
  50599. * The color applied when light is emitted from a material.
  50600. */
  50601. protected _emissiveColor: Color3;
  50602. /**
  50603. * AKA Glossiness in other nomenclature.
  50604. */
  50605. protected _microSurface: number;
  50606. /**
  50607. * Specifies that the material will use the light map as a show map.
  50608. */
  50609. protected _useLightmapAsShadowmap: boolean;
  50610. /**
  50611. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50612. * makes the reflect vector face the model (under horizon).
  50613. */
  50614. protected _useHorizonOcclusion: boolean;
  50615. /**
  50616. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50617. * too much the area relying on ambient texture to define their ambient occlusion.
  50618. */
  50619. protected _useRadianceOcclusion: boolean;
  50620. /**
  50621. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50622. */
  50623. protected _useAlphaFromAlbedoTexture: boolean;
  50624. /**
  50625. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50626. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50627. */
  50628. protected _useSpecularOverAlpha: boolean;
  50629. /**
  50630. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50631. */
  50632. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50633. /**
  50634. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50635. */
  50636. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50637. /**
  50638. * Specifies if the metallic texture contains the roughness information in its green channel.
  50639. */
  50640. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50641. /**
  50642. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50643. */
  50644. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50645. /**
  50646. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50647. */
  50648. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50649. /**
  50650. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50651. */
  50652. protected _useAmbientInGrayScale: boolean;
  50653. /**
  50654. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50655. * The material will try to infer what glossiness each pixel should be.
  50656. */
  50657. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50658. /**
  50659. * Defines the falloff type used in this material.
  50660. * It by default is Physical.
  50661. */
  50662. protected _lightFalloff: number;
  50663. /**
  50664. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50665. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50666. */
  50667. protected _useRadianceOverAlpha: boolean;
  50668. /**
  50669. * Allows using an object space normal map (instead of tangent space).
  50670. */
  50671. protected _useObjectSpaceNormalMap: boolean;
  50672. /**
  50673. * Allows using the bump map in parallax mode.
  50674. */
  50675. protected _useParallax: boolean;
  50676. /**
  50677. * Allows using the bump map in parallax occlusion mode.
  50678. */
  50679. protected _useParallaxOcclusion: boolean;
  50680. /**
  50681. * Controls the scale bias of the parallax mode.
  50682. */
  50683. protected _parallaxScaleBias: number;
  50684. /**
  50685. * If sets to true, disables all the lights affecting the material.
  50686. */
  50687. protected _disableLighting: boolean;
  50688. /**
  50689. * Number of Simultaneous lights allowed on the material.
  50690. */
  50691. protected _maxSimultaneousLights: number;
  50692. /**
  50693. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50694. */
  50695. protected _invertNormalMapX: boolean;
  50696. /**
  50697. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50698. */
  50699. protected _invertNormalMapY: boolean;
  50700. /**
  50701. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50702. */
  50703. protected _twoSidedLighting: boolean;
  50704. /**
  50705. * Defines the alpha limits in alpha test mode.
  50706. */
  50707. protected _alphaCutOff: number;
  50708. /**
  50709. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50710. */
  50711. protected _forceAlphaTest: boolean;
  50712. /**
  50713. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50714. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50715. */
  50716. protected _useAlphaFresnel: boolean;
  50717. /**
  50718. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50719. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50720. */
  50721. protected _useLinearAlphaFresnel: boolean;
  50722. /**
  50723. * The transparency mode of the material.
  50724. */
  50725. protected _transparencyMode: Nullable<number>;
  50726. /**
  50727. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50728. * from cos thetav and roughness:
  50729. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50730. */
  50731. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50732. /**
  50733. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50734. */
  50735. protected _forceIrradianceInFragment: boolean;
  50736. /**
  50737. * Force normal to face away from face.
  50738. */
  50739. protected _forceNormalForward: boolean;
  50740. /**
  50741. * Enables specular anti aliasing in the PBR shader.
  50742. * It will both interacts on the Geometry for analytical and IBL lighting.
  50743. * It also prefilter the roughness map based on the bump values.
  50744. */
  50745. protected _enableSpecularAntiAliasing: boolean;
  50746. /**
  50747. * Default configuration related to image processing available in the PBR Material.
  50748. */
  50749. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50750. /**
  50751. * Keep track of the image processing observer to allow dispose and replace.
  50752. */
  50753. private _imageProcessingObserver;
  50754. /**
  50755. * Attaches a new image processing configuration to the PBR Material.
  50756. * @param configuration
  50757. */
  50758. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50759. /**
  50760. * Stores the available render targets.
  50761. */
  50762. private _renderTargets;
  50763. /**
  50764. * Sets the global ambient color for the material used in lighting calculations.
  50765. */
  50766. private _globalAmbientColor;
  50767. /**
  50768. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50769. */
  50770. private _useLogarithmicDepth;
  50771. /**
  50772. * If set to true, no lighting calculations will be applied.
  50773. */
  50774. private _unlit;
  50775. private _debugMode;
  50776. /**
  50777. * @hidden
  50778. * This is reserved for the inspector.
  50779. * Defines the material debug mode.
  50780. * It helps seeing only some components of the material while troubleshooting.
  50781. */
  50782. debugMode: number;
  50783. /**
  50784. * @hidden
  50785. * This is reserved for the inspector.
  50786. * Specify from where on screen the debug mode should start.
  50787. * The value goes from -1 (full screen) to 1 (not visible)
  50788. * It helps with side by side comparison against the final render
  50789. * This defaults to -1
  50790. */
  50791. private debugLimit;
  50792. /**
  50793. * @hidden
  50794. * This is reserved for the inspector.
  50795. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50796. * You can use the factor to better multiply the final value.
  50797. */
  50798. private debugFactor;
  50799. /**
  50800. * Defines the clear coat layer parameters for the material.
  50801. */
  50802. readonly clearCoat: PBRClearCoatConfiguration;
  50803. /**
  50804. * Defines the anisotropic parameters for the material.
  50805. */
  50806. readonly anisotropy: PBRAnisotropicConfiguration;
  50807. /**
  50808. * Defines the BRDF parameters for the material.
  50809. */
  50810. readonly brdf: PBRBRDFConfiguration;
  50811. /**
  50812. * Defines the Sheen parameters for the material.
  50813. */
  50814. readonly sheen: PBRSheenConfiguration;
  50815. /**
  50816. * Defines the SubSurface parameters for the material.
  50817. */
  50818. readonly subSurface: PBRSubSurfaceConfiguration;
  50819. /**
  50820. * Custom callback helping to override the default shader used in the material.
  50821. */
  50822. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50823. protected _rebuildInParallel: boolean;
  50824. /**
  50825. * Instantiates a new PBRMaterial instance.
  50826. *
  50827. * @param name The material name
  50828. * @param scene The scene the material will be use in.
  50829. */
  50830. constructor(name: string, scene: Scene);
  50831. /**
  50832. * Gets a boolean indicating that current material needs to register RTT
  50833. */
  50834. readonly hasRenderTargetTextures: boolean;
  50835. /**
  50836. * Gets the name of the material class.
  50837. */
  50838. getClassName(): string;
  50839. /**
  50840. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50841. */
  50842. /**
  50843. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50844. */
  50845. useLogarithmicDepth: boolean;
  50846. /**
  50847. * Gets the current transparency mode.
  50848. */
  50849. /**
  50850. * Sets the transparency mode of the material.
  50851. *
  50852. * | Value | Type | Description |
  50853. * | ----- | ----------------------------------- | ----------- |
  50854. * | 0 | OPAQUE | |
  50855. * | 1 | ALPHATEST | |
  50856. * | 2 | ALPHABLEND | |
  50857. * | 3 | ALPHATESTANDBLEND | |
  50858. *
  50859. */
  50860. transparencyMode: Nullable<number>;
  50861. /**
  50862. * Returns true if alpha blending should be disabled.
  50863. */
  50864. private readonly _disableAlphaBlending;
  50865. /**
  50866. * Specifies whether or not this material should be rendered in alpha blend mode.
  50867. */
  50868. needAlphaBlending(): boolean;
  50869. /**
  50870. * Specifies if the mesh will require alpha blending.
  50871. * @param mesh - BJS mesh.
  50872. */
  50873. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50874. /**
  50875. * Specifies whether or not this material should be rendered in alpha test mode.
  50876. */
  50877. needAlphaTesting(): boolean;
  50878. /**
  50879. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50880. */
  50881. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50882. /**
  50883. * Gets the texture used for the alpha test.
  50884. */
  50885. getAlphaTestTexture(): Nullable<BaseTexture>;
  50886. /**
  50887. * Specifies that the submesh is ready to be used.
  50888. * @param mesh - BJS mesh.
  50889. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50890. * @param useInstances - Specifies that instances should be used.
  50891. * @returns - boolean indicating that the submesh is ready or not.
  50892. */
  50893. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50894. /**
  50895. * Specifies if the material uses metallic roughness workflow.
  50896. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50897. */
  50898. isMetallicWorkflow(): boolean;
  50899. private _prepareEffect;
  50900. private _prepareDefines;
  50901. /**
  50902. * Force shader compilation
  50903. */
  50904. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  50905. /**
  50906. * Initializes the uniform buffer layout for the shader.
  50907. */
  50908. buildUniformLayout(): void;
  50909. /**
  50910. * Unbinds the material from the mesh
  50911. */
  50912. unbind(): void;
  50913. /**
  50914. * Binds the submesh data.
  50915. * @param world - The world matrix.
  50916. * @param mesh - The BJS mesh.
  50917. * @param subMesh - A submesh of the BJS mesh.
  50918. */
  50919. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50920. /**
  50921. * Returns the animatable textures.
  50922. * @returns - Array of animatable textures.
  50923. */
  50924. getAnimatables(): IAnimatable[];
  50925. /**
  50926. * Returns the texture used for reflections.
  50927. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50928. */
  50929. private _getReflectionTexture;
  50930. /**
  50931. * Returns an array of the actively used textures.
  50932. * @returns - Array of BaseTextures
  50933. */
  50934. getActiveTextures(): BaseTexture[];
  50935. /**
  50936. * Checks to see if a texture is used in the material.
  50937. * @param texture - Base texture to use.
  50938. * @returns - Boolean specifying if a texture is used in the material.
  50939. */
  50940. hasTexture(texture: BaseTexture): boolean;
  50941. /**
  50942. * Disposes the resources of the material.
  50943. * @param forceDisposeEffect - Forces the disposal of effects.
  50944. * @param forceDisposeTextures - Forces the disposal of all textures.
  50945. */
  50946. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50947. }
  50948. }
  50949. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50950. import { Nullable } from "babylonjs/types";
  50951. import { Scene } from "babylonjs/scene";
  50952. import { Color3 } from "babylonjs/Maths/math.color";
  50953. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50954. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50955. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50956. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50957. /**
  50958. * The Physically based material of BJS.
  50959. *
  50960. * This offers the main features of a standard PBR material.
  50961. * For more information, please refer to the documentation :
  50962. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50963. */
  50964. export class PBRMaterial extends PBRBaseMaterial {
  50965. /**
  50966. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50967. */
  50968. static readonly PBRMATERIAL_OPAQUE: number;
  50969. /**
  50970. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50971. */
  50972. static readonly PBRMATERIAL_ALPHATEST: number;
  50973. /**
  50974. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50975. */
  50976. static readonly PBRMATERIAL_ALPHABLEND: number;
  50977. /**
  50978. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50979. * They are also discarded below the alpha cutoff threshold to improve performances.
  50980. */
  50981. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50982. /**
  50983. * Defines the default value of how much AO map is occluding the analytical lights
  50984. * (point spot...).
  50985. */
  50986. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50987. /**
  50988. * Intensity of the direct lights e.g. the four lights available in your scene.
  50989. * This impacts both the direct diffuse and specular highlights.
  50990. */
  50991. directIntensity: number;
  50992. /**
  50993. * Intensity of the emissive part of the material.
  50994. * This helps controlling the emissive effect without modifying the emissive color.
  50995. */
  50996. emissiveIntensity: number;
  50997. /**
  50998. * Intensity of the environment e.g. how much the environment will light the object
  50999. * either through harmonics for rough material or through the refelction for shiny ones.
  51000. */
  51001. environmentIntensity: number;
  51002. /**
  51003. * This is a special control allowing the reduction of the specular highlights coming from the
  51004. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51005. */
  51006. specularIntensity: number;
  51007. /**
  51008. * Debug Control allowing disabling the bump map on this material.
  51009. */
  51010. disableBumpMap: boolean;
  51011. /**
  51012. * AKA Diffuse Texture in standard nomenclature.
  51013. */
  51014. albedoTexture: BaseTexture;
  51015. /**
  51016. * AKA Occlusion Texture in other nomenclature.
  51017. */
  51018. ambientTexture: BaseTexture;
  51019. /**
  51020. * AKA Occlusion Texture Intensity in other nomenclature.
  51021. */
  51022. ambientTextureStrength: number;
  51023. /**
  51024. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51025. * 1 means it completely occludes it
  51026. * 0 mean it has no impact
  51027. */
  51028. ambientTextureImpactOnAnalyticalLights: number;
  51029. /**
  51030. * Stores the alpha values in a texture.
  51031. */
  51032. opacityTexture: BaseTexture;
  51033. /**
  51034. * Stores the reflection values in a texture.
  51035. */
  51036. reflectionTexture: Nullable<BaseTexture>;
  51037. /**
  51038. * Stores the emissive values in a texture.
  51039. */
  51040. emissiveTexture: BaseTexture;
  51041. /**
  51042. * AKA Specular texture in other nomenclature.
  51043. */
  51044. reflectivityTexture: BaseTexture;
  51045. /**
  51046. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51047. */
  51048. metallicTexture: BaseTexture;
  51049. /**
  51050. * Specifies the metallic scalar of the metallic/roughness workflow.
  51051. * Can also be used to scale the metalness values of the metallic texture.
  51052. */
  51053. metallic: Nullable<number>;
  51054. /**
  51055. * Specifies the roughness scalar of the metallic/roughness workflow.
  51056. * Can also be used to scale the roughness values of the metallic texture.
  51057. */
  51058. roughness: Nullable<number>;
  51059. /**
  51060. * Specifies the an F0 factor to help configuring the material F0.
  51061. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51062. * to 0.5 the previously hard coded value stays the same.
  51063. * Can also be used to scale the F0 values of the metallic texture.
  51064. */
  51065. metallicF0Factor: number;
  51066. /**
  51067. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51068. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51069. * your expectation as it multiplies with the texture data.
  51070. */
  51071. useMetallicF0FactorFromMetallicTexture: boolean;
  51072. /**
  51073. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51074. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51075. */
  51076. microSurfaceTexture: BaseTexture;
  51077. /**
  51078. * Stores surface normal data used to displace a mesh in a texture.
  51079. */
  51080. bumpTexture: BaseTexture;
  51081. /**
  51082. * Stores the pre-calculated light information of a mesh in a texture.
  51083. */
  51084. lightmapTexture: BaseTexture;
  51085. /**
  51086. * Stores the refracted light information in a texture.
  51087. */
  51088. refractionTexture: Nullable<BaseTexture>;
  51089. /**
  51090. * The color of a material in ambient lighting.
  51091. */
  51092. ambientColor: Color3;
  51093. /**
  51094. * AKA Diffuse Color in other nomenclature.
  51095. */
  51096. albedoColor: Color3;
  51097. /**
  51098. * AKA Specular Color in other nomenclature.
  51099. */
  51100. reflectivityColor: Color3;
  51101. /**
  51102. * The color reflected from the material.
  51103. */
  51104. reflectionColor: Color3;
  51105. /**
  51106. * The color emitted from the material.
  51107. */
  51108. emissiveColor: Color3;
  51109. /**
  51110. * AKA Glossiness in other nomenclature.
  51111. */
  51112. microSurface: number;
  51113. /**
  51114. * source material index of refraction (IOR)' / 'destination material IOR.
  51115. */
  51116. indexOfRefraction: number;
  51117. /**
  51118. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51119. */
  51120. invertRefractionY: boolean;
  51121. /**
  51122. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51123. * Materials half opaque for instance using refraction could benefit from this control.
  51124. */
  51125. linkRefractionWithTransparency: boolean;
  51126. /**
  51127. * If true, the light map contains occlusion information instead of lighting info.
  51128. */
  51129. useLightmapAsShadowmap: boolean;
  51130. /**
  51131. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51132. */
  51133. useAlphaFromAlbedoTexture: boolean;
  51134. /**
  51135. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51136. */
  51137. forceAlphaTest: boolean;
  51138. /**
  51139. * Defines the alpha limits in alpha test mode.
  51140. */
  51141. alphaCutOff: number;
  51142. /**
  51143. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51144. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51145. */
  51146. useSpecularOverAlpha: boolean;
  51147. /**
  51148. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51149. */
  51150. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51151. /**
  51152. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51153. */
  51154. useRoughnessFromMetallicTextureAlpha: boolean;
  51155. /**
  51156. * Specifies if the metallic texture contains the roughness information in its green channel.
  51157. */
  51158. useRoughnessFromMetallicTextureGreen: boolean;
  51159. /**
  51160. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51161. */
  51162. useMetallnessFromMetallicTextureBlue: boolean;
  51163. /**
  51164. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51165. */
  51166. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51167. /**
  51168. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51169. */
  51170. useAmbientInGrayScale: boolean;
  51171. /**
  51172. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51173. * The material will try to infer what glossiness each pixel should be.
  51174. */
  51175. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51176. /**
  51177. * BJS is using an harcoded light falloff based on a manually sets up range.
  51178. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51179. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51180. */
  51181. /**
  51182. * BJS is using an harcoded light falloff based on a manually sets up range.
  51183. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51184. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51185. */
  51186. usePhysicalLightFalloff: boolean;
  51187. /**
  51188. * In order to support the falloff compatibility with gltf, a special mode has been added
  51189. * to reproduce the gltf light falloff.
  51190. */
  51191. /**
  51192. * In order to support the falloff compatibility with gltf, a special mode has been added
  51193. * to reproduce the gltf light falloff.
  51194. */
  51195. useGLTFLightFalloff: boolean;
  51196. /**
  51197. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51198. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51199. */
  51200. useRadianceOverAlpha: boolean;
  51201. /**
  51202. * Allows using an object space normal map (instead of tangent space).
  51203. */
  51204. useObjectSpaceNormalMap: boolean;
  51205. /**
  51206. * Allows using the bump map in parallax mode.
  51207. */
  51208. useParallax: boolean;
  51209. /**
  51210. * Allows using the bump map in parallax occlusion mode.
  51211. */
  51212. useParallaxOcclusion: boolean;
  51213. /**
  51214. * Controls the scale bias of the parallax mode.
  51215. */
  51216. parallaxScaleBias: number;
  51217. /**
  51218. * If sets to true, disables all the lights affecting the material.
  51219. */
  51220. disableLighting: boolean;
  51221. /**
  51222. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51223. */
  51224. forceIrradianceInFragment: boolean;
  51225. /**
  51226. * Number of Simultaneous lights allowed on the material.
  51227. */
  51228. maxSimultaneousLights: number;
  51229. /**
  51230. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51231. */
  51232. invertNormalMapX: boolean;
  51233. /**
  51234. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51235. */
  51236. invertNormalMapY: boolean;
  51237. /**
  51238. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51239. */
  51240. twoSidedLighting: boolean;
  51241. /**
  51242. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51243. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51244. */
  51245. useAlphaFresnel: boolean;
  51246. /**
  51247. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51248. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51249. */
  51250. useLinearAlphaFresnel: boolean;
  51251. /**
  51252. * Let user defines the brdf lookup texture used for IBL.
  51253. * A default 8bit version is embedded but you could point at :
  51254. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51255. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51256. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51257. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51258. */
  51259. environmentBRDFTexture: Nullable<BaseTexture>;
  51260. /**
  51261. * Force normal to face away from face.
  51262. */
  51263. forceNormalForward: boolean;
  51264. /**
  51265. * Enables specular anti aliasing in the PBR shader.
  51266. * It will both interacts on the Geometry for analytical and IBL lighting.
  51267. * It also prefilter the roughness map based on the bump values.
  51268. */
  51269. enableSpecularAntiAliasing: boolean;
  51270. /**
  51271. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51272. * makes the reflect vector face the model (under horizon).
  51273. */
  51274. useHorizonOcclusion: boolean;
  51275. /**
  51276. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51277. * too much the area relying on ambient texture to define their ambient occlusion.
  51278. */
  51279. useRadianceOcclusion: boolean;
  51280. /**
  51281. * If set to true, no lighting calculations will be applied.
  51282. */
  51283. unlit: boolean;
  51284. /**
  51285. * Gets the image processing configuration used either in this material.
  51286. */
  51287. /**
  51288. * Sets the Default image processing configuration used either in the this material.
  51289. *
  51290. * If sets to null, the scene one is in use.
  51291. */
  51292. imageProcessingConfiguration: ImageProcessingConfiguration;
  51293. /**
  51294. * Gets wether the color curves effect is enabled.
  51295. */
  51296. /**
  51297. * Sets wether the color curves effect is enabled.
  51298. */
  51299. cameraColorCurvesEnabled: boolean;
  51300. /**
  51301. * Gets wether the color grading effect is enabled.
  51302. */
  51303. /**
  51304. * Gets wether the color grading effect is enabled.
  51305. */
  51306. cameraColorGradingEnabled: boolean;
  51307. /**
  51308. * Gets wether tonemapping is enabled or not.
  51309. */
  51310. /**
  51311. * Sets wether tonemapping is enabled or not
  51312. */
  51313. cameraToneMappingEnabled: boolean;
  51314. /**
  51315. * The camera exposure used on this material.
  51316. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51317. * This corresponds to a photographic exposure.
  51318. */
  51319. /**
  51320. * The camera exposure used on this material.
  51321. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51322. * This corresponds to a photographic exposure.
  51323. */
  51324. cameraExposure: number;
  51325. /**
  51326. * Gets The camera contrast used on this material.
  51327. */
  51328. /**
  51329. * Sets The camera contrast used on this material.
  51330. */
  51331. cameraContrast: number;
  51332. /**
  51333. * Gets the Color Grading 2D Lookup Texture.
  51334. */
  51335. /**
  51336. * Sets the Color Grading 2D Lookup Texture.
  51337. */
  51338. cameraColorGradingTexture: Nullable<BaseTexture>;
  51339. /**
  51340. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51341. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51342. * 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;
  51343. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51344. */
  51345. /**
  51346. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51347. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51348. * 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;
  51349. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51350. */
  51351. cameraColorCurves: Nullable<ColorCurves>;
  51352. /**
  51353. * Instantiates a new PBRMaterial instance.
  51354. *
  51355. * @param name The material name
  51356. * @param scene The scene the material will be use in.
  51357. */
  51358. constructor(name: string, scene: Scene);
  51359. /**
  51360. * Returns the name of this material class.
  51361. */
  51362. getClassName(): string;
  51363. /**
  51364. * Makes a duplicate of the current material.
  51365. * @param name - name to use for the new material.
  51366. */
  51367. clone(name: string): PBRMaterial;
  51368. /**
  51369. * Serializes this PBR Material.
  51370. * @returns - An object with the serialized material.
  51371. */
  51372. serialize(): any;
  51373. /**
  51374. * Parses a PBR Material from a serialized object.
  51375. * @param source - Serialized object.
  51376. * @param scene - BJS scene instance.
  51377. * @param rootUrl - url for the scene object
  51378. * @returns - PBRMaterial
  51379. */
  51380. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51381. }
  51382. }
  51383. declare module "babylonjs/Misc/dds" {
  51384. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51385. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51386. import { Nullable } from "babylonjs/types";
  51387. import { Scene } from "babylonjs/scene";
  51388. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  51389. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51390. /**
  51391. * Direct draw surface info
  51392. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51393. */
  51394. export interface DDSInfo {
  51395. /**
  51396. * Width of the texture
  51397. */
  51398. width: number;
  51399. /**
  51400. * Width of the texture
  51401. */
  51402. height: number;
  51403. /**
  51404. * Number of Mipmaps for the texture
  51405. * @see https://en.wikipedia.org/wiki/Mipmap
  51406. */
  51407. mipmapCount: number;
  51408. /**
  51409. * If the textures format is a known fourCC format
  51410. * @see https://www.fourcc.org/
  51411. */
  51412. isFourCC: boolean;
  51413. /**
  51414. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51415. */
  51416. isRGB: boolean;
  51417. /**
  51418. * If the texture is a lumincance format
  51419. */
  51420. isLuminance: boolean;
  51421. /**
  51422. * If this is a cube texture
  51423. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51424. */
  51425. isCube: boolean;
  51426. /**
  51427. * If the texture is a compressed format eg. FOURCC_DXT1
  51428. */
  51429. isCompressed: boolean;
  51430. /**
  51431. * The dxgiFormat of the texture
  51432. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51433. */
  51434. dxgiFormat: number;
  51435. /**
  51436. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51437. */
  51438. textureType: number;
  51439. /**
  51440. * Sphericle polynomial created for the dds texture
  51441. */
  51442. sphericalPolynomial?: SphericalPolynomial;
  51443. }
  51444. /**
  51445. * Class used to provide DDS decompression tools
  51446. */
  51447. export class DDSTools {
  51448. /**
  51449. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51450. */
  51451. static StoreLODInAlphaChannel: boolean;
  51452. /**
  51453. * Gets DDS information from an array buffer
  51454. * @param arrayBuffer defines the array buffer to read data from
  51455. * @returns the DDS information
  51456. */
  51457. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  51458. private static _FloatView;
  51459. private static _Int32View;
  51460. private static _ToHalfFloat;
  51461. private static _FromHalfFloat;
  51462. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51463. private static _GetHalfFloatRGBAArrayBuffer;
  51464. private static _GetFloatRGBAArrayBuffer;
  51465. private static _GetFloatAsUIntRGBAArrayBuffer;
  51466. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51467. private static _GetRGBAArrayBuffer;
  51468. private static _ExtractLongWordOrder;
  51469. private static _GetRGBArrayBuffer;
  51470. private static _GetLuminanceArrayBuffer;
  51471. /**
  51472. * Uploads DDS Levels to a Babylon Texture
  51473. * @hidden
  51474. */
  51475. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51476. }
  51477. module "babylonjs/Engines/thinEngine" {
  51478. interface ThinEngine {
  51479. /**
  51480. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51481. * @param rootUrl defines the url where the file to load is located
  51482. * @param scene defines the current scene
  51483. * @param lodScale defines scale to apply to the mip map selection
  51484. * @param lodOffset defines offset to apply to the mip map selection
  51485. * @param onLoad defines an optional callback raised when the texture is loaded
  51486. * @param onError defines an optional callback raised if there is an issue to load the texture
  51487. * @param format defines the format of the data
  51488. * @param forcedExtension defines the extension to use to pick the right loader
  51489. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51490. * @returns the cube texture as an InternalTexture
  51491. */
  51492. 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;
  51493. }
  51494. }
  51495. }
  51496. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  51497. import { Nullable } from "babylonjs/types";
  51498. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51499. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51500. /**
  51501. * Implementation of the DDS Texture Loader.
  51502. * @hidden
  51503. */
  51504. export class _DDSTextureLoader implements IInternalTextureLoader {
  51505. /**
  51506. * Defines wether the loader supports cascade loading the different faces.
  51507. */
  51508. readonly supportCascades: boolean;
  51509. /**
  51510. * This returns if the loader support the current file information.
  51511. * @param extension defines the file extension of the file being loaded
  51512. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51513. * @param fallback defines the fallback internal texture if any
  51514. * @param isBase64 defines whether the texture is encoded as a base64
  51515. * @param isBuffer defines whether the texture data are stored as a buffer
  51516. * @returns true if the loader can load the specified file
  51517. */
  51518. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51519. /**
  51520. * Transform the url before loading if required.
  51521. * @param rootUrl the url of the texture
  51522. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51523. * @returns the transformed texture
  51524. */
  51525. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51526. /**
  51527. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51528. * @param rootUrl the url of the texture
  51529. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51530. * @returns the fallback texture
  51531. */
  51532. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51533. /**
  51534. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51535. * @param data contains the texture data
  51536. * @param texture defines the BabylonJS internal texture
  51537. * @param createPolynomials will be true if polynomials have been requested
  51538. * @param onLoad defines the callback to trigger once the texture is ready
  51539. * @param onError defines the callback to trigger in case of error
  51540. */
  51541. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51542. /**
  51543. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51544. * @param data contains the texture data
  51545. * @param texture defines the BabylonJS internal texture
  51546. * @param callback defines the method to call once ready to upload
  51547. */
  51548. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51549. }
  51550. }
  51551. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  51552. import { Nullable } from "babylonjs/types";
  51553. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51554. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51555. /**
  51556. * Implementation of the ENV Texture Loader.
  51557. * @hidden
  51558. */
  51559. export class _ENVTextureLoader implements IInternalTextureLoader {
  51560. /**
  51561. * Defines wether the loader supports cascade loading the different faces.
  51562. */
  51563. readonly supportCascades: boolean;
  51564. /**
  51565. * This returns if the loader support the current file information.
  51566. * @param extension defines the file extension of the file being loaded
  51567. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51568. * @param fallback defines the fallback internal texture if any
  51569. * @param isBase64 defines whether the texture is encoded as a base64
  51570. * @param isBuffer defines whether the texture data are stored as a buffer
  51571. * @returns true if the loader can load the specified file
  51572. */
  51573. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51574. /**
  51575. * Transform the url before loading if required.
  51576. * @param rootUrl the url of the texture
  51577. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51578. * @returns the transformed texture
  51579. */
  51580. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51581. /**
  51582. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51583. * @param rootUrl the url of the texture
  51584. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51585. * @returns the fallback texture
  51586. */
  51587. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51588. /**
  51589. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51590. * @param data contains the texture data
  51591. * @param texture defines the BabylonJS internal texture
  51592. * @param createPolynomials will be true if polynomials have been requested
  51593. * @param onLoad defines the callback to trigger once the texture is ready
  51594. * @param onError defines the callback to trigger in case of error
  51595. */
  51596. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51597. /**
  51598. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51599. * @param data contains the texture data
  51600. * @param texture defines the BabylonJS internal texture
  51601. * @param callback defines the method to call once ready to upload
  51602. */
  51603. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51604. }
  51605. }
  51606. declare module "babylonjs/Misc/khronosTextureContainer" {
  51607. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51608. /**
  51609. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51610. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51611. */
  51612. export class KhronosTextureContainer {
  51613. /** contents of the KTX container file */
  51614. arrayBuffer: any;
  51615. private static HEADER_LEN;
  51616. private static COMPRESSED_2D;
  51617. private static COMPRESSED_3D;
  51618. private static TEX_2D;
  51619. private static TEX_3D;
  51620. /**
  51621. * Gets the openGL type
  51622. */
  51623. glType: number;
  51624. /**
  51625. * Gets the openGL type size
  51626. */
  51627. glTypeSize: number;
  51628. /**
  51629. * Gets the openGL format
  51630. */
  51631. glFormat: number;
  51632. /**
  51633. * Gets the openGL internal format
  51634. */
  51635. glInternalFormat: number;
  51636. /**
  51637. * Gets the base internal format
  51638. */
  51639. glBaseInternalFormat: number;
  51640. /**
  51641. * Gets image width in pixel
  51642. */
  51643. pixelWidth: number;
  51644. /**
  51645. * Gets image height in pixel
  51646. */
  51647. pixelHeight: number;
  51648. /**
  51649. * Gets image depth in pixels
  51650. */
  51651. pixelDepth: number;
  51652. /**
  51653. * Gets the number of array elements
  51654. */
  51655. numberOfArrayElements: number;
  51656. /**
  51657. * Gets the number of faces
  51658. */
  51659. numberOfFaces: number;
  51660. /**
  51661. * Gets the number of mipmap levels
  51662. */
  51663. numberOfMipmapLevels: number;
  51664. /**
  51665. * Gets the bytes of key value data
  51666. */
  51667. bytesOfKeyValueData: number;
  51668. /**
  51669. * Gets the load type
  51670. */
  51671. loadType: number;
  51672. /**
  51673. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51674. */
  51675. isInvalid: boolean;
  51676. /**
  51677. * Creates a new KhronosTextureContainer
  51678. * @param arrayBuffer contents of the KTX container file
  51679. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51680. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51681. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51682. */
  51683. constructor(
  51684. /** contents of the KTX container file */
  51685. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51686. /**
  51687. * Uploads KTX content to a Babylon Texture.
  51688. * It is assumed that the texture has already been created & is currently bound
  51689. * @hidden
  51690. */
  51691. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51692. private _upload2DCompressedLevels;
  51693. }
  51694. }
  51695. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  51696. import { Nullable } from "babylonjs/types";
  51697. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51698. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51699. /**
  51700. * Implementation of the KTX Texture Loader.
  51701. * @hidden
  51702. */
  51703. export class _KTXTextureLoader implements IInternalTextureLoader {
  51704. /**
  51705. * Defines wether the loader supports cascade loading the different faces.
  51706. */
  51707. readonly supportCascades: boolean;
  51708. /**
  51709. * This returns if the loader support the current file information.
  51710. * @param extension defines the file extension of the file being loaded
  51711. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51712. * @param fallback defines the fallback internal texture if any
  51713. * @param isBase64 defines whether the texture is encoded as a base64
  51714. * @param isBuffer defines whether the texture data are stored as a buffer
  51715. * @returns true if the loader can load the specified file
  51716. */
  51717. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51718. /**
  51719. * Transform the url before loading if required.
  51720. * @param rootUrl the url of the texture
  51721. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51722. * @returns the transformed texture
  51723. */
  51724. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51725. /**
  51726. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51727. * @param rootUrl the url of the texture
  51728. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51729. * @returns the fallback texture
  51730. */
  51731. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51732. /**
  51733. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51734. * @param data contains the texture data
  51735. * @param texture defines the BabylonJS internal texture
  51736. * @param createPolynomials will be true if polynomials have been requested
  51737. * @param onLoad defines the callback to trigger once the texture is ready
  51738. * @param onError defines the callback to trigger in case of error
  51739. */
  51740. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51741. /**
  51742. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51743. * @param data contains the texture data
  51744. * @param texture defines the BabylonJS internal texture
  51745. * @param callback defines the method to call once ready to upload
  51746. */
  51747. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51748. }
  51749. }
  51750. declare module "babylonjs/Helpers/sceneHelpers" {
  51751. import { Nullable } from "babylonjs/types";
  51752. import { Mesh } from "babylonjs/Meshes/mesh";
  51753. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51754. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51755. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51756. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51757. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51758. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51759. import "babylonjs/Meshes/Builders/boxBuilder";
  51760. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51761. /** @hidden */
  51762. export var _forceSceneHelpersToBundle: boolean;
  51763. module "babylonjs/scene" {
  51764. interface Scene {
  51765. /**
  51766. * Creates a default light for the scene.
  51767. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51768. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51769. */
  51770. createDefaultLight(replace?: boolean): void;
  51771. /**
  51772. * Creates a default camera for the scene.
  51773. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51774. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51775. * @param replace has default false, when true replaces the active camera in the scene
  51776. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51777. */
  51778. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51779. /**
  51780. * Creates a default camera and a default light.
  51781. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51782. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51783. * @param replace has the default false, when true replaces the active camera/light in the scene
  51784. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51785. */
  51786. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51787. /**
  51788. * Creates a new sky box
  51789. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51790. * @param environmentTexture defines the texture to use as environment texture
  51791. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51792. * @param scale defines the overall scale of the skybox
  51793. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51794. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51795. * @returns a new mesh holding the sky box
  51796. */
  51797. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51798. /**
  51799. * Creates a new environment
  51800. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51801. * @param options defines the options you can use to configure the environment
  51802. * @returns the new EnvironmentHelper
  51803. */
  51804. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51805. /**
  51806. * Creates a new VREXperienceHelper
  51807. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51808. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51809. * @returns a new VREXperienceHelper
  51810. */
  51811. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51812. /**
  51813. * Creates a new WebXRDefaultExperience
  51814. * @see http://doc.babylonjs.com/how_to/webxr
  51815. * @param options experience options
  51816. * @returns a promise for a new WebXRDefaultExperience
  51817. */
  51818. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51819. }
  51820. }
  51821. }
  51822. declare module "babylonjs/Helpers/videoDome" {
  51823. import { Scene } from "babylonjs/scene";
  51824. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51825. import { Mesh } from "babylonjs/Meshes/mesh";
  51826. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51827. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51828. import "babylonjs/Meshes/Builders/sphereBuilder";
  51829. /**
  51830. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51831. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51832. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51833. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51834. */
  51835. export class VideoDome extends TransformNode {
  51836. /**
  51837. * Define the video source as a Monoscopic panoramic 360 video.
  51838. */
  51839. static readonly MODE_MONOSCOPIC: number;
  51840. /**
  51841. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51842. */
  51843. static readonly MODE_TOPBOTTOM: number;
  51844. /**
  51845. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51846. */
  51847. static readonly MODE_SIDEBYSIDE: number;
  51848. private _halfDome;
  51849. private _useDirectMapping;
  51850. /**
  51851. * The video texture being displayed on the sphere
  51852. */
  51853. protected _videoTexture: VideoTexture;
  51854. /**
  51855. * Gets the video texture being displayed on the sphere
  51856. */
  51857. readonly videoTexture: VideoTexture;
  51858. /**
  51859. * The skybox material
  51860. */
  51861. protected _material: BackgroundMaterial;
  51862. /**
  51863. * The surface used for the skybox
  51864. */
  51865. protected _mesh: Mesh;
  51866. /**
  51867. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51868. */
  51869. private _halfDomeMask;
  51870. /**
  51871. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51872. * Also see the options.resolution property.
  51873. */
  51874. fovMultiplier: number;
  51875. private _videoMode;
  51876. /**
  51877. * Gets or set the current video mode for the video. It can be:
  51878. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51879. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51880. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51881. */
  51882. videoMode: number;
  51883. /**
  51884. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51885. *
  51886. */
  51887. /**
  51888. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51889. */
  51890. halfDome: boolean;
  51891. /**
  51892. * Oberserver used in Stereoscopic VR Mode.
  51893. */
  51894. private _onBeforeCameraRenderObserver;
  51895. /**
  51896. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51897. * @param name Element's name, child elements will append suffixes for their own names.
  51898. * @param urlsOrVideo defines the url(s) or the video element to use
  51899. * @param options An object containing optional or exposed sub element properties
  51900. */
  51901. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51902. resolution?: number;
  51903. clickToPlay?: boolean;
  51904. autoPlay?: boolean;
  51905. loop?: boolean;
  51906. size?: number;
  51907. poster?: string;
  51908. faceForward?: boolean;
  51909. useDirectMapping?: boolean;
  51910. halfDomeMode?: boolean;
  51911. }, scene: Scene);
  51912. private _changeVideoMode;
  51913. /**
  51914. * Releases resources associated with this node.
  51915. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51916. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51917. */
  51918. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51919. }
  51920. }
  51921. declare module "babylonjs/Helpers/index" {
  51922. export * from "babylonjs/Helpers/environmentHelper";
  51923. export * from "babylonjs/Helpers/photoDome";
  51924. export * from "babylonjs/Helpers/sceneHelpers";
  51925. export * from "babylonjs/Helpers/videoDome";
  51926. }
  51927. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51928. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51929. import { IDisposable } from "babylonjs/scene";
  51930. import { Engine } from "babylonjs/Engines/engine";
  51931. /**
  51932. * This class can be used to get instrumentation data from a Babylon engine
  51933. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51934. */
  51935. export class EngineInstrumentation implements IDisposable {
  51936. /**
  51937. * Define the instrumented engine.
  51938. */
  51939. engine: Engine;
  51940. private _captureGPUFrameTime;
  51941. private _gpuFrameTimeToken;
  51942. private _gpuFrameTime;
  51943. private _captureShaderCompilationTime;
  51944. private _shaderCompilationTime;
  51945. private _onBeginFrameObserver;
  51946. private _onEndFrameObserver;
  51947. private _onBeforeShaderCompilationObserver;
  51948. private _onAfterShaderCompilationObserver;
  51949. /**
  51950. * Gets the perf counter used for GPU frame time
  51951. */
  51952. readonly gpuFrameTimeCounter: PerfCounter;
  51953. /**
  51954. * Gets the GPU frame time capture status
  51955. */
  51956. /**
  51957. * Enable or disable the GPU frame time capture
  51958. */
  51959. captureGPUFrameTime: boolean;
  51960. /**
  51961. * Gets the perf counter used for shader compilation time
  51962. */
  51963. readonly shaderCompilationTimeCounter: PerfCounter;
  51964. /**
  51965. * Gets the shader compilation time capture status
  51966. */
  51967. /**
  51968. * Enable or disable the shader compilation time capture
  51969. */
  51970. captureShaderCompilationTime: boolean;
  51971. /**
  51972. * Instantiates a new engine instrumentation.
  51973. * This class can be used to get instrumentation data from a Babylon engine
  51974. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51975. * @param engine Defines the engine to instrument
  51976. */
  51977. constructor(
  51978. /**
  51979. * Define the instrumented engine.
  51980. */
  51981. engine: Engine);
  51982. /**
  51983. * Dispose and release associated resources.
  51984. */
  51985. dispose(): void;
  51986. }
  51987. }
  51988. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51989. import { Scene, IDisposable } from "babylonjs/scene";
  51990. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51991. /**
  51992. * This class can be used to get instrumentation data from a Babylon engine
  51993. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51994. */
  51995. export class SceneInstrumentation implements IDisposable {
  51996. /**
  51997. * Defines the scene to instrument
  51998. */
  51999. scene: Scene;
  52000. private _captureActiveMeshesEvaluationTime;
  52001. private _activeMeshesEvaluationTime;
  52002. private _captureRenderTargetsRenderTime;
  52003. private _renderTargetsRenderTime;
  52004. private _captureFrameTime;
  52005. private _frameTime;
  52006. private _captureRenderTime;
  52007. private _renderTime;
  52008. private _captureInterFrameTime;
  52009. private _interFrameTime;
  52010. private _captureParticlesRenderTime;
  52011. private _particlesRenderTime;
  52012. private _captureSpritesRenderTime;
  52013. private _spritesRenderTime;
  52014. private _capturePhysicsTime;
  52015. private _physicsTime;
  52016. private _captureAnimationsTime;
  52017. private _animationsTime;
  52018. private _captureCameraRenderTime;
  52019. private _cameraRenderTime;
  52020. private _onBeforeActiveMeshesEvaluationObserver;
  52021. private _onAfterActiveMeshesEvaluationObserver;
  52022. private _onBeforeRenderTargetsRenderObserver;
  52023. private _onAfterRenderTargetsRenderObserver;
  52024. private _onAfterRenderObserver;
  52025. private _onBeforeDrawPhaseObserver;
  52026. private _onAfterDrawPhaseObserver;
  52027. private _onBeforeAnimationsObserver;
  52028. private _onBeforeParticlesRenderingObserver;
  52029. private _onAfterParticlesRenderingObserver;
  52030. private _onBeforeSpritesRenderingObserver;
  52031. private _onAfterSpritesRenderingObserver;
  52032. private _onBeforePhysicsObserver;
  52033. private _onAfterPhysicsObserver;
  52034. private _onAfterAnimationsObserver;
  52035. private _onBeforeCameraRenderObserver;
  52036. private _onAfterCameraRenderObserver;
  52037. /**
  52038. * Gets the perf counter used for active meshes evaluation time
  52039. */
  52040. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  52041. /**
  52042. * Gets the active meshes evaluation time capture status
  52043. */
  52044. /**
  52045. * Enable or disable the active meshes evaluation time capture
  52046. */
  52047. captureActiveMeshesEvaluationTime: boolean;
  52048. /**
  52049. * Gets the perf counter used for render targets render time
  52050. */
  52051. readonly renderTargetsRenderTimeCounter: PerfCounter;
  52052. /**
  52053. * Gets the render targets render time capture status
  52054. */
  52055. /**
  52056. * Enable or disable the render targets render time capture
  52057. */
  52058. captureRenderTargetsRenderTime: boolean;
  52059. /**
  52060. * Gets the perf counter used for particles render time
  52061. */
  52062. readonly particlesRenderTimeCounter: PerfCounter;
  52063. /**
  52064. * Gets the particles render time capture status
  52065. */
  52066. /**
  52067. * Enable or disable the particles render time capture
  52068. */
  52069. captureParticlesRenderTime: boolean;
  52070. /**
  52071. * Gets the perf counter used for sprites render time
  52072. */
  52073. readonly spritesRenderTimeCounter: PerfCounter;
  52074. /**
  52075. * Gets the sprites render time capture status
  52076. */
  52077. /**
  52078. * Enable or disable the sprites render time capture
  52079. */
  52080. captureSpritesRenderTime: boolean;
  52081. /**
  52082. * Gets the perf counter used for physics time
  52083. */
  52084. readonly physicsTimeCounter: PerfCounter;
  52085. /**
  52086. * Gets the physics time capture status
  52087. */
  52088. /**
  52089. * Enable or disable the physics time capture
  52090. */
  52091. capturePhysicsTime: boolean;
  52092. /**
  52093. * Gets the perf counter used for animations time
  52094. */
  52095. readonly animationsTimeCounter: PerfCounter;
  52096. /**
  52097. * Gets the animations time capture status
  52098. */
  52099. /**
  52100. * Enable or disable the animations time capture
  52101. */
  52102. captureAnimationsTime: boolean;
  52103. /**
  52104. * Gets the perf counter used for frame time capture
  52105. */
  52106. readonly frameTimeCounter: PerfCounter;
  52107. /**
  52108. * Gets the frame time capture status
  52109. */
  52110. /**
  52111. * Enable or disable the frame time capture
  52112. */
  52113. captureFrameTime: boolean;
  52114. /**
  52115. * Gets the perf counter used for inter-frames time capture
  52116. */
  52117. readonly interFrameTimeCounter: PerfCounter;
  52118. /**
  52119. * Gets the inter-frames time capture status
  52120. */
  52121. /**
  52122. * Enable or disable the inter-frames time capture
  52123. */
  52124. captureInterFrameTime: boolean;
  52125. /**
  52126. * Gets the perf counter used for render time capture
  52127. */
  52128. readonly renderTimeCounter: PerfCounter;
  52129. /**
  52130. * Gets the render time capture status
  52131. */
  52132. /**
  52133. * Enable or disable the render time capture
  52134. */
  52135. captureRenderTime: boolean;
  52136. /**
  52137. * Gets the perf counter used for camera render time capture
  52138. */
  52139. readonly cameraRenderTimeCounter: PerfCounter;
  52140. /**
  52141. * Gets the camera render time capture status
  52142. */
  52143. /**
  52144. * Enable or disable the camera render time capture
  52145. */
  52146. captureCameraRenderTime: boolean;
  52147. /**
  52148. * Gets the perf counter used for draw calls
  52149. */
  52150. readonly drawCallsCounter: PerfCounter;
  52151. /**
  52152. * Instantiates a new scene instrumentation.
  52153. * This class can be used to get instrumentation data from a Babylon engine
  52154. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52155. * @param scene Defines the scene to instrument
  52156. */
  52157. constructor(
  52158. /**
  52159. * Defines the scene to instrument
  52160. */
  52161. scene: Scene);
  52162. /**
  52163. * Dispose and release associated resources.
  52164. */
  52165. dispose(): void;
  52166. }
  52167. }
  52168. declare module "babylonjs/Instrumentation/index" {
  52169. export * from "babylonjs/Instrumentation/engineInstrumentation";
  52170. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  52171. export * from "babylonjs/Instrumentation/timeToken";
  52172. }
  52173. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  52174. /** @hidden */
  52175. export var glowMapGenerationPixelShader: {
  52176. name: string;
  52177. shader: string;
  52178. };
  52179. }
  52180. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  52181. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52182. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52183. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52184. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52185. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52186. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52187. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52188. /** @hidden */
  52189. export var glowMapGenerationVertexShader: {
  52190. name: string;
  52191. shader: string;
  52192. };
  52193. }
  52194. declare module "babylonjs/Layers/effectLayer" {
  52195. import { Observable } from "babylonjs/Misc/observable";
  52196. import { Nullable } from "babylonjs/types";
  52197. import { Camera } from "babylonjs/Cameras/camera";
  52198. import { Scene } from "babylonjs/scene";
  52199. import { ISize } from "babylonjs/Maths/math.size";
  52200. import { Color4 } from "babylonjs/Maths/math.color";
  52201. import { Engine } from "babylonjs/Engines/engine";
  52202. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52203. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52204. import { Mesh } from "babylonjs/Meshes/mesh";
  52205. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52206. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52207. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52208. import { Effect } from "babylonjs/Materials/effect";
  52209. import { Material } from "babylonjs/Materials/material";
  52210. import "babylonjs/Shaders/glowMapGeneration.fragment";
  52211. import "babylonjs/Shaders/glowMapGeneration.vertex";
  52212. /**
  52213. * Effect layer options. This helps customizing the behaviour
  52214. * of the effect layer.
  52215. */
  52216. export interface IEffectLayerOptions {
  52217. /**
  52218. * Multiplication factor apply to the canvas size to compute the render target size
  52219. * used to generated the objects (the smaller the faster).
  52220. */
  52221. mainTextureRatio: number;
  52222. /**
  52223. * Enforces a fixed size texture to ensure effect stability across devices.
  52224. */
  52225. mainTextureFixedSize?: number;
  52226. /**
  52227. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52228. */
  52229. alphaBlendingMode: number;
  52230. /**
  52231. * The camera attached to the layer.
  52232. */
  52233. camera: Nullable<Camera>;
  52234. /**
  52235. * The rendering group to draw the layer in.
  52236. */
  52237. renderingGroupId: number;
  52238. }
  52239. /**
  52240. * The effect layer Helps adding post process effect blended with the main pass.
  52241. *
  52242. * This can be for instance use to generate glow or higlight effects on the scene.
  52243. *
  52244. * The effect layer class can not be used directly and is intented to inherited from to be
  52245. * customized per effects.
  52246. */
  52247. export abstract class EffectLayer {
  52248. private _vertexBuffers;
  52249. private _indexBuffer;
  52250. private _cachedDefines;
  52251. private _effectLayerMapGenerationEffect;
  52252. private _effectLayerOptions;
  52253. private _mergeEffect;
  52254. protected _scene: Scene;
  52255. protected _engine: Engine;
  52256. protected _maxSize: number;
  52257. protected _mainTextureDesiredSize: ISize;
  52258. protected _mainTexture: RenderTargetTexture;
  52259. protected _shouldRender: boolean;
  52260. protected _postProcesses: PostProcess[];
  52261. protected _textures: BaseTexture[];
  52262. protected _emissiveTextureAndColor: {
  52263. texture: Nullable<BaseTexture>;
  52264. color: Color4;
  52265. };
  52266. /**
  52267. * The name of the layer
  52268. */
  52269. name: string;
  52270. /**
  52271. * The clear color of the texture used to generate the glow map.
  52272. */
  52273. neutralColor: Color4;
  52274. /**
  52275. * Specifies wether the highlight layer is enabled or not.
  52276. */
  52277. isEnabled: boolean;
  52278. /**
  52279. * Gets the camera attached to the layer.
  52280. */
  52281. readonly camera: Nullable<Camera>;
  52282. /**
  52283. * Gets the rendering group id the layer should render in.
  52284. */
  52285. renderingGroupId: number;
  52286. /**
  52287. * An event triggered when the effect layer has been disposed.
  52288. */
  52289. onDisposeObservable: Observable<EffectLayer>;
  52290. /**
  52291. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52292. */
  52293. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52294. /**
  52295. * An event triggered when the generated texture is being merged in the scene.
  52296. */
  52297. onBeforeComposeObservable: Observable<EffectLayer>;
  52298. /**
  52299. * An event triggered when the mesh is rendered into the effect render target.
  52300. */
  52301. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52302. /**
  52303. * An event triggered after the mesh has been rendered into the effect render target.
  52304. */
  52305. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52306. /**
  52307. * An event triggered when the generated texture has been merged in the scene.
  52308. */
  52309. onAfterComposeObservable: Observable<EffectLayer>;
  52310. /**
  52311. * An event triggered when the efffect layer changes its size.
  52312. */
  52313. onSizeChangedObservable: Observable<EffectLayer>;
  52314. /** @hidden */
  52315. static _SceneComponentInitialization: (scene: Scene) => void;
  52316. /**
  52317. * Instantiates a new effect Layer and references it in the scene.
  52318. * @param name The name of the layer
  52319. * @param scene The scene to use the layer in
  52320. */
  52321. constructor(
  52322. /** The Friendly of the effect in the scene */
  52323. name: string, scene: Scene);
  52324. /**
  52325. * Get the effect name of the layer.
  52326. * @return The effect name
  52327. */
  52328. abstract getEffectName(): string;
  52329. /**
  52330. * Checks for the readiness of the element composing the layer.
  52331. * @param subMesh the mesh to check for
  52332. * @param useInstances specify wether or not to use instances to render the mesh
  52333. * @return true if ready otherwise, false
  52334. */
  52335. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52336. /**
  52337. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52338. * @returns true if the effect requires stencil during the main canvas render pass.
  52339. */
  52340. abstract needStencil(): boolean;
  52341. /**
  52342. * Create the merge effect. This is the shader use to blit the information back
  52343. * to the main canvas at the end of the scene rendering.
  52344. * @returns The effect containing the shader used to merge the effect on the main canvas
  52345. */
  52346. protected abstract _createMergeEffect(): Effect;
  52347. /**
  52348. * Creates the render target textures and post processes used in the effect layer.
  52349. */
  52350. protected abstract _createTextureAndPostProcesses(): void;
  52351. /**
  52352. * Implementation specific of rendering the generating effect on the main canvas.
  52353. * @param effect The effect used to render through
  52354. */
  52355. protected abstract _internalRender(effect: Effect): void;
  52356. /**
  52357. * Sets the required values for both the emissive texture and and the main color.
  52358. */
  52359. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52360. /**
  52361. * Free any resources and references associated to a mesh.
  52362. * Internal use
  52363. * @param mesh The mesh to free.
  52364. */
  52365. abstract _disposeMesh(mesh: Mesh): void;
  52366. /**
  52367. * Serializes this layer (Glow or Highlight for example)
  52368. * @returns a serialized layer object
  52369. */
  52370. abstract serialize?(): any;
  52371. /**
  52372. * Initializes the effect layer with the required options.
  52373. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52374. */
  52375. protected _init(options: Partial<IEffectLayerOptions>): void;
  52376. /**
  52377. * Generates the index buffer of the full screen quad blending to the main canvas.
  52378. */
  52379. private _generateIndexBuffer;
  52380. /**
  52381. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52382. */
  52383. private _generateVertexBuffer;
  52384. /**
  52385. * Sets the main texture desired size which is the closest power of two
  52386. * of the engine canvas size.
  52387. */
  52388. private _setMainTextureSize;
  52389. /**
  52390. * Creates the main texture for the effect layer.
  52391. */
  52392. protected _createMainTexture(): void;
  52393. /**
  52394. * Adds specific effects defines.
  52395. * @param defines The defines to add specifics to.
  52396. */
  52397. protected _addCustomEffectDefines(defines: string[]): void;
  52398. /**
  52399. * Checks for the readiness of the element composing the layer.
  52400. * @param subMesh the mesh to check for
  52401. * @param useInstances specify wether or not to use instances to render the mesh
  52402. * @param emissiveTexture the associated emissive texture used to generate the glow
  52403. * @return true if ready otherwise, false
  52404. */
  52405. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52406. /**
  52407. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52408. */
  52409. render(): void;
  52410. /**
  52411. * Determine if a given mesh will be used in the current effect.
  52412. * @param mesh mesh to test
  52413. * @returns true if the mesh will be used
  52414. */
  52415. hasMesh(mesh: AbstractMesh): boolean;
  52416. /**
  52417. * Returns true if the layer contains information to display, otherwise false.
  52418. * @returns true if the glow layer should be rendered
  52419. */
  52420. shouldRender(): boolean;
  52421. /**
  52422. * Returns true if the mesh should render, otherwise false.
  52423. * @param mesh The mesh to render
  52424. * @returns true if it should render otherwise false
  52425. */
  52426. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52427. /**
  52428. * Returns true if the mesh can be rendered, otherwise false.
  52429. * @param mesh The mesh to render
  52430. * @param material The material used on the mesh
  52431. * @returns true if it can be rendered otherwise false
  52432. */
  52433. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52434. /**
  52435. * Returns true if the mesh should render, otherwise false.
  52436. * @param mesh The mesh to render
  52437. * @returns true if it should render otherwise false
  52438. */
  52439. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52440. /**
  52441. * Renders the submesh passed in parameter to the generation map.
  52442. */
  52443. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52444. /**
  52445. * Defines wether the current material of the mesh should be use to render the effect.
  52446. * @param mesh defines the current mesh to render
  52447. */
  52448. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52449. /**
  52450. * Rebuild the required buffers.
  52451. * @hidden Internal use only.
  52452. */
  52453. _rebuild(): void;
  52454. /**
  52455. * Dispose only the render target textures and post process.
  52456. */
  52457. private _disposeTextureAndPostProcesses;
  52458. /**
  52459. * Dispose the highlight layer and free resources.
  52460. */
  52461. dispose(): void;
  52462. /**
  52463. * Gets the class name of the effect layer
  52464. * @returns the string with the class name of the effect layer
  52465. */
  52466. getClassName(): string;
  52467. /**
  52468. * Creates an effect layer from parsed effect layer data
  52469. * @param parsedEffectLayer defines effect layer data
  52470. * @param scene defines the current scene
  52471. * @param rootUrl defines the root URL containing the effect layer information
  52472. * @returns a parsed effect Layer
  52473. */
  52474. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52475. }
  52476. }
  52477. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  52478. import { Scene } from "babylonjs/scene";
  52479. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52480. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52481. import { AbstractScene } from "babylonjs/abstractScene";
  52482. module "babylonjs/abstractScene" {
  52483. interface AbstractScene {
  52484. /**
  52485. * The list of effect layers (highlights/glow) added to the scene
  52486. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52487. * @see http://doc.babylonjs.com/how_to/glow_layer
  52488. */
  52489. effectLayers: Array<EffectLayer>;
  52490. /**
  52491. * Removes the given effect layer from this scene.
  52492. * @param toRemove defines the effect layer to remove
  52493. * @returns the index of the removed effect layer
  52494. */
  52495. removeEffectLayer(toRemove: EffectLayer): number;
  52496. /**
  52497. * Adds the given effect layer to this scene
  52498. * @param newEffectLayer defines the effect layer to add
  52499. */
  52500. addEffectLayer(newEffectLayer: EffectLayer): void;
  52501. }
  52502. }
  52503. /**
  52504. * Defines the layer scene component responsible to manage any effect layers
  52505. * in a given scene.
  52506. */
  52507. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52508. /**
  52509. * The component name helpfull to identify the component in the list of scene components.
  52510. */
  52511. readonly name: string;
  52512. /**
  52513. * The scene the component belongs to.
  52514. */
  52515. scene: Scene;
  52516. private _engine;
  52517. private _renderEffects;
  52518. private _needStencil;
  52519. private _previousStencilState;
  52520. /**
  52521. * Creates a new instance of the component for the given scene
  52522. * @param scene Defines the scene to register the component in
  52523. */
  52524. constructor(scene: Scene);
  52525. /**
  52526. * Registers the component in a given scene
  52527. */
  52528. register(): void;
  52529. /**
  52530. * Rebuilds the elements related to this component in case of
  52531. * context lost for instance.
  52532. */
  52533. rebuild(): void;
  52534. /**
  52535. * Serializes the component data to the specified json object
  52536. * @param serializationObject The object to serialize to
  52537. */
  52538. serialize(serializationObject: any): void;
  52539. /**
  52540. * Adds all the elements from the container to the scene
  52541. * @param container the container holding the elements
  52542. */
  52543. addFromContainer(container: AbstractScene): void;
  52544. /**
  52545. * Removes all the elements in the container from the scene
  52546. * @param container contains the elements to remove
  52547. * @param dispose if the removed element should be disposed (default: false)
  52548. */
  52549. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52550. /**
  52551. * Disposes the component and the associated ressources.
  52552. */
  52553. dispose(): void;
  52554. private _isReadyForMesh;
  52555. private _renderMainTexture;
  52556. private _setStencil;
  52557. private _setStencilBack;
  52558. private _draw;
  52559. private _drawCamera;
  52560. private _drawRenderingGroup;
  52561. }
  52562. }
  52563. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52564. /** @hidden */
  52565. export var glowMapMergePixelShader: {
  52566. name: string;
  52567. shader: string;
  52568. };
  52569. }
  52570. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52571. /** @hidden */
  52572. export var glowMapMergeVertexShader: {
  52573. name: string;
  52574. shader: string;
  52575. };
  52576. }
  52577. declare module "babylonjs/Layers/glowLayer" {
  52578. import { Nullable } from "babylonjs/types";
  52579. import { Camera } from "babylonjs/Cameras/camera";
  52580. import { Scene } from "babylonjs/scene";
  52581. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52583. import { Mesh } from "babylonjs/Meshes/mesh";
  52584. import { Texture } from "babylonjs/Materials/Textures/texture";
  52585. import { Effect } from "babylonjs/Materials/effect";
  52586. import { Material } from "babylonjs/Materials/material";
  52587. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52588. import { Color4 } from "babylonjs/Maths/math.color";
  52589. import "babylonjs/Shaders/glowMapMerge.fragment";
  52590. import "babylonjs/Shaders/glowMapMerge.vertex";
  52591. import "babylonjs/Layers/effectLayerSceneComponent";
  52592. module "babylonjs/abstractScene" {
  52593. interface AbstractScene {
  52594. /**
  52595. * Return a the first highlight layer of the scene with a given name.
  52596. * @param name The name of the highlight layer to look for.
  52597. * @return The highlight layer if found otherwise null.
  52598. */
  52599. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52600. }
  52601. }
  52602. /**
  52603. * Glow layer options. This helps customizing the behaviour
  52604. * of the glow layer.
  52605. */
  52606. export interface IGlowLayerOptions {
  52607. /**
  52608. * Multiplication factor apply to the canvas size to compute the render target size
  52609. * used to generated the glowing objects (the smaller the faster).
  52610. */
  52611. mainTextureRatio: number;
  52612. /**
  52613. * Enforces a fixed size texture to ensure resize independant blur.
  52614. */
  52615. mainTextureFixedSize?: number;
  52616. /**
  52617. * How big is the kernel of the blur texture.
  52618. */
  52619. blurKernelSize: number;
  52620. /**
  52621. * The camera attached to the layer.
  52622. */
  52623. camera: Nullable<Camera>;
  52624. /**
  52625. * Enable MSAA by chosing the number of samples.
  52626. */
  52627. mainTextureSamples?: number;
  52628. /**
  52629. * The rendering group to draw the layer in.
  52630. */
  52631. renderingGroupId: number;
  52632. }
  52633. /**
  52634. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52635. *
  52636. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  52637. *
  52638. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52639. */
  52640. export class GlowLayer extends EffectLayer {
  52641. /**
  52642. * Effect Name of the layer.
  52643. */
  52644. static readonly EffectName: string;
  52645. /**
  52646. * The default blur kernel size used for the glow.
  52647. */
  52648. static DefaultBlurKernelSize: number;
  52649. /**
  52650. * The default texture size ratio used for the glow.
  52651. */
  52652. static DefaultTextureRatio: number;
  52653. /**
  52654. * Sets the kernel size of the blur.
  52655. */
  52656. /**
  52657. * Gets the kernel size of the blur.
  52658. */
  52659. blurKernelSize: number;
  52660. /**
  52661. * Sets the glow intensity.
  52662. */
  52663. /**
  52664. * Gets the glow intensity.
  52665. */
  52666. intensity: number;
  52667. private _options;
  52668. private _intensity;
  52669. private _horizontalBlurPostprocess1;
  52670. private _verticalBlurPostprocess1;
  52671. private _horizontalBlurPostprocess2;
  52672. private _verticalBlurPostprocess2;
  52673. private _blurTexture1;
  52674. private _blurTexture2;
  52675. private _postProcesses1;
  52676. private _postProcesses2;
  52677. private _includedOnlyMeshes;
  52678. private _excludedMeshes;
  52679. private _meshesUsingTheirOwnMaterials;
  52680. /**
  52681. * Callback used to let the user override the color selection on a per mesh basis
  52682. */
  52683. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52684. /**
  52685. * Callback used to let the user override the texture selection on a per mesh basis
  52686. */
  52687. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52688. /**
  52689. * Instantiates a new glow Layer and references it to the scene.
  52690. * @param name The name of the layer
  52691. * @param scene The scene to use the layer in
  52692. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52693. */
  52694. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52695. /**
  52696. * Get the effect name of the layer.
  52697. * @return The effect name
  52698. */
  52699. getEffectName(): string;
  52700. /**
  52701. * Create the merge effect. This is the shader use to blit the information back
  52702. * to the main canvas at the end of the scene rendering.
  52703. */
  52704. protected _createMergeEffect(): Effect;
  52705. /**
  52706. * Creates the render target textures and post processes used in the glow layer.
  52707. */
  52708. protected _createTextureAndPostProcesses(): void;
  52709. /**
  52710. * Checks for the readiness of the element composing the layer.
  52711. * @param subMesh the mesh to check for
  52712. * @param useInstances specify wether or not to use instances to render the mesh
  52713. * @param emissiveTexture the associated emissive texture used to generate the glow
  52714. * @return true if ready otherwise, false
  52715. */
  52716. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52717. /**
  52718. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52719. */
  52720. needStencil(): boolean;
  52721. /**
  52722. * Returns true if the mesh can be rendered, otherwise false.
  52723. * @param mesh The mesh to render
  52724. * @param material The material used on the mesh
  52725. * @returns true if it can be rendered otherwise false
  52726. */
  52727. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52728. /**
  52729. * Implementation specific of rendering the generating effect on the main canvas.
  52730. * @param effect The effect used to render through
  52731. */
  52732. protected _internalRender(effect: Effect): void;
  52733. /**
  52734. * Sets the required values for both the emissive texture and and the main color.
  52735. */
  52736. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52737. /**
  52738. * Returns true if the mesh should render, otherwise false.
  52739. * @param mesh The mesh to render
  52740. * @returns true if it should render otherwise false
  52741. */
  52742. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52743. /**
  52744. * Adds specific effects defines.
  52745. * @param defines The defines to add specifics to.
  52746. */
  52747. protected _addCustomEffectDefines(defines: string[]): void;
  52748. /**
  52749. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52750. * @param mesh The mesh to exclude from the glow layer
  52751. */
  52752. addExcludedMesh(mesh: Mesh): void;
  52753. /**
  52754. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52755. * @param mesh The mesh to remove
  52756. */
  52757. removeExcludedMesh(mesh: Mesh): void;
  52758. /**
  52759. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52760. * @param mesh The mesh to include in the glow layer
  52761. */
  52762. addIncludedOnlyMesh(mesh: Mesh): void;
  52763. /**
  52764. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52765. * @param mesh The mesh to remove
  52766. */
  52767. removeIncludedOnlyMesh(mesh: Mesh): void;
  52768. /**
  52769. * Determine if a given mesh will be used in the glow layer
  52770. * @param mesh The mesh to test
  52771. * @returns true if the mesh will be highlighted by the current glow layer
  52772. */
  52773. hasMesh(mesh: AbstractMesh): boolean;
  52774. /**
  52775. * Defines wether the current material of the mesh should be use to render the effect.
  52776. * @param mesh defines the current mesh to render
  52777. */
  52778. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52779. /**
  52780. * Add a mesh to be rendered through its own material and not with emissive only.
  52781. * @param mesh The mesh for which we need to use its material
  52782. */
  52783. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  52784. /**
  52785. * Remove a mesh from being rendered through its own material and not with emissive only.
  52786. * @param mesh The mesh for which we need to not use its material
  52787. */
  52788. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  52789. /**
  52790. * Free any resources and references associated to a mesh.
  52791. * Internal use
  52792. * @param mesh The mesh to free.
  52793. * @hidden
  52794. */
  52795. _disposeMesh(mesh: Mesh): void;
  52796. /**
  52797. * Gets the class name of the effect layer
  52798. * @returns the string with the class name of the effect layer
  52799. */
  52800. getClassName(): string;
  52801. /**
  52802. * Serializes this glow layer
  52803. * @returns a serialized glow layer object
  52804. */
  52805. serialize(): any;
  52806. /**
  52807. * Creates a Glow Layer from parsed glow layer data
  52808. * @param parsedGlowLayer defines glow layer data
  52809. * @param scene defines the current scene
  52810. * @param rootUrl defines the root URL containing the glow layer information
  52811. * @returns a parsed Glow Layer
  52812. */
  52813. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52814. }
  52815. }
  52816. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52817. /** @hidden */
  52818. export var glowBlurPostProcessPixelShader: {
  52819. name: string;
  52820. shader: string;
  52821. };
  52822. }
  52823. declare module "babylonjs/Layers/highlightLayer" {
  52824. import { Observable } from "babylonjs/Misc/observable";
  52825. import { Nullable } from "babylonjs/types";
  52826. import { Camera } from "babylonjs/Cameras/camera";
  52827. import { Scene } from "babylonjs/scene";
  52828. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52830. import { Mesh } from "babylonjs/Meshes/mesh";
  52831. import { Effect } from "babylonjs/Materials/effect";
  52832. import { Material } from "babylonjs/Materials/material";
  52833. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52834. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52835. import "babylonjs/Shaders/glowMapMerge.fragment";
  52836. import "babylonjs/Shaders/glowMapMerge.vertex";
  52837. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52838. module "babylonjs/abstractScene" {
  52839. interface AbstractScene {
  52840. /**
  52841. * Return a the first highlight layer of the scene with a given name.
  52842. * @param name The name of the highlight layer to look for.
  52843. * @return The highlight layer if found otherwise null.
  52844. */
  52845. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52846. }
  52847. }
  52848. /**
  52849. * Highlight layer options. This helps customizing the behaviour
  52850. * of the highlight layer.
  52851. */
  52852. export interface IHighlightLayerOptions {
  52853. /**
  52854. * Multiplication factor apply to the canvas size to compute the render target size
  52855. * used to generated the glowing objects (the smaller the faster).
  52856. */
  52857. mainTextureRatio: number;
  52858. /**
  52859. * Enforces a fixed size texture to ensure resize independant blur.
  52860. */
  52861. mainTextureFixedSize?: number;
  52862. /**
  52863. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52864. * of the picture to blur (the smaller the faster).
  52865. */
  52866. blurTextureSizeRatio: number;
  52867. /**
  52868. * How big in texel of the blur texture is the vertical blur.
  52869. */
  52870. blurVerticalSize: number;
  52871. /**
  52872. * How big in texel of the blur texture is the horizontal blur.
  52873. */
  52874. blurHorizontalSize: number;
  52875. /**
  52876. * Alpha blending mode used to apply the blur. Default is combine.
  52877. */
  52878. alphaBlendingMode: number;
  52879. /**
  52880. * The camera attached to the layer.
  52881. */
  52882. camera: Nullable<Camera>;
  52883. /**
  52884. * Should we display highlight as a solid stroke?
  52885. */
  52886. isStroke?: boolean;
  52887. /**
  52888. * The rendering group to draw the layer in.
  52889. */
  52890. renderingGroupId: number;
  52891. }
  52892. /**
  52893. * The highlight layer Helps adding a glow effect around a mesh.
  52894. *
  52895. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52896. * glowy meshes to your scene.
  52897. *
  52898. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52899. */
  52900. export class HighlightLayer extends EffectLayer {
  52901. name: string;
  52902. /**
  52903. * Effect Name of the highlight layer.
  52904. */
  52905. static readonly EffectName: string;
  52906. /**
  52907. * The neutral color used during the preparation of the glow effect.
  52908. * This is black by default as the blend operation is a blend operation.
  52909. */
  52910. static NeutralColor: Color4;
  52911. /**
  52912. * Stencil value used for glowing meshes.
  52913. */
  52914. static GlowingMeshStencilReference: number;
  52915. /**
  52916. * Stencil value used for the other meshes in the scene.
  52917. */
  52918. static NormalMeshStencilReference: number;
  52919. /**
  52920. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52921. */
  52922. innerGlow: boolean;
  52923. /**
  52924. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52925. */
  52926. outerGlow: boolean;
  52927. /**
  52928. * Specifies the horizontal size of the blur.
  52929. */
  52930. /**
  52931. * Gets the horizontal size of the blur.
  52932. */
  52933. blurHorizontalSize: number;
  52934. /**
  52935. * Specifies the vertical size of the blur.
  52936. */
  52937. /**
  52938. * Gets the vertical size of the blur.
  52939. */
  52940. blurVerticalSize: number;
  52941. /**
  52942. * An event triggered when the highlight layer is being blurred.
  52943. */
  52944. onBeforeBlurObservable: Observable<HighlightLayer>;
  52945. /**
  52946. * An event triggered when the highlight layer has been blurred.
  52947. */
  52948. onAfterBlurObservable: Observable<HighlightLayer>;
  52949. private _instanceGlowingMeshStencilReference;
  52950. private _options;
  52951. private _downSamplePostprocess;
  52952. private _horizontalBlurPostprocess;
  52953. private _verticalBlurPostprocess;
  52954. private _blurTexture;
  52955. private _meshes;
  52956. private _excludedMeshes;
  52957. /**
  52958. * Instantiates a new highlight Layer and references it to the scene..
  52959. * @param name The name of the layer
  52960. * @param scene The scene to use the layer in
  52961. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52962. */
  52963. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52964. /**
  52965. * Get the effect name of the layer.
  52966. * @return The effect name
  52967. */
  52968. getEffectName(): string;
  52969. /**
  52970. * Create the merge effect. This is the shader use to blit the information back
  52971. * to the main canvas at the end of the scene rendering.
  52972. */
  52973. protected _createMergeEffect(): Effect;
  52974. /**
  52975. * Creates the render target textures and post processes used in the highlight layer.
  52976. */
  52977. protected _createTextureAndPostProcesses(): void;
  52978. /**
  52979. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52980. */
  52981. needStencil(): boolean;
  52982. /**
  52983. * Checks for the readiness of the element composing the layer.
  52984. * @param subMesh the mesh to check for
  52985. * @param useInstances specify wether or not to use instances to render the mesh
  52986. * @param emissiveTexture the associated emissive texture used to generate the glow
  52987. * @return true if ready otherwise, false
  52988. */
  52989. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52990. /**
  52991. * Implementation specific of rendering the generating effect on the main canvas.
  52992. * @param effect The effect used to render through
  52993. */
  52994. protected _internalRender(effect: Effect): void;
  52995. /**
  52996. * Returns true if the layer contains information to display, otherwise false.
  52997. */
  52998. shouldRender(): boolean;
  52999. /**
  53000. * Returns true if the mesh should render, otherwise false.
  53001. * @param mesh The mesh to render
  53002. * @returns true if it should render otherwise false
  53003. */
  53004. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53005. /**
  53006. * Sets the required values for both the emissive texture and and the main color.
  53007. */
  53008. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53009. /**
  53010. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53011. * @param mesh The mesh to exclude from the highlight layer
  53012. */
  53013. addExcludedMesh(mesh: Mesh): void;
  53014. /**
  53015. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53016. * @param mesh The mesh to highlight
  53017. */
  53018. removeExcludedMesh(mesh: Mesh): void;
  53019. /**
  53020. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53021. * @param mesh mesh to test
  53022. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53023. */
  53024. hasMesh(mesh: AbstractMesh): boolean;
  53025. /**
  53026. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53027. * @param mesh The mesh to highlight
  53028. * @param color The color of the highlight
  53029. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53030. */
  53031. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53032. /**
  53033. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53034. * @param mesh The mesh to highlight
  53035. */
  53036. removeMesh(mesh: Mesh): void;
  53037. /**
  53038. * Force the stencil to the normal expected value for none glowing parts
  53039. */
  53040. private _defaultStencilReference;
  53041. /**
  53042. * Free any resources and references associated to a mesh.
  53043. * Internal use
  53044. * @param mesh The mesh to free.
  53045. * @hidden
  53046. */
  53047. _disposeMesh(mesh: Mesh): void;
  53048. /**
  53049. * Dispose the highlight layer and free resources.
  53050. */
  53051. dispose(): void;
  53052. /**
  53053. * Gets the class name of the effect layer
  53054. * @returns the string with the class name of the effect layer
  53055. */
  53056. getClassName(): string;
  53057. /**
  53058. * Serializes this Highlight layer
  53059. * @returns a serialized Highlight layer object
  53060. */
  53061. serialize(): any;
  53062. /**
  53063. * Creates a Highlight layer from parsed Highlight layer data
  53064. * @param parsedHightlightLayer defines the Highlight layer data
  53065. * @param scene defines the current scene
  53066. * @param rootUrl defines the root URL containing the Highlight layer information
  53067. * @returns a parsed Highlight layer
  53068. */
  53069. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53070. }
  53071. }
  53072. declare module "babylonjs/Layers/layerSceneComponent" {
  53073. import { Scene } from "babylonjs/scene";
  53074. import { ISceneComponent } from "babylonjs/sceneComponent";
  53075. import { Layer } from "babylonjs/Layers/layer";
  53076. import { AbstractScene } from "babylonjs/abstractScene";
  53077. module "babylonjs/abstractScene" {
  53078. interface AbstractScene {
  53079. /**
  53080. * The list of layers (background and foreground) of the scene
  53081. */
  53082. layers: Array<Layer>;
  53083. }
  53084. }
  53085. /**
  53086. * Defines the layer scene component responsible to manage any layers
  53087. * in a given scene.
  53088. */
  53089. export class LayerSceneComponent implements ISceneComponent {
  53090. /**
  53091. * The component name helpfull to identify the component in the list of scene components.
  53092. */
  53093. readonly name: string;
  53094. /**
  53095. * The scene the component belongs to.
  53096. */
  53097. scene: Scene;
  53098. private _engine;
  53099. /**
  53100. * Creates a new instance of the component for the given scene
  53101. * @param scene Defines the scene to register the component in
  53102. */
  53103. constructor(scene: Scene);
  53104. /**
  53105. * Registers the component in a given scene
  53106. */
  53107. register(): void;
  53108. /**
  53109. * Rebuilds the elements related to this component in case of
  53110. * context lost for instance.
  53111. */
  53112. rebuild(): void;
  53113. /**
  53114. * Disposes the component and the associated ressources.
  53115. */
  53116. dispose(): void;
  53117. private _draw;
  53118. private _drawCameraPredicate;
  53119. private _drawCameraBackground;
  53120. private _drawCameraForeground;
  53121. private _drawRenderTargetPredicate;
  53122. private _drawRenderTargetBackground;
  53123. private _drawRenderTargetForeground;
  53124. /**
  53125. * Adds all the elements from the container to the scene
  53126. * @param container the container holding the elements
  53127. */
  53128. addFromContainer(container: AbstractScene): void;
  53129. /**
  53130. * Removes all the elements in the container from the scene
  53131. * @param container contains the elements to remove
  53132. * @param dispose if the removed element should be disposed (default: false)
  53133. */
  53134. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53135. }
  53136. }
  53137. declare module "babylonjs/Shaders/layer.fragment" {
  53138. /** @hidden */
  53139. export var layerPixelShader: {
  53140. name: string;
  53141. shader: string;
  53142. };
  53143. }
  53144. declare module "babylonjs/Shaders/layer.vertex" {
  53145. /** @hidden */
  53146. export var layerVertexShader: {
  53147. name: string;
  53148. shader: string;
  53149. };
  53150. }
  53151. declare module "babylonjs/Layers/layer" {
  53152. import { Observable } from "babylonjs/Misc/observable";
  53153. import { Nullable } from "babylonjs/types";
  53154. import { Scene } from "babylonjs/scene";
  53155. import { Vector2 } from "babylonjs/Maths/math.vector";
  53156. import { Color4 } from "babylonjs/Maths/math.color";
  53157. import { Texture } from "babylonjs/Materials/Textures/texture";
  53158. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53159. import "babylonjs/Shaders/layer.fragment";
  53160. import "babylonjs/Shaders/layer.vertex";
  53161. /**
  53162. * This represents a full screen 2d layer.
  53163. * This can be useful to display a picture in the background of your scene for instance.
  53164. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53165. */
  53166. export class Layer {
  53167. /**
  53168. * Define the name of the layer.
  53169. */
  53170. name: string;
  53171. /**
  53172. * Define the texture the layer should display.
  53173. */
  53174. texture: Nullable<Texture>;
  53175. /**
  53176. * Is the layer in background or foreground.
  53177. */
  53178. isBackground: boolean;
  53179. /**
  53180. * Define the color of the layer (instead of texture).
  53181. */
  53182. color: Color4;
  53183. /**
  53184. * Define the scale of the layer in order to zoom in out of the texture.
  53185. */
  53186. scale: Vector2;
  53187. /**
  53188. * Define an offset for the layer in order to shift the texture.
  53189. */
  53190. offset: Vector2;
  53191. /**
  53192. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53193. */
  53194. alphaBlendingMode: number;
  53195. /**
  53196. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53197. * Alpha test will not mix with the background color in case of transparency.
  53198. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53199. */
  53200. alphaTest: boolean;
  53201. /**
  53202. * Define a mask to restrict the layer to only some of the scene cameras.
  53203. */
  53204. layerMask: number;
  53205. /**
  53206. * Define the list of render target the layer is visible into.
  53207. */
  53208. renderTargetTextures: RenderTargetTexture[];
  53209. /**
  53210. * Define if the layer is only used in renderTarget or if it also
  53211. * renders in the main frame buffer of the canvas.
  53212. */
  53213. renderOnlyInRenderTargetTextures: boolean;
  53214. private _scene;
  53215. private _vertexBuffers;
  53216. private _indexBuffer;
  53217. private _effect;
  53218. private _alphaTestEffect;
  53219. /**
  53220. * An event triggered when the layer is disposed.
  53221. */
  53222. onDisposeObservable: Observable<Layer>;
  53223. private _onDisposeObserver;
  53224. /**
  53225. * Back compatibility with callback before the onDisposeObservable existed.
  53226. * The set callback will be triggered when the layer has been disposed.
  53227. */
  53228. onDispose: () => void;
  53229. /**
  53230. * An event triggered before rendering the scene
  53231. */
  53232. onBeforeRenderObservable: Observable<Layer>;
  53233. private _onBeforeRenderObserver;
  53234. /**
  53235. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53236. * The set callback will be triggered just before rendering the layer.
  53237. */
  53238. onBeforeRender: () => void;
  53239. /**
  53240. * An event triggered after rendering the scene
  53241. */
  53242. onAfterRenderObservable: Observable<Layer>;
  53243. private _onAfterRenderObserver;
  53244. /**
  53245. * Back compatibility with callback before the onAfterRenderObservable existed.
  53246. * The set callback will be triggered just after rendering the layer.
  53247. */
  53248. onAfterRender: () => void;
  53249. /**
  53250. * Instantiates a new layer.
  53251. * This represents a full screen 2d layer.
  53252. * This can be useful to display a picture in the background of your scene for instance.
  53253. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53254. * @param name Define the name of the layer in the scene
  53255. * @param imgUrl Define the url of the texture to display in the layer
  53256. * @param scene Define the scene the layer belongs to
  53257. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53258. * @param color Defines a color for the layer
  53259. */
  53260. constructor(
  53261. /**
  53262. * Define the name of the layer.
  53263. */
  53264. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53265. private _createIndexBuffer;
  53266. /** @hidden */
  53267. _rebuild(): void;
  53268. /**
  53269. * Renders the layer in the scene.
  53270. */
  53271. render(): void;
  53272. /**
  53273. * Disposes and releases the associated ressources.
  53274. */
  53275. dispose(): void;
  53276. }
  53277. }
  53278. declare module "babylonjs/Layers/index" {
  53279. export * from "babylonjs/Layers/effectLayer";
  53280. export * from "babylonjs/Layers/effectLayerSceneComponent";
  53281. export * from "babylonjs/Layers/glowLayer";
  53282. export * from "babylonjs/Layers/highlightLayer";
  53283. export * from "babylonjs/Layers/layer";
  53284. export * from "babylonjs/Layers/layerSceneComponent";
  53285. }
  53286. declare module "babylonjs/Shaders/lensFlare.fragment" {
  53287. /** @hidden */
  53288. export var lensFlarePixelShader: {
  53289. name: string;
  53290. shader: string;
  53291. };
  53292. }
  53293. declare module "babylonjs/Shaders/lensFlare.vertex" {
  53294. /** @hidden */
  53295. export var lensFlareVertexShader: {
  53296. name: string;
  53297. shader: string;
  53298. };
  53299. }
  53300. declare module "babylonjs/LensFlares/lensFlareSystem" {
  53301. import { Scene } from "babylonjs/scene";
  53302. import { Vector3 } from "babylonjs/Maths/math.vector";
  53303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53304. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  53305. import "babylonjs/Shaders/lensFlare.fragment";
  53306. import "babylonjs/Shaders/lensFlare.vertex";
  53307. import { Viewport } from "babylonjs/Maths/math.viewport";
  53308. /**
  53309. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53310. * It is usually composed of several `lensFlare`.
  53311. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53312. */
  53313. export class LensFlareSystem {
  53314. /**
  53315. * Define the name of the lens flare system
  53316. */
  53317. name: string;
  53318. /**
  53319. * List of lens flares used in this system.
  53320. */
  53321. lensFlares: LensFlare[];
  53322. /**
  53323. * Define a limit from the border the lens flare can be visible.
  53324. */
  53325. borderLimit: number;
  53326. /**
  53327. * Define a viewport border we do not want to see the lens flare in.
  53328. */
  53329. viewportBorder: number;
  53330. /**
  53331. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53332. */
  53333. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53334. /**
  53335. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53336. */
  53337. layerMask: number;
  53338. /**
  53339. * Define the id of the lens flare system in the scene.
  53340. * (equal to name by default)
  53341. */
  53342. id: string;
  53343. private _scene;
  53344. private _emitter;
  53345. private _vertexBuffers;
  53346. private _indexBuffer;
  53347. private _effect;
  53348. private _positionX;
  53349. private _positionY;
  53350. private _isEnabled;
  53351. /** @hidden */
  53352. static _SceneComponentInitialization: (scene: Scene) => void;
  53353. /**
  53354. * Instantiates a lens flare system.
  53355. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53356. * It is usually composed of several `lensFlare`.
  53357. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53358. * @param name Define the name of the lens flare system in the scene
  53359. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53360. * @param scene Define the scene the lens flare system belongs to
  53361. */
  53362. constructor(
  53363. /**
  53364. * Define the name of the lens flare system
  53365. */
  53366. name: string, emitter: any, scene: Scene);
  53367. /**
  53368. * Define if the lens flare system is enabled.
  53369. */
  53370. isEnabled: boolean;
  53371. /**
  53372. * Get the scene the effects belongs to.
  53373. * @returns the scene holding the lens flare system
  53374. */
  53375. getScene(): Scene;
  53376. /**
  53377. * Get the emitter of the lens flare system.
  53378. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53379. * @returns the emitter of the lens flare system
  53380. */
  53381. getEmitter(): any;
  53382. /**
  53383. * Set the emitter of the lens flare system.
  53384. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53385. * @param newEmitter Define the new emitter of the system
  53386. */
  53387. setEmitter(newEmitter: any): void;
  53388. /**
  53389. * Get the lens flare system emitter position.
  53390. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53391. * @returns the position
  53392. */
  53393. getEmitterPosition(): Vector3;
  53394. /**
  53395. * @hidden
  53396. */
  53397. computeEffectivePosition(globalViewport: Viewport): boolean;
  53398. /** @hidden */
  53399. _isVisible(): boolean;
  53400. /**
  53401. * @hidden
  53402. */
  53403. render(): boolean;
  53404. /**
  53405. * Dispose and release the lens flare with its associated resources.
  53406. */
  53407. dispose(): void;
  53408. /**
  53409. * Parse a lens flare system from a JSON repressentation
  53410. * @param parsedLensFlareSystem Define the JSON to parse
  53411. * @param scene Define the scene the parsed system should be instantiated in
  53412. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53413. * @returns the parsed system
  53414. */
  53415. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53416. /**
  53417. * Serialize the current Lens Flare System into a JSON representation.
  53418. * @returns the serialized JSON
  53419. */
  53420. serialize(): any;
  53421. }
  53422. }
  53423. declare module "babylonjs/LensFlares/lensFlare" {
  53424. import { Nullable } from "babylonjs/types";
  53425. import { Color3 } from "babylonjs/Maths/math.color";
  53426. import { Texture } from "babylonjs/Materials/Textures/texture";
  53427. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53428. /**
  53429. * This represents one of the lens effect in a `lensFlareSystem`.
  53430. * It controls one of the indiviual texture used in the effect.
  53431. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53432. */
  53433. export class LensFlare {
  53434. /**
  53435. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53436. */
  53437. size: number;
  53438. /**
  53439. * 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.
  53440. */
  53441. position: number;
  53442. /**
  53443. * Define the lens color.
  53444. */
  53445. color: Color3;
  53446. /**
  53447. * Define the lens texture.
  53448. */
  53449. texture: Nullable<Texture>;
  53450. /**
  53451. * Define the alpha mode to render this particular lens.
  53452. */
  53453. alphaMode: number;
  53454. private _system;
  53455. /**
  53456. * Creates a new Lens Flare.
  53457. * This represents one of the lens effect in a `lensFlareSystem`.
  53458. * It controls one of the indiviual texture used in the effect.
  53459. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53460. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53461. * @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.
  53462. * @param color Define the lens color
  53463. * @param imgUrl Define the lens texture url
  53464. * @param system Define the `lensFlareSystem` this flare is part of
  53465. * @returns The newly created Lens Flare
  53466. */
  53467. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53468. /**
  53469. * Instantiates a new Lens Flare.
  53470. * This represents one of the lens effect in a `lensFlareSystem`.
  53471. * It controls one of the indiviual texture used in the effect.
  53472. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53473. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53474. * @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.
  53475. * @param color Define the lens color
  53476. * @param imgUrl Define the lens texture url
  53477. * @param system Define the `lensFlareSystem` this flare is part of
  53478. */
  53479. constructor(
  53480. /**
  53481. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53482. */
  53483. size: number,
  53484. /**
  53485. * 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.
  53486. */
  53487. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53488. /**
  53489. * Dispose and release the lens flare with its associated resources.
  53490. */
  53491. dispose(): void;
  53492. }
  53493. }
  53494. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  53495. import { Nullable } from "babylonjs/types";
  53496. import { Scene } from "babylonjs/scene";
  53497. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53498. import { AbstractScene } from "babylonjs/abstractScene";
  53499. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53500. module "babylonjs/abstractScene" {
  53501. interface AbstractScene {
  53502. /**
  53503. * The list of lens flare system added to the scene
  53504. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53505. */
  53506. lensFlareSystems: Array<LensFlareSystem>;
  53507. /**
  53508. * Removes the given lens flare system from this scene.
  53509. * @param toRemove The lens flare system to remove
  53510. * @returns The index of the removed lens flare system
  53511. */
  53512. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53513. /**
  53514. * Adds the given lens flare system to this scene
  53515. * @param newLensFlareSystem The lens flare system to add
  53516. */
  53517. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53518. /**
  53519. * Gets a lens flare system using its name
  53520. * @param name defines the name to look for
  53521. * @returns the lens flare system or null if not found
  53522. */
  53523. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53524. /**
  53525. * Gets a lens flare system using its id
  53526. * @param id defines the id to look for
  53527. * @returns the lens flare system or null if not found
  53528. */
  53529. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53530. }
  53531. }
  53532. /**
  53533. * Defines the lens flare scene component responsible to manage any lens flares
  53534. * in a given scene.
  53535. */
  53536. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53537. /**
  53538. * The component name helpfull to identify the component in the list of scene components.
  53539. */
  53540. readonly name: string;
  53541. /**
  53542. * The scene the component belongs to.
  53543. */
  53544. scene: Scene;
  53545. /**
  53546. * Creates a new instance of the component for the given scene
  53547. * @param scene Defines the scene to register the component in
  53548. */
  53549. constructor(scene: Scene);
  53550. /**
  53551. * Registers the component in a given scene
  53552. */
  53553. register(): void;
  53554. /**
  53555. * Rebuilds the elements related to this component in case of
  53556. * context lost for instance.
  53557. */
  53558. rebuild(): void;
  53559. /**
  53560. * Adds all the elements from the container to the scene
  53561. * @param container the container holding the elements
  53562. */
  53563. addFromContainer(container: AbstractScene): void;
  53564. /**
  53565. * Removes all the elements in the container from the scene
  53566. * @param container contains the elements to remove
  53567. * @param dispose if the removed element should be disposed (default: false)
  53568. */
  53569. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53570. /**
  53571. * Serializes the component data to the specified json object
  53572. * @param serializationObject The object to serialize to
  53573. */
  53574. serialize(serializationObject: any): void;
  53575. /**
  53576. * Disposes the component and the associated ressources.
  53577. */
  53578. dispose(): void;
  53579. private _draw;
  53580. }
  53581. }
  53582. declare module "babylonjs/LensFlares/index" {
  53583. export * from "babylonjs/LensFlares/lensFlare";
  53584. export * from "babylonjs/LensFlares/lensFlareSystem";
  53585. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  53586. }
  53587. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  53588. import { Scene } from "babylonjs/scene";
  53589. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53590. import { AbstractScene } from "babylonjs/abstractScene";
  53591. /**
  53592. * Defines the shadow generator component responsible to manage any shadow generators
  53593. * in a given scene.
  53594. */
  53595. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53596. /**
  53597. * The component name helpfull to identify the component in the list of scene components.
  53598. */
  53599. readonly name: string;
  53600. /**
  53601. * The scene the component belongs to.
  53602. */
  53603. scene: Scene;
  53604. /**
  53605. * Creates a new instance of the component for the given scene
  53606. * @param scene Defines the scene to register the component in
  53607. */
  53608. constructor(scene: Scene);
  53609. /**
  53610. * Registers the component in a given scene
  53611. */
  53612. register(): void;
  53613. /**
  53614. * Rebuilds the elements related to this component in case of
  53615. * context lost for instance.
  53616. */
  53617. rebuild(): void;
  53618. /**
  53619. * Serializes the component data to the specified json object
  53620. * @param serializationObject The object to serialize to
  53621. */
  53622. serialize(serializationObject: any): void;
  53623. /**
  53624. * Adds all the elements from the container to the scene
  53625. * @param container the container holding the elements
  53626. */
  53627. addFromContainer(container: AbstractScene): void;
  53628. /**
  53629. * Removes all the elements in the container from the scene
  53630. * @param container contains the elements to remove
  53631. * @param dispose if the removed element should be disposed (default: false)
  53632. */
  53633. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53634. /**
  53635. * Rebuilds the elements related to this component in case of
  53636. * context lost for instance.
  53637. */
  53638. dispose(): void;
  53639. private _gatherRenderTargets;
  53640. }
  53641. }
  53642. declare module "babylonjs/Lights/Shadows/index" {
  53643. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  53644. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  53645. }
  53646. declare module "babylonjs/Lights/pointLight" {
  53647. import { Scene } from "babylonjs/scene";
  53648. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53650. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  53651. import { Effect } from "babylonjs/Materials/effect";
  53652. /**
  53653. * A point light is a light defined by an unique point in world space.
  53654. * The light is emitted in every direction from this point.
  53655. * A good example of a point light is a standard light bulb.
  53656. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53657. */
  53658. export class PointLight extends ShadowLight {
  53659. private _shadowAngle;
  53660. /**
  53661. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53662. * This specifies what angle the shadow will use to be created.
  53663. *
  53664. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53665. */
  53666. /**
  53667. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53668. * This specifies what angle the shadow will use to be created.
  53669. *
  53670. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53671. */
  53672. shadowAngle: number;
  53673. /**
  53674. * Gets the direction if it has been set.
  53675. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53676. */
  53677. /**
  53678. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53679. */
  53680. direction: Vector3;
  53681. /**
  53682. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53683. * A PointLight emits the light in every direction.
  53684. * It can cast shadows.
  53685. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53686. * ```javascript
  53687. * var pointLight = new PointLight("pl", camera.position, scene);
  53688. * ```
  53689. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53690. * @param name The light friendly name
  53691. * @param position The position of the point light in the scene
  53692. * @param scene The scene the lights belongs to
  53693. */
  53694. constructor(name: string, position: Vector3, scene: Scene);
  53695. /**
  53696. * Returns the string "PointLight"
  53697. * @returns the class name
  53698. */
  53699. getClassName(): string;
  53700. /**
  53701. * Returns the integer 0.
  53702. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53703. */
  53704. getTypeID(): number;
  53705. /**
  53706. * Specifies wether or not the shadowmap should be a cube texture.
  53707. * @returns true if the shadowmap needs to be a cube texture.
  53708. */
  53709. needCube(): boolean;
  53710. /**
  53711. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53712. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53713. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53714. */
  53715. getShadowDirection(faceIndex?: number): Vector3;
  53716. /**
  53717. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53718. * - fov = PI / 2
  53719. * - aspect ratio : 1.0
  53720. * - z-near and far equal to the active camera minZ and maxZ.
  53721. * Returns the PointLight.
  53722. */
  53723. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53724. protected _buildUniformLayout(): void;
  53725. /**
  53726. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53727. * @param effect The effect to update
  53728. * @param lightIndex The index of the light in the effect to update
  53729. * @returns The point light
  53730. */
  53731. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53732. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53733. /**
  53734. * Prepares the list of defines specific to the light type.
  53735. * @param defines the list of defines
  53736. * @param lightIndex defines the index of the light for the effect
  53737. */
  53738. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53739. }
  53740. }
  53741. declare module "babylonjs/Lights/index" {
  53742. export * from "babylonjs/Lights/light";
  53743. export * from "babylonjs/Lights/shadowLight";
  53744. export * from "babylonjs/Lights/Shadows/index";
  53745. export * from "babylonjs/Lights/directionalLight";
  53746. export * from "babylonjs/Lights/hemisphericLight";
  53747. export * from "babylonjs/Lights/pointLight";
  53748. export * from "babylonjs/Lights/spotLight";
  53749. }
  53750. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53751. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53752. /**
  53753. * Header information of HDR texture files.
  53754. */
  53755. export interface HDRInfo {
  53756. /**
  53757. * The height of the texture in pixels.
  53758. */
  53759. height: number;
  53760. /**
  53761. * The width of the texture in pixels.
  53762. */
  53763. width: number;
  53764. /**
  53765. * The index of the beginning of the data in the binary file.
  53766. */
  53767. dataPosition: number;
  53768. }
  53769. /**
  53770. * This groups tools to convert HDR texture to native colors array.
  53771. */
  53772. export class HDRTools {
  53773. private static Ldexp;
  53774. private static Rgbe2float;
  53775. private static readStringLine;
  53776. /**
  53777. * Reads header information from an RGBE texture stored in a native array.
  53778. * More information on this format are available here:
  53779. * https://en.wikipedia.org/wiki/RGBE_image_format
  53780. *
  53781. * @param uint8array The binary file stored in native array.
  53782. * @return The header information.
  53783. */
  53784. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53785. /**
  53786. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53787. * This RGBE texture needs to store the information as a panorama.
  53788. *
  53789. * More information on this format are available here:
  53790. * https://en.wikipedia.org/wiki/RGBE_image_format
  53791. *
  53792. * @param buffer The binary file stored in an array buffer.
  53793. * @param size The expected size of the extracted cubemap.
  53794. * @return The Cube Map information.
  53795. */
  53796. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53797. /**
  53798. * Returns the pixels data extracted from an RGBE texture.
  53799. * This pixels will be stored left to right up to down in the R G B order in one array.
  53800. *
  53801. * More information on this format are available here:
  53802. * https://en.wikipedia.org/wiki/RGBE_image_format
  53803. *
  53804. * @param uint8array The binary file stored in an array buffer.
  53805. * @param hdrInfo The header information of the file.
  53806. * @return The pixels data in RGB right to left up to down order.
  53807. */
  53808. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53809. private static RGBE_ReadPixels_RLE;
  53810. }
  53811. }
  53812. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53813. import { Nullable } from "babylonjs/types";
  53814. import { Scene } from "babylonjs/scene";
  53815. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53816. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53817. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53818. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53819. /**
  53820. * This represents a texture coming from an HDR input.
  53821. *
  53822. * The only supported format is currently panorama picture stored in RGBE format.
  53823. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53824. */
  53825. export class HDRCubeTexture extends BaseTexture {
  53826. private static _facesMapping;
  53827. private _generateHarmonics;
  53828. private _noMipmap;
  53829. private _textureMatrix;
  53830. private _size;
  53831. private _onLoad;
  53832. private _onError;
  53833. /**
  53834. * The texture URL.
  53835. */
  53836. url: string;
  53837. /**
  53838. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53839. */
  53840. coordinatesMode: number;
  53841. protected _isBlocking: boolean;
  53842. /**
  53843. * Sets wether or not the texture is blocking during loading.
  53844. */
  53845. /**
  53846. * Gets wether or not the texture is blocking during loading.
  53847. */
  53848. isBlocking: boolean;
  53849. protected _rotationY: number;
  53850. /**
  53851. * Sets texture matrix rotation angle around Y axis in radians.
  53852. */
  53853. /**
  53854. * Gets texture matrix rotation angle around Y axis radians.
  53855. */
  53856. rotationY: number;
  53857. /**
  53858. * Gets or sets the center of the bounding box associated with the cube texture
  53859. * It must define where the camera used to render the texture was set
  53860. */
  53861. boundingBoxPosition: Vector3;
  53862. private _boundingBoxSize;
  53863. /**
  53864. * Gets or sets the size of the bounding box associated with the cube texture
  53865. * When defined, the cubemap will switch to local mode
  53866. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53867. * @example https://www.babylonjs-playground.com/#RNASML
  53868. */
  53869. boundingBoxSize: Vector3;
  53870. /**
  53871. * Instantiates an HDRTexture from the following parameters.
  53872. *
  53873. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53874. * @param scene The scene the texture will be used in
  53875. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53876. * @param noMipmap Forces to not generate the mipmap if true
  53877. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53878. * @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)
  53879. * @param reserved Reserved flag for internal use.
  53880. */
  53881. 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>);
  53882. /**
  53883. * Get the current class name of the texture useful for serialization or dynamic coding.
  53884. * @returns "HDRCubeTexture"
  53885. */
  53886. getClassName(): string;
  53887. /**
  53888. * Occurs when the file is raw .hdr file.
  53889. */
  53890. private loadTexture;
  53891. clone(): HDRCubeTexture;
  53892. delayLoad(): void;
  53893. /**
  53894. * Get the texture reflection matrix used to rotate/transform the reflection.
  53895. * @returns the reflection matrix
  53896. */
  53897. getReflectionTextureMatrix(): Matrix;
  53898. /**
  53899. * Set the texture reflection matrix used to rotate/transform the reflection.
  53900. * @param value Define the reflection matrix to set
  53901. */
  53902. setReflectionTextureMatrix(value: Matrix): void;
  53903. /**
  53904. * Parses a JSON representation of an HDR Texture in order to create the texture
  53905. * @param parsedTexture Define the JSON representation
  53906. * @param scene Define the scene the texture should be created in
  53907. * @param rootUrl Define the root url in case we need to load relative dependencies
  53908. * @returns the newly created texture after parsing
  53909. */
  53910. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53911. serialize(): any;
  53912. }
  53913. }
  53914. declare module "babylonjs/Physics/physicsEngine" {
  53915. import { Nullable } from "babylonjs/types";
  53916. import { Vector3 } from "babylonjs/Maths/math.vector";
  53917. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53918. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53919. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53920. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53921. /**
  53922. * Class used to control physics engine
  53923. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53924. */
  53925. export class PhysicsEngine implements IPhysicsEngine {
  53926. private _physicsPlugin;
  53927. /**
  53928. * Global value used to control the smallest number supported by the simulation
  53929. */
  53930. static Epsilon: number;
  53931. private _impostors;
  53932. private _joints;
  53933. /**
  53934. * Gets the gravity vector used by the simulation
  53935. */
  53936. gravity: Vector3;
  53937. /**
  53938. * Factory used to create the default physics plugin.
  53939. * @returns The default physics plugin
  53940. */
  53941. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53942. /**
  53943. * Creates a new Physics Engine
  53944. * @param gravity defines the gravity vector used by the simulation
  53945. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53946. */
  53947. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53948. /**
  53949. * Sets the gravity vector used by the simulation
  53950. * @param gravity defines the gravity vector to use
  53951. */
  53952. setGravity(gravity: Vector3): void;
  53953. /**
  53954. * Set the time step of the physics engine.
  53955. * Default is 1/60.
  53956. * To slow it down, enter 1/600 for example.
  53957. * To speed it up, 1/30
  53958. * @param newTimeStep defines the new timestep to apply to this world.
  53959. */
  53960. setTimeStep(newTimeStep?: number): void;
  53961. /**
  53962. * Get the time step of the physics engine.
  53963. * @returns the current time step
  53964. */
  53965. getTimeStep(): number;
  53966. /**
  53967. * Release all resources
  53968. */
  53969. dispose(): void;
  53970. /**
  53971. * Gets the name of the current physics plugin
  53972. * @returns the name of the plugin
  53973. */
  53974. getPhysicsPluginName(): string;
  53975. /**
  53976. * Adding a new impostor for the impostor tracking.
  53977. * This will be done by the impostor itself.
  53978. * @param impostor the impostor to add
  53979. */
  53980. addImpostor(impostor: PhysicsImpostor): void;
  53981. /**
  53982. * Remove an impostor from the engine.
  53983. * This impostor and its mesh will not longer be updated by the physics engine.
  53984. * @param impostor the impostor to remove
  53985. */
  53986. removeImpostor(impostor: PhysicsImpostor): void;
  53987. /**
  53988. * Add a joint to the physics engine
  53989. * @param mainImpostor defines the main impostor to which the joint is added.
  53990. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53991. * @param joint defines the joint that will connect both impostors.
  53992. */
  53993. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53994. /**
  53995. * Removes a joint from the simulation
  53996. * @param mainImpostor defines the impostor used with the joint
  53997. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53998. * @param joint defines the joint to remove
  53999. */
  54000. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54001. /**
  54002. * Called by the scene. No need to call it.
  54003. * @param delta defines the timespam between frames
  54004. */
  54005. _step(delta: number): void;
  54006. /**
  54007. * Gets the current plugin used to run the simulation
  54008. * @returns current plugin
  54009. */
  54010. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54011. /**
  54012. * Gets the list of physic impostors
  54013. * @returns an array of PhysicsImpostor
  54014. */
  54015. getImpostors(): Array<PhysicsImpostor>;
  54016. /**
  54017. * Gets the impostor for a physics enabled object
  54018. * @param object defines the object impersonated by the impostor
  54019. * @returns the PhysicsImpostor or null if not found
  54020. */
  54021. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54022. /**
  54023. * Gets the impostor for a physics body object
  54024. * @param body defines physics body used by the impostor
  54025. * @returns the PhysicsImpostor or null if not found
  54026. */
  54027. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54028. /**
  54029. * Does a raycast in the physics world
  54030. * @param from when should the ray start?
  54031. * @param to when should the ray end?
  54032. * @returns PhysicsRaycastResult
  54033. */
  54034. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54035. }
  54036. }
  54037. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  54038. import { Nullable } from "babylonjs/types";
  54039. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54041. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54042. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54043. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54044. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54045. /** @hidden */
  54046. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54047. private _useDeltaForWorldStep;
  54048. world: any;
  54049. name: string;
  54050. private _physicsMaterials;
  54051. private _fixedTimeStep;
  54052. private _cannonRaycastResult;
  54053. private _raycastResult;
  54054. private _physicsBodysToRemoveAfterStep;
  54055. BJSCANNON: any;
  54056. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54057. setGravity(gravity: Vector3): void;
  54058. setTimeStep(timeStep: number): void;
  54059. getTimeStep(): number;
  54060. executeStep(delta: number): void;
  54061. private _removeMarkedPhysicsBodiesFromWorld;
  54062. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54063. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54064. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54065. private _processChildMeshes;
  54066. removePhysicsBody(impostor: PhysicsImpostor): void;
  54067. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54068. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54069. private _addMaterial;
  54070. private _checkWithEpsilon;
  54071. private _createShape;
  54072. private _createHeightmap;
  54073. private _minus90X;
  54074. private _plus90X;
  54075. private _tmpPosition;
  54076. private _tmpDeltaPosition;
  54077. private _tmpUnityRotation;
  54078. private _updatePhysicsBodyTransformation;
  54079. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54080. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54081. isSupported(): boolean;
  54082. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54083. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54084. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54085. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54086. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54087. getBodyMass(impostor: PhysicsImpostor): number;
  54088. getBodyFriction(impostor: PhysicsImpostor): number;
  54089. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54090. getBodyRestitution(impostor: PhysicsImpostor): number;
  54091. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54092. sleepBody(impostor: PhysicsImpostor): void;
  54093. wakeUpBody(impostor: PhysicsImpostor): void;
  54094. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54095. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54096. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54097. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54098. getRadius(impostor: PhysicsImpostor): number;
  54099. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54100. dispose(): void;
  54101. private _extendNamespace;
  54102. /**
  54103. * Does a raycast in the physics world
  54104. * @param from when should the ray start?
  54105. * @param to when should the ray end?
  54106. * @returns PhysicsRaycastResult
  54107. */
  54108. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54109. }
  54110. }
  54111. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  54112. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54113. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54114. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54116. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54117. import { Nullable } from "babylonjs/types";
  54118. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54119. /** @hidden */
  54120. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54121. world: any;
  54122. name: string;
  54123. BJSOIMO: any;
  54124. private _raycastResult;
  54125. constructor(iterations?: number, oimoInjection?: any);
  54126. setGravity(gravity: Vector3): void;
  54127. setTimeStep(timeStep: number): void;
  54128. getTimeStep(): number;
  54129. private _tmpImpostorsArray;
  54130. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54131. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54132. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54133. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54134. private _tmpPositionVector;
  54135. removePhysicsBody(impostor: PhysicsImpostor): void;
  54136. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54137. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54138. isSupported(): boolean;
  54139. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54140. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54141. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54142. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54143. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54144. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54145. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54146. getBodyMass(impostor: PhysicsImpostor): number;
  54147. getBodyFriction(impostor: PhysicsImpostor): number;
  54148. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54149. getBodyRestitution(impostor: PhysicsImpostor): number;
  54150. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54151. sleepBody(impostor: PhysicsImpostor): void;
  54152. wakeUpBody(impostor: PhysicsImpostor): void;
  54153. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54154. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54155. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54156. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54157. getRadius(impostor: PhysicsImpostor): number;
  54158. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54159. dispose(): void;
  54160. /**
  54161. * Does a raycast in the physics world
  54162. * @param from when should the ray start?
  54163. * @param to when should the ray end?
  54164. * @returns PhysicsRaycastResult
  54165. */
  54166. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54167. }
  54168. }
  54169. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  54170. import { Nullable } from "babylonjs/types";
  54171. import { Scene } from "babylonjs/scene";
  54172. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  54173. import { Color4 } from "babylonjs/Maths/math.color";
  54174. import { Mesh } from "babylonjs/Meshes/mesh";
  54175. /**
  54176. * Class containing static functions to help procedurally build meshes
  54177. */
  54178. export class RibbonBuilder {
  54179. /**
  54180. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54181. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54182. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54183. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54184. * * 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
  54185. * * 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
  54186. * * 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
  54187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54188. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54189. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54190. * * 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
  54191. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54192. * * 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
  54193. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54195. * @param name defines the name of the mesh
  54196. * @param options defines the options used to create the mesh
  54197. * @param scene defines the hosting scene
  54198. * @returns the ribbon mesh
  54199. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54200. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54201. */
  54202. static CreateRibbon(name: string, options: {
  54203. pathArray: Vector3[][];
  54204. closeArray?: boolean;
  54205. closePath?: boolean;
  54206. offset?: number;
  54207. updatable?: boolean;
  54208. sideOrientation?: number;
  54209. frontUVs?: Vector4;
  54210. backUVs?: Vector4;
  54211. instance?: Mesh;
  54212. invertUV?: boolean;
  54213. uvs?: Vector2[];
  54214. colors?: Color4[];
  54215. }, scene?: Nullable<Scene>): Mesh;
  54216. }
  54217. }
  54218. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  54219. import { Nullable } from "babylonjs/types";
  54220. import { Scene } from "babylonjs/scene";
  54221. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  54222. import { Mesh } from "babylonjs/Meshes/mesh";
  54223. /**
  54224. * Class containing static functions to help procedurally build meshes
  54225. */
  54226. export class ShapeBuilder {
  54227. /**
  54228. * 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.
  54229. * * 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.
  54230. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54231. * * 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.
  54232. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54233. * * 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
  54234. * * 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
  54235. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54237. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54238. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54240. * @param name defines the name of the mesh
  54241. * @param options defines the options used to create the mesh
  54242. * @param scene defines the hosting scene
  54243. * @returns the extruded shape mesh
  54244. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54245. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54246. */
  54247. static ExtrudeShape(name: string, options: {
  54248. shape: Vector3[];
  54249. path: Vector3[];
  54250. scale?: number;
  54251. rotation?: number;
  54252. cap?: number;
  54253. updatable?: boolean;
  54254. sideOrientation?: number;
  54255. frontUVs?: Vector4;
  54256. backUVs?: Vector4;
  54257. instance?: Mesh;
  54258. invertUV?: boolean;
  54259. }, scene?: Nullable<Scene>): Mesh;
  54260. /**
  54261. * Creates an custom extruded shape mesh.
  54262. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54263. * * 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.
  54264. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54265. * * 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
  54266. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54267. * * 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
  54268. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54269. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54270. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54271. * * 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
  54272. * * 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
  54273. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54275. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54276. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54278. * @param name defines the name of the mesh
  54279. * @param options defines the options used to create the mesh
  54280. * @param scene defines the hosting scene
  54281. * @returns the custom extruded shape mesh
  54282. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54283. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54284. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54285. */
  54286. static ExtrudeShapeCustom(name: string, options: {
  54287. shape: Vector3[];
  54288. path: Vector3[];
  54289. scaleFunction?: any;
  54290. rotationFunction?: any;
  54291. ribbonCloseArray?: boolean;
  54292. ribbonClosePath?: boolean;
  54293. cap?: number;
  54294. updatable?: boolean;
  54295. sideOrientation?: number;
  54296. frontUVs?: Vector4;
  54297. backUVs?: Vector4;
  54298. instance?: Mesh;
  54299. invertUV?: boolean;
  54300. }, scene?: Nullable<Scene>): Mesh;
  54301. private static _ExtrudeShapeGeneric;
  54302. }
  54303. }
  54304. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  54305. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  54306. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54307. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54308. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54309. import { Nullable } from "babylonjs/types";
  54310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54311. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54312. /**
  54313. * AmmoJS Physics plugin
  54314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  54315. * @see https://github.com/kripken/ammo.js/
  54316. */
  54317. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  54318. private _useDeltaForWorldStep;
  54319. /**
  54320. * Reference to the Ammo library
  54321. */
  54322. bjsAMMO: any;
  54323. /**
  54324. * Created ammoJS world which physics bodies are added to
  54325. */
  54326. world: any;
  54327. /**
  54328. * Name of the plugin
  54329. */
  54330. name: string;
  54331. private _timeStep;
  54332. private _fixedTimeStep;
  54333. private _maxSteps;
  54334. private _tmpQuaternion;
  54335. private _tmpAmmoTransform;
  54336. private _tmpAmmoQuaternion;
  54337. private _tmpAmmoConcreteContactResultCallback;
  54338. private _collisionConfiguration;
  54339. private _dispatcher;
  54340. private _overlappingPairCache;
  54341. private _solver;
  54342. private _softBodySolver;
  54343. private _tmpAmmoVectorA;
  54344. private _tmpAmmoVectorB;
  54345. private _tmpAmmoVectorC;
  54346. private _tmpAmmoVectorD;
  54347. private _tmpContactCallbackResult;
  54348. private _tmpAmmoVectorRCA;
  54349. private _tmpAmmoVectorRCB;
  54350. private _raycastResult;
  54351. private static readonly DISABLE_COLLISION_FLAG;
  54352. private static readonly KINEMATIC_FLAG;
  54353. private static readonly DISABLE_DEACTIVATION_FLAG;
  54354. /**
  54355. * Initializes the ammoJS plugin
  54356. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54357. * @param ammoInjection can be used to inject your own ammo reference
  54358. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54359. */
  54360. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54361. /**
  54362. * Sets the gravity of the physics world (m/(s^2))
  54363. * @param gravity Gravity to set
  54364. */
  54365. setGravity(gravity: Vector3): void;
  54366. /**
  54367. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54368. * @param timeStep timestep to use in seconds
  54369. */
  54370. setTimeStep(timeStep: number): void;
  54371. /**
  54372. * 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)
  54373. * @param fixedTimeStep fixedTimeStep to use in seconds
  54374. */
  54375. setFixedTimeStep(fixedTimeStep: number): void;
  54376. /**
  54377. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54378. * @param maxSteps the maximum number of steps by the physics engine per frame
  54379. */
  54380. setMaxSteps(maxSteps: number): void;
  54381. /**
  54382. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54383. * @returns the current timestep in seconds
  54384. */
  54385. getTimeStep(): number;
  54386. private _isImpostorInContact;
  54387. private _isImpostorPairInContact;
  54388. private _stepSimulation;
  54389. /**
  54390. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54391. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54392. * After the step the babylon meshes are set to the position of the physics imposters
  54393. * @param delta amount of time to step forward
  54394. * @param impostors array of imposters to update before/after the step
  54395. */
  54396. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54397. /**
  54398. * Update babylon mesh to match physics world object
  54399. * @param impostor imposter to match
  54400. */
  54401. private _afterSoftStep;
  54402. /**
  54403. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54404. * @param impostor imposter to match
  54405. */
  54406. private _ropeStep;
  54407. /**
  54408. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54409. * @param impostor imposter to match
  54410. */
  54411. private _softbodyOrClothStep;
  54412. private _tmpVector;
  54413. private _tmpMatrix;
  54414. /**
  54415. * Applies an impulse on the imposter
  54416. * @param impostor imposter to apply impulse to
  54417. * @param force amount of force to be applied to the imposter
  54418. * @param contactPoint the location to apply the impulse on the imposter
  54419. */
  54420. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54421. /**
  54422. * Applies a force on the imposter
  54423. * @param impostor imposter to apply force
  54424. * @param force amount of force to be applied to the imposter
  54425. * @param contactPoint the location to apply the force on the imposter
  54426. */
  54427. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54428. /**
  54429. * Creates a physics body using the plugin
  54430. * @param impostor the imposter to create the physics body on
  54431. */
  54432. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54433. /**
  54434. * Removes the physics body from the imposter and disposes of the body's memory
  54435. * @param impostor imposter to remove the physics body from
  54436. */
  54437. removePhysicsBody(impostor: PhysicsImpostor): void;
  54438. /**
  54439. * Generates a joint
  54440. * @param impostorJoint the imposter joint to create the joint with
  54441. */
  54442. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54443. /**
  54444. * Removes a joint
  54445. * @param impostorJoint the imposter joint to remove the joint from
  54446. */
  54447. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54448. private _addMeshVerts;
  54449. /**
  54450. * Initialise the soft body vertices to match its object's (mesh) vertices
  54451. * Softbody vertices (nodes) are in world space and to match this
  54452. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  54453. * @param impostor to create the softbody for
  54454. */
  54455. private _softVertexData;
  54456. /**
  54457. * Create an impostor's soft body
  54458. * @param impostor to create the softbody for
  54459. */
  54460. private _createSoftbody;
  54461. /**
  54462. * Create cloth for an impostor
  54463. * @param impostor to create the softbody for
  54464. */
  54465. private _createCloth;
  54466. /**
  54467. * Create rope for an impostor
  54468. * @param impostor to create the softbody for
  54469. */
  54470. private _createRope;
  54471. private _addHullVerts;
  54472. private _createShape;
  54473. /**
  54474. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  54475. * @param impostor imposter containing the physics body and babylon object
  54476. */
  54477. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54478. /**
  54479. * Sets the babylon object's position/rotation from the physics body's position/rotation
  54480. * @param impostor imposter containing the physics body and babylon object
  54481. * @param newPosition new position
  54482. * @param newRotation new rotation
  54483. */
  54484. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54485. /**
  54486. * If this plugin is supported
  54487. * @returns true if its supported
  54488. */
  54489. isSupported(): boolean;
  54490. /**
  54491. * Sets the linear velocity of the physics body
  54492. * @param impostor imposter to set the velocity on
  54493. * @param velocity velocity to set
  54494. */
  54495. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54496. /**
  54497. * Sets the angular velocity of the physics body
  54498. * @param impostor imposter to set the velocity on
  54499. * @param velocity velocity to set
  54500. */
  54501. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54502. /**
  54503. * gets the linear velocity
  54504. * @param impostor imposter to get linear velocity from
  54505. * @returns linear velocity
  54506. */
  54507. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54508. /**
  54509. * gets the angular velocity
  54510. * @param impostor imposter to get angular velocity from
  54511. * @returns angular velocity
  54512. */
  54513. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54514. /**
  54515. * Sets the mass of physics body
  54516. * @param impostor imposter to set the mass on
  54517. * @param mass mass to set
  54518. */
  54519. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54520. /**
  54521. * Gets the mass of the physics body
  54522. * @param impostor imposter to get the mass from
  54523. * @returns mass
  54524. */
  54525. getBodyMass(impostor: PhysicsImpostor): number;
  54526. /**
  54527. * Gets friction of the impostor
  54528. * @param impostor impostor to get friction from
  54529. * @returns friction value
  54530. */
  54531. getBodyFriction(impostor: PhysicsImpostor): number;
  54532. /**
  54533. * Sets friction of the impostor
  54534. * @param impostor impostor to set friction on
  54535. * @param friction friction value
  54536. */
  54537. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54538. /**
  54539. * Gets restitution of the impostor
  54540. * @param impostor impostor to get restitution from
  54541. * @returns restitution value
  54542. */
  54543. getBodyRestitution(impostor: PhysicsImpostor): number;
  54544. /**
  54545. * Sets resitution of the impostor
  54546. * @param impostor impostor to set resitution on
  54547. * @param restitution resitution value
  54548. */
  54549. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54550. /**
  54551. * Gets pressure inside the impostor
  54552. * @param impostor impostor to get pressure from
  54553. * @returns pressure value
  54554. */
  54555. getBodyPressure(impostor: PhysicsImpostor): number;
  54556. /**
  54557. * Sets pressure inside a soft body impostor
  54558. * Cloth and rope must remain 0 pressure
  54559. * @param impostor impostor to set pressure on
  54560. * @param pressure pressure value
  54561. */
  54562. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  54563. /**
  54564. * Gets stiffness of the impostor
  54565. * @param impostor impostor to get stiffness from
  54566. * @returns pressure value
  54567. */
  54568. getBodyStiffness(impostor: PhysicsImpostor): number;
  54569. /**
  54570. * Sets stiffness of the impostor
  54571. * @param impostor impostor to set stiffness on
  54572. * @param stiffness stiffness value from 0 to 1
  54573. */
  54574. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  54575. /**
  54576. * Gets velocityIterations of the impostor
  54577. * @param impostor impostor to get velocity iterations from
  54578. * @returns velocityIterations value
  54579. */
  54580. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  54581. /**
  54582. * Sets velocityIterations of the impostor
  54583. * @param impostor impostor to set velocity iterations on
  54584. * @param velocityIterations velocityIterations value
  54585. */
  54586. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  54587. /**
  54588. * Gets positionIterations of the impostor
  54589. * @param impostor impostor to get position iterations from
  54590. * @returns positionIterations value
  54591. */
  54592. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  54593. /**
  54594. * Sets positionIterations of the impostor
  54595. * @param impostor impostor to set position on
  54596. * @param positionIterations positionIterations value
  54597. */
  54598. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  54599. /**
  54600. * Append an anchor to a cloth object
  54601. * @param impostor is the cloth impostor to add anchor to
  54602. * @param otherImpostor is the rigid impostor to anchor to
  54603. * @param width ratio across width from 0 to 1
  54604. * @param height ratio up height from 0 to 1
  54605. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54606. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54607. */
  54608. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54609. /**
  54610. * Append an hook to a rope object
  54611. * @param impostor is the rope impostor to add hook to
  54612. * @param otherImpostor is the rigid impostor to hook to
  54613. * @param length ratio along the rope from 0 to 1
  54614. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  54615. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54616. */
  54617. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54618. /**
  54619. * Sleeps the physics body and stops it from being active
  54620. * @param impostor impostor to sleep
  54621. */
  54622. sleepBody(impostor: PhysicsImpostor): void;
  54623. /**
  54624. * Activates the physics body
  54625. * @param impostor impostor to activate
  54626. */
  54627. wakeUpBody(impostor: PhysicsImpostor): void;
  54628. /**
  54629. * Updates the distance parameters of the joint
  54630. * @param joint joint to update
  54631. * @param maxDistance maximum distance of the joint
  54632. * @param minDistance minimum distance of the joint
  54633. */
  54634. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54635. /**
  54636. * Sets a motor on the joint
  54637. * @param joint joint to set motor on
  54638. * @param speed speed of the motor
  54639. * @param maxForce maximum force of the motor
  54640. * @param motorIndex index of the motor
  54641. */
  54642. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54643. /**
  54644. * Sets the motors limit
  54645. * @param joint joint to set limit on
  54646. * @param upperLimit upper limit
  54647. * @param lowerLimit lower limit
  54648. */
  54649. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54650. /**
  54651. * Syncs the position and rotation of a mesh with the impostor
  54652. * @param mesh mesh to sync
  54653. * @param impostor impostor to update the mesh with
  54654. */
  54655. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54656. /**
  54657. * Gets the radius of the impostor
  54658. * @param impostor impostor to get radius from
  54659. * @returns the radius
  54660. */
  54661. getRadius(impostor: PhysicsImpostor): number;
  54662. /**
  54663. * Gets the box size of the impostor
  54664. * @param impostor impostor to get box size from
  54665. * @param result the resulting box size
  54666. */
  54667. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54668. /**
  54669. * Disposes of the impostor
  54670. */
  54671. dispose(): void;
  54672. /**
  54673. * Does a raycast in the physics world
  54674. * @param from when should the ray start?
  54675. * @param to when should the ray end?
  54676. * @returns PhysicsRaycastResult
  54677. */
  54678. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54679. }
  54680. }
  54681. declare module "babylonjs/Probes/reflectionProbe" {
  54682. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54683. import { Vector3 } from "babylonjs/Maths/math.vector";
  54684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54685. import { Nullable } from "babylonjs/types";
  54686. import { Scene } from "babylonjs/scene";
  54687. module "babylonjs/abstractScene" {
  54688. interface AbstractScene {
  54689. /**
  54690. * The list of reflection probes added to the scene
  54691. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54692. */
  54693. reflectionProbes: Array<ReflectionProbe>;
  54694. /**
  54695. * Removes the given reflection probe from this scene.
  54696. * @param toRemove The reflection probe to remove
  54697. * @returns The index of the removed reflection probe
  54698. */
  54699. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54700. /**
  54701. * Adds the given reflection probe to this scene.
  54702. * @param newReflectionProbe The reflection probe to add
  54703. */
  54704. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54705. }
  54706. }
  54707. /**
  54708. * Class used to generate realtime reflection / refraction cube textures
  54709. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54710. */
  54711. export class ReflectionProbe {
  54712. /** defines the name of the probe */
  54713. name: string;
  54714. private _scene;
  54715. private _renderTargetTexture;
  54716. private _projectionMatrix;
  54717. private _viewMatrix;
  54718. private _target;
  54719. private _add;
  54720. private _attachedMesh;
  54721. private _invertYAxis;
  54722. /** Gets or sets probe position (center of the cube map) */
  54723. position: Vector3;
  54724. /**
  54725. * Creates a new reflection probe
  54726. * @param name defines the name of the probe
  54727. * @param size defines the texture resolution (for each face)
  54728. * @param scene defines the hosting scene
  54729. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54730. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54731. */
  54732. constructor(
  54733. /** defines the name of the probe */
  54734. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54735. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54736. samples: number;
  54737. /** Gets or sets the refresh rate to use (on every frame by default) */
  54738. refreshRate: number;
  54739. /**
  54740. * Gets the hosting scene
  54741. * @returns a Scene
  54742. */
  54743. getScene(): Scene;
  54744. /** Gets the internal CubeTexture used to render to */
  54745. readonly cubeTexture: RenderTargetTexture;
  54746. /** Gets the list of meshes to render */
  54747. readonly renderList: Nullable<AbstractMesh[]>;
  54748. /**
  54749. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54750. * @param mesh defines the mesh to attach to
  54751. */
  54752. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54753. /**
  54754. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54755. * @param renderingGroupId The rendering group id corresponding to its index
  54756. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54757. */
  54758. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54759. /**
  54760. * Clean all associated resources
  54761. */
  54762. dispose(): void;
  54763. /**
  54764. * Converts the reflection probe information to a readable string for debug purpose.
  54765. * @param fullDetails Supports for multiple levels of logging within scene loading
  54766. * @returns the human readable reflection probe info
  54767. */
  54768. toString(fullDetails?: boolean): string;
  54769. /**
  54770. * Get the class name of the relfection probe.
  54771. * @returns "ReflectionProbe"
  54772. */
  54773. getClassName(): string;
  54774. /**
  54775. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54776. * @returns The JSON representation of the texture
  54777. */
  54778. serialize(): any;
  54779. /**
  54780. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54781. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54782. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54783. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54784. * @returns The parsed reflection probe if successful
  54785. */
  54786. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54787. }
  54788. }
  54789. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54790. /** @hidden */
  54791. export var _BabylonLoaderRegistered: boolean;
  54792. /**
  54793. * Helps setting up some configuration for the babylon file loader.
  54794. */
  54795. export class BabylonFileLoaderConfiguration {
  54796. /**
  54797. * The loader does not allow injecting custom physix engine into the plugins.
  54798. * Unfortunately in ES6, we need to manually inject them into the plugin.
  54799. * So you could set this variable to your engine import to make it work.
  54800. */
  54801. static LoaderInjectedPhysicsEngine: any;
  54802. }
  54803. }
  54804. declare module "babylonjs/Loading/Plugins/index" {
  54805. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54806. }
  54807. declare module "babylonjs/Loading/index" {
  54808. export * from "babylonjs/Loading/loadingScreen";
  54809. export * from "babylonjs/Loading/Plugins/index";
  54810. export * from "babylonjs/Loading/sceneLoader";
  54811. export * from "babylonjs/Loading/sceneLoaderFlags";
  54812. }
  54813. declare module "babylonjs/Materials/Background/index" {
  54814. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54815. }
  54816. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54817. import { Scene } from "babylonjs/scene";
  54818. import { Color3 } from "babylonjs/Maths/math.color";
  54819. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54820. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54821. /**
  54822. * The Physically based simple base material of BJS.
  54823. *
  54824. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54825. * It is used as the base class for both the specGloss and metalRough conventions.
  54826. */
  54827. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54828. /**
  54829. * Number of Simultaneous lights allowed on the material.
  54830. */
  54831. maxSimultaneousLights: number;
  54832. /**
  54833. * If sets to true, disables all the lights affecting the material.
  54834. */
  54835. disableLighting: boolean;
  54836. /**
  54837. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54838. */
  54839. environmentTexture: BaseTexture;
  54840. /**
  54841. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54842. */
  54843. invertNormalMapX: boolean;
  54844. /**
  54845. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54846. */
  54847. invertNormalMapY: boolean;
  54848. /**
  54849. * Normal map used in the model.
  54850. */
  54851. normalTexture: BaseTexture;
  54852. /**
  54853. * Emissivie color used to self-illuminate the model.
  54854. */
  54855. emissiveColor: Color3;
  54856. /**
  54857. * Emissivie texture used to self-illuminate the model.
  54858. */
  54859. emissiveTexture: BaseTexture;
  54860. /**
  54861. * Occlusion Channel Strenght.
  54862. */
  54863. occlusionStrength: number;
  54864. /**
  54865. * Occlusion Texture of the material (adding extra occlusion effects).
  54866. */
  54867. occlusionTexture: BaseTexture;
  54868. /**
  54869. * Defines the alpha limits in alpha test mode.
  54870. */
  54871. alphaCutOff: number;
  54872. /**
  54873. * Gets the current double sided mode.
  54874. */
  54875. /**
  54876. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54877. */
  54878. doubleSided: boolean;
  54879. /**
  54880. * Stores the pre-calculated light information of a mesh in a texture.
  54881. */
  54882. lightmapTexture: BaseTexture;
  54883. /**
  54884. * If true, the light map contains occlusion information instead of lighting info.
  54885. */
  54886. useLightmapAsShadowmap: boolean;
  54887. /**
  54888. * Instantiates a new PBRMaterial instance.
  54889. *
  54890. * @param name The material name
  54891. * @param scene The scene the material will be use in.
  54892. */
  54893. constructor(name: string, scene: Scene);
  54894. getClassName(): string;
  54895. }
  54896. }
  54897. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54898. import { Scene } from "babylonjs/scene";
  54899. import { Color3 } from "babylonjs/Maths/math.color";
  54900. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54901. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54902. /**
  54903. * The PBR material of BJS following the metal roughness convention.
  54904. *
  54905. * This fits to the PBR convention in the GLTF definition:
  54906. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54907. */
  54908. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54909. /**
  54910. * The base color has two different interpretations depending on the value of metalness.
  54911. * When the material is a metal, the base color is the specific measured reflectance value
  54912. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54913. * of the material.
  54914. */
  54915. baseColor: Color3;
  54916. /**
  54917. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54918. * well as opacity information in the alpha channel.
  54919. */
  54920. baseTexture: BaseTexture;
  54921. /**
  54922. * Specifies the metallic scalar value of the material.
  54923. * Can also be used to scale the metalness values of the metallic texture.
  54924. */
  54925. metallic: number;
  54926. /**
  54927. * Specifies the roughness scalar value of the material.
  54928. * Can also be used to scale the roughness values of the metallic texture.
  54929. */
  54930. roughness: number;
  54931. /**
  54932. * Texture containing both the metallic value in the B channel and the
  54933. * roughness value in the G channel to keep better precision.
  54934. */
  54935. metallicRoughnessTexture: BaseTexture;
  54936. /**
  54937. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54938. *
  54939. * @param name The material name
  54940. * @param scene The scene the material will be use in.
  54941. */
  54942. constructor(name: string, scene: Scene);
  54943. /**
  54944. * Return the currrent class name of the material.
  54945. */
  54946. getClassName(): string;
  54947. /**
  54948. * Makes a duplicate of the current material.
  54949. * @param name - name to use for the new material.
  54950. */
  54951. clone(name: string): PBRMetallicRoughnessMaterial;
  54952. /**
  54953. * Serialize the material to a parsable JSON object.
  54954. */
  54955. serialize(): any;
  54956. /**
  54957. * Parses a JSON object correponding to the serialize function.
  54958. */
  54959. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54960. }
  54961. }
  54962. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54963. import { Scene } from "babylonjs/scene";
  54964. import { Color3 } from "babylonjs/Maths/math.color";
  54965. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54966. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54967. /**
  54968. * The PBR material of BJS following the specular glossiness convention.
  54969. *
  54970. * This fits to the PBR convention in the GLTF definition:
  54971. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54972. */
  54973. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54974. /**
  54975. * Specifies the diffuse color of the material.
  54976. */
  54977. diffuseColor: Color3;
  54978. /**
  54979. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54980. * channel.
  54981. */
  54982. diffuseTexture: BaseTexture;
  54983. /**
  54984. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54985. */
  54986. specularColor: Color3;
  54987. /**
  54988. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54989. */
  54990. glossiness: number;
  54991. /**
  54992. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54993. */
  54994. specularGlossinessTexture: BaseTexture;
  54995. /**
  54996. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54997. *
  54998. * @param name The material name
  54999. * @param scene The scene the material will be use in.
  55000. */
  55001. constructor(name: string, scene: Scene);
  55002. /**
  55003. * Return the currrent class name of the material.
  55004. */
  55005. getClassName(): string;
  55006. /**
  55007. * Makes a duplicate of the current material.
  55008. * @param name - name to use for the new material.
  55009. */
  55010. clone(name: string): PBRSpecularGlossinessMaterial;
  55011. /**
  55012. * Serialize the material to a parsable JSON object.
  55013. */
  55014. serialize(): any;
  55015. /**
  55016. * Parses a JSON object correponding to the serialize function.
  55017. */
  55018. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55019. }
  55020. }
  55021. declare module "babylonjs/Materials/PBR/index" {
  55022. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55023. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55024. export * from "babylonjs/Materials/PBR/pbrMaterial";
  55025. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  55026. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  55027. }
  55028. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  55029. import { Nullable } from "babylonjs/types";
  55030. import { Scene } from "babylonjs/scene";
  55031. import { Matrix } from "babylonjs/Maths/math.vector";
  55032. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55033. /**
  55034. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55035. * It can help converting any input color in a desired output one. This can then be used to create effects
  55036. * from sepia, black and white to sixties or futuristic rendering...
  55037. *
  55038. * The only supported format is currently 3dl.
  55039. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55040. */
  55041. export class ColorGradingTexture extends BaseTexture {
  55042. /**
  55043. * The current texture matrix. (will always be identity in color grading texture)
  55044. */
  55045. private _textureMatrix;
  55046. /**
  55047. * The texture URL.
  55048. */
  55049. url: string;
  55050. /**
  55051. * Empty line regex stored for GC.
  55052. */
  55053. private static _noneEmptyLineRegex;
  55054. private _engine;
  55055. /**
  55056. * Instantiates a ColorGradingTexture from the following parameters.
  55057. *
  55058. * @param url The location of the color gradind data (currently only supporting 3dl)
  55059. * @param scene The scene the texture will be used in
  55060. */
  55061. constructor(url: string, scene: Scene);
  55062. /**
  55063. * Returns the texture matrix used in most of the material.
  55064. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55065. */
  55066. getTextureMatrix(): Matrix;
  55067. /**
  55068. * Occurs when the file being loaded is a .3dl LUT file.
  55069. */
  55070. private load3dlTexture;
  55071. /**
  55072. * Starts the loading process of the texture.
  55073. */
  55074. private loadTexture;
  55075. /**
  55076. * Clones the color gradind texture.
  55077. */
  55078. clone(): ColorGradingTexture;
  55079. /**
  55080. * Called during delayed load for textures.
  55081. */
  55082. delayLoad(): void;
  55083. /**
  55084. * Parses a color grading texture serialized by Babylon.
  55085. * @param parsedTexture The texture information being parsedTexture
  55086. * @param scene The scene to load the texture in
  55087. * @param rootUrl The root url of the data assets to load
  55088. * @return A color gradind texture
  55089. */
  55090. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55091. /**
  55092. * Serializes the LUT texture to json format.
  55093. */
  55094. serialize(): any;
  55095. }
  55096. }
  55097. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  55098. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55099. import { Scene } from "babylonjs/scene";
  55100. import { Nullable } from "babylonjs/types";
  55101. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55102. /**
  55103. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55104. */
  55105. export class EquiRectangularCubeTexture extends BaseTexture {
  55106. /** The six faces of the cube. */
  55107. private static _FacesMapping;
  55108. private _noMipmap;
  55109. private _onLoad;
  55110. private _onError;
  55111. /** The size of the cubemap. */
  55112. private _size;
  55113. /** The buffer of the image. */
  55114. private _buffer;
  55115. /** The width of the input image. */
  55116. private _width;
  55117. /** The height of the input image. */
  55118. private _height;
  55119. /** The URL to the image. */
  55120. url: string;
  55121. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55122. coordinatesMode: number;
  55123. /**
  55124. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55125. * @param url The location of the image
  55126. * @param scene The scene the texture will be used in
  55127. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55128. * @param noMipmap Forces to not generate the mipmap if true
  55129. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55130. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55131. * @param onLoad — defines a callback called when texture is loaded
  55132. * @param onError — defines a callback called if there is an error
  55133. */
  55134. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55135. /**
  55136. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55137. */
  55138. private loadImage;
  55139. /**
  55140. * Convert the image buffer into a cubemap and create a CubeTexture.
  55141. */
  55142. private loadTexture;
  55143. /**
  55144. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55145. * @param buffer The ArrayBuffer that should be converted.
  55146. * @returns The buffer as Float32Array.
  55147. */
  55148. private getFloat32ArrayFromArrayBuffer;
  55149. /**
  55150. * Get the current class name of the texture useful for serialization or dynamic coding.
  55151. * @returns "EquiRectangularCubeTexture"
  55152. */
  55153. getClassName(): string;
  55154. /**
  55155. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55156. * @returns A clone of the current EquiRectangularCubeTexture.
  55157. */
  55158. clone(): EquiRectangularCubeTexture;
  55159. }
  55160. }
  55161. declare module "babylonjs/Misc/tga" {
  55162. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55163. /**
  55164. * Based on jsTGALoader - Javascript loader for TGA file
  55165. * By Vincent Thibault
  55166. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55167. */
  55168. export class TGATools {
  55169. private static _TYPE_INDEXED;
  55170. private static _TYPE_RGB;
  55171. private static _TYPE_GREY;
  55172. private static _TYPE_RLE_INDEXED;
  55173. private static _TYPE_RLE_RGB;
  55174. private static _TYPE_RLE_GREY;
  55175. private static _ORIGIN_MASK;
  55176. private static _ORIGIN_SHIFT;
  55177. private static _ORIGIN_BL;
  55178. private static _ORIGIN_BR;
  55179. private static _ORIGIN_UL;
  55180. private static _ORIGIN_UR;
  55181. /**
  55182. * Gets the header of a TGA file
  55183. * @param data defines the TGA data
  55184. * @returns the header
  55185. */
  55186. static GetTGAHeader(data: Uint8Array): any;
  55187. /**
  55188. * Uploads TGA content to a Babylon Texture
  55189. * @hidden
  55190. */
  55191. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55192. /** @hidden */
  55193. 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;
  55194. /** @hidden */
  55195. 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;
  55196. /** @hidden */
  55197. 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;
  55198. /** @hidden */
  55199. 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;
  55200. /** @hidden */
  55201. 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;
  55202. /** @hidden */
  55203. 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;
  55204. }
  55205. }
  55206. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  55207. import { Nullable } from "babylonjs/types";
  55208. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55209. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55210. /**
  55211. * Implementation of the TGA Texture Loader.
  55212. * @hidden
  55213. */
  55214. export class _TGATextureLoader implements IInternalTextureLoader {
  55215. /**
  55216. * Defines wether the loader supports cascade loading the different faces.
  55217. */
  55218. readonly supportCascades: boolean;
  55219. /**
  55220. * This returns if the loader support the current file information.
  55221. * @param extension defines the file extension of the file being loaded
  55222. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55223. * @param fallback defines the fallback internal texture if any
  55224. * @param isBase64 defines whether the texture is encoded as a base64
  55225. * @param isBuffer defines whether the texture data are stored as a buffer
  55226. * @returns true if the loader can load the specified file
  55227. */
  55228. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55229. /**
  55230. * Transform the url before loading if required.
  55231. * @param rootUrl the url of the texture
  55232. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55233. * @returns the transformed texture
  55234. */
  55235. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55236. /**
  55237. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55238. * @param rootUrl the url of the texture
  55239. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55240. * @returns the fallback texture
  55241. */
  55242. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55243. /**
  55244. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55245. * @param data contains the texture data
  55246. * @param texture defines the BabylonJS internal texture
  55247. * @param createPolynomials will be true if polynomials have been requested
  55248. * @param onLoad defines the callback to trigger once the texture is ready
  55249. * @param onError defines the callback to trigger in case of error
  55250. */
  55251. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55252. /**
  55253. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55254. * @param data contains the texture data
  55255. * @param texture defines the BabylonJS internal texture
  55256. * @param callback defines the method to call once ready to upload
  55257. */
  55258. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55259. }
  55260. }
  55261. declare module "babylonjs/Misc/basis" {
  55262. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55263. /**
  55264. * Info about the .basis files
  55265. */
  55266. class BasisFileInfo {
  55267. /**
  55268. * If the file has alpha
  55269. */
  55270. hasAlpha: boolean;
  55271. /**
  55272. * Info about each image of the basis file
  55273. */
  55274. images: Array<{
  55275. levels: Array<{
  55276. width: number;
  55277. height: number;
  55278. transcodedPixels: ArrayBufferView;
  55279. }>;
  55280. }>;
  55281. }
  55282. /**
  55283. * Result of transcoding a basis file
  55284. */
  55285. class TranscodeResult {
  55286. /**
  55287. * Info about the .basis file
  55288. */
  55289. fileInfo: BasisFileInfo;
  55290. /**
  55291. * Format to use when loading the file
  55292. */
  55293. format: number;
  55294. }
  55295. /**
  55296. * Configuration options for the Basis transcoder
  55297. */
  55298. export class BasisTranscodeConfiguration {
  55299. /**
  55300. * Supported compression formats used to determine the supported output format of the transcoder
  55301. */
  55302. supportedCompressionFormats?: {
  55303. /**
  55304. * etc1 compression format
  55305. */
  55306. etc1?: boolean;
  55307. /**
  55308. * s3tc compression format
  55309. */
  55310. s3tc?: boolean;
  55311. /**
  55312. * pvrtc compression format
  55313. */
  55314. pvrtc?: boolean;
  55315. /**
  55316. * etc2 compression format
  55317. */
  55318. etc2?: boolean;
  55319. };
  55320. /**
  55321. * If mipmap levels should be loaded for transcoded images (Default: true)
  55322. */
  55323. loadMipmapLevels?: boolean;
  55324. /**
  55325. * Index of a single image to load (Default: all images)
  55326. */
  55327. loadSingleImage?: number;
  55328. }
  55329. /**
  55330. * Used to load .Basis files
  55331. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  55332. */
  55333. export class BasisTools {
  55334. private static _IgnoreSupportedFormats;
  55335. /**
  55336. * URL to use when loading the basis transcoder
  55337. */
  55338. static JSModuleURL: string;
  55339. /**
  55340. * URL to use when loading the wasm module for the transcoder
  55341. */
  55342. static WasmModuleURL: string;
  55343. /**
  55344. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55345. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55346. * @returns internal format corresponding to the Basis format
  55347. */
  55348. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55349. private static _WorkerPromise;
  55350. private static _Worker;
  55351. private static _actionId;
  55352. private static _CreateWorkerAsync;
  55353. /**
  55354. * Transcodes a loaded image file to compressed pixel data
  55355. * @param imageData image data to transcode
  55356. * @param config configuration options for the transcoding
  55357. * @returns a promise resulting in the transcoded image
  55358. */
  55359. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55360. /**
  55361. * Loads a texture from the transcode result
  55362. * @param texture texture load to
  55363. * @param transcodeResult the result of transcoding the basis file to load from
  55364. */
  55365. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55366. }
  55367. }
  55368. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  55369. import { Nullable } from "babylonjs/types";
  55370. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55371. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55372. /**
  55373. * Loader for .basis file format
  55374. */
  55375. export class _BasisTextureLoader implements IInternalTextureLoader {
  55376. /**
  55377. * Defines whether the loader supports cascade loading the different faces.
  55378. */
  55379. readonly supportCascades: boolean;
  55380. /**
  55381. * This returns if the loader support the current file information.
  55382. * @param extension defines the file extension of the file being loaded
  55383. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55384. * @param fallback defines the fallback internal texture if any
  55385. * @param isBase64 defines whether the texture is encoded as a base64
  55386. * @param isBuffer defines whether the texture data are stored as a buffer
  55387. * @returns true if the loader can load the specified file
  55388. */
  55389. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55390. /**
  55391. * Transform the url before loading if required.
  55392. * @param rootUrl the url of the texture
  55393. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55394. * @returns the transformed texture
  55395. */
  55396. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55397. /**
  55398. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55399. * @param rootUrl the url of the texture
  55400. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55401. * @returns the fallback texture
  55402. */
  55403. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55404. /**
  55405. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55406. * @param data contains the texture data
  55407. * @param texture defines the BabylonJS internal texture
  55408. * @param createPolynomials will be true if polynomials have been requested
  55409. * @param onLoad defines the callback to trigger once the texture is ready
  55410. * @param onError defines the callback to trigger in case of error
  55411. */
  55412. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55413. /**
  55414. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55415. * @param data contains the texture data
  55416. * @param texture defines the BabylonJS internal texture
  55417. * @param callback defines the method to call once ready to upload
  55418. */
  55419. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55420. }
  55421. }
  55422. declare module "babylonjs/Materials/Textures/Loaders/index" {
  55423. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55424. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55425. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55426. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  55427. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  55428. }
  55429. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  55430. import { Scene } from "babylonjs/scene";
  55431. import { Texture } from "babylonjs/Materials/Textures/texture";
  55432. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55433. /**
  55434. * 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.
  55435. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55436. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55437. */
  55438. export class CustomProceduralTexture extends ProceduralTexture {
  55439. private _animate;
  55440. private _time;
  55441. private _config;
  55442. private _texturePath;
  55443. /**
  55444. * Instantiates a new Custom Procedural Texture.
  55445. * 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.
  55446. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55447. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55448. * @param name Define the name of the texture
  55449. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55450. * @param size Define the size of the texture to create
  55451. * @param scene Define the scene the texture belongs to
  55452. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55453. * @param generateMipMaps Define if the texture should creates mip maps or not
  55454. */
  55455. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55456. private _loadJson;
  55457. /**
  55458. * Is the texture ready to be used ? (rendered at least once)
  55459. * @returns true if ready, otherwise, false.
  55460. */
  55461. isReady(): boolean;
  55462. /**
  55463. * Render the texture to its associated render target.
  55464. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55465. */
  55466. render(useCameraPostProcess?: boolean): void;
  55467. /**
  55468. * Update the list of dependant textures samplers in the shader.
  55469. */
  55470. updateTextures(): void;
  55471. /**
  55472. * Update the uniform values of the procedural texture in the shader.
  55473. */
  55474. updateShaderUniforms(): void;
  55475. /**
  55476. * Define if the texture animates or not.
  55477. */
  55478. animate: boolean;
  55479. }
  55480. }
  55481. declare module "babylonjs/Shaders/noise.fragment" {
  55482. /** @hidden */
  55483. export var noisePixelShader: {
  55484. name: string;
  55485. shader: string;
  55486. };
  55487. }
  55488. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  55489. import { Nullable } from "babylonjs/types";
  55490. import { Scene } from "babylonjs/scene";
  55491. import { Texture } from "babylonjs/Materials/Textures/texture";
  55492. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55493. import "babylonjs/Shaders/noise.fragment";
  55494. /**
  55495. * Class used to generate noise procedural textures
  55496. */
  55497. export class NoiseProceduralTexture extends ProceduralTexture {
  55498. private _time;
  55499. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55500. brightness: number;
  55501. /** Defines the number of octaves to process */
  55502. octaves: number;
  55503. /** Defines the level of persistence (0.8 by default) */
  55504. persistence: number;
  55505. /** Gets or sets animation speed factor (default is 1) */
  55506. animationSpeedFactor: number;
  55507. /**
  55508. * Creates a new NoiseProceduralTexture
  55509. * @param name defines the name fo the texture
  55510. * @param size defines the size of the texture (default is 256)
  55511. * @param scene defines the hosting scene
  55512. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55513. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55514. */
  55515. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55516. private _updateShaderUniforms;
  55517. protected _getDefines(): string;
  55518. /** Generate the current state of the procedural texture */
  55519. render(useCameraPostProcess?: boolean): void;
  55520. /**
  55521. * Serializes this noise procedural texture
  55522. * @returns a serialized noise procedural texture object
  55523. */
  55524. serialize(): any;
  55525. /**
  55526. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55527. * @param parsedTexture defines parsed texture data
  55528. * @param scene defines the current scene
  55529. * @param rootUrl defines the root URL containing noise procedural texture information
  55530. * @returns a parsed NoiseProceduralTexture
  55531. */
  55532. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  55533. }
  55534. }
  55535. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  55536. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  55537. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  55538. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55539. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  55540. }
  55541. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  55542. import { Nullable } from "babylonjs/types";
  55543. import { Scene } from "babylonjs/scene";
  55544. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55545. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55546. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55547. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55548. /**
  55549. * Raw cube texture where the raw buffers are passed in
  55550. */
  55551. export class RawCubeTexture extends CubeTexture {
  55552. /**
  55553. * Creates a cube texture where the raw buffers are passed in.
  55554. * @param scene defines the scene the texture is attached to
  55555. * @param data defines the array of data to use to create each face
  55556. * @param size defines the size of the textures
  55557. * @param format defines the format of the data
  55558. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  55559. * @param generateMipMaps defines if the engine should generate the mip levels
  55560. * @param invertY defines if data must be stored with Y axis inverted
  55561. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  55562. * @param compression defines the compression used (null by default)
  55563. */
  55564. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  55565. /**
  55566. * Updates the raw cube texture.
  55567. * @param data defines the data to store
  55568. * @param format defines the data format
  55569. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55570. * @param invertY defines if data must be stored with Y axis inverted
  55571. * @param compression defines the compression used (null by default)
  55572. * @param level defines which level of the texture to update
  55573. */
  55574. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  55575. /**
  55576. * Updates a raw cube texture with RGBD encoded data.
  55577. * @param data defines the array of data [mipmap][face] to use to create each face
  55578. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  55579. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55580. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55581. * @returns a promsie that resolves when the operation is complete
  55582. */
  55583. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  55584. /**
  55585. * Clones the raw cube texture.
  55586. * @return a new cube texture
  55587. */
  55588. clone(): CubeTexture;
  55589. /** @hidden */
  55590. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55591. }
  55592. }
  55593. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  55594. import { Scene } from "babylonjs/scene";
  55595. import { Texture } from "babylonjs/Materials/Textures/texture";
  55596. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55597. /**
  55598. * Class used to store 3D textures containing user data
  55599. */
  55600. export class RawTexture3D extends Texture {
  55601. /** Gets or sets the texture format to use */
  55602. format: number;
  55603. private _engine;
  55604. /**
  55605. * Create a new RawTexture3D
  55606. * @param data defines the data of the texture
  55607. * @param width defines the width of the texture
  55608. * @param height defines the height of the texture
  55609. * @param depth defines the depth of the texture
  55610. * @param format defines the texture format to use
  55611. * @param scene defines the hosting scene
  55612. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55613. * @param invertY defines if texture must be stored with Y axis inverted
  55614. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55615. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55616. */
  55617. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55618. /** Gets or sets the texture format to use */
  55619. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55620. /**
  55621. * Update the texture with new data
  55622. * @param data defines the data to store in the texture
  55623. */
  55624. update(data: ArrayBufferView): void;
  55625. }
  55626. }
  55627. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  55628. import { Scene } from "babylonjs/scene";
  55629. import { Texture } from "babylonjs/Materials/Textures/texture";
  55630. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55631. /**
  55632. * Class used to store 2D array textures containing user data
  55633. */
  55634. export class RawTexture2DArray extends Texture {
  55635. /** Gets or sets the texture format to use */
  55636. format: number;
  55637. private _engine;
  55638. /**
  55639. * Create a new RawTexture2DArray
  55640. * @param data defines the data of the texture
  55641. * @param width defines the width of the texture
  55642. * @param height defines the height of the texture
  55643. * @param depth defines the number of layers of the texture
  55644. * @param format defines the texture format to use
  55645. * @param scene defines the hosting scene
  55646. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55647. * @param invertY defines if texture must be stored with Y axis inverted
  55648. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55649. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55650. */
  55651. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55652. /** Gets or sets the texture format to use */
  55653. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55654. /**
  55655. * Update the texture with new data
  55656. * @param data defines the data to store in the texture
  55657. */
  55658. update(data: ArrayBufferView): void;
  55659. }
  55660. }
  55661. declare module "babylonjs/Materials/Textures/refractionTexture" {
  55662. import { Scene } from "babylonjs/scene";
  55663. import { Plane } from "babylonjs/Maths/math.plane";
  55664. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55665. /**
  55666. * Creates a refraction texture used by refraction channel of the standard material.
  55667. * It is like a mirror but to see through a material.
  55668. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55669. */
  55670. export class RefractionTexture extends RenderTargetTexture {
  55671. /**
  55672. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  55673. * 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.
  55674. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55675. */
  55676. refractionPlane: Plane;
  55677. /**
  55678. * Define how deep under the surface we should see.
  55679. */
  55680. depth: number;
  55681. /**
  55682. * Creates a refraction texture used by refraction channel of the standard material.
  55683. * It is like a mirror but to see through a material.
  55684. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55685. * @param name Define the texture name
  55686. * @param size Define the size of the underlying texture
  55687. * @param scene Define the scene the refraction belongs to
  55688. * @param generateMipMaps Define if we need to generate mips level for the refraction
  55689. */
  55690. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  55691. /**
  55692. * Clone the refraction texture.
  55693. * @returns the cloned texture
  55694. */
  55695. clone(): RefractionTexture;
  55696. /**
  55697. * Serialize the texture to a JSON representation you could use in Parse later on
  55698. * @returns the serialized JSON representation
  55699. */
  55700. serialize(): any;
  55701. }
  55702. }
  55703. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  55704. import { Nullable } from "babylonjs/types";
  55705. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55706. import { Matrix } from "babylonjs/Maths/math.vector";
  55707. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55708. import "babylonjs/Engines/Extensions/engine.videoTexture";
  55709. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55710. import { Scene } from "babylonjs/scene";
  55711. /**
  55712. * Defines the options related to the creation of an HtmlElementTexture
  55713. */
  55714. export interface IHtmlElementTextureOptions {
  55715. /**
  55716. * Defines wether mip maps should be created or not.
  55717. */
  55718. generateMipMaps?: boolean;
  55719. /**
  55720. * Defines the sampling mode of the texture.
  55721. */
  55722. samplingMode?: number;
  55723. /**
  55724. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  55725. */
  55726. engine: Nullable<ThinEngine>;
  55727. /**
  55728. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  55729. */
  55730. scene: Nullable<Scene>;
  55731. }
  55732. /**
  55733. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  55734. * To be as efficient as possible depending on your constraints nothing aside the first upload
  55735. * is automatically managed.
  55736. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  55737. * in your application.
  55738. *
  55739. * As the update is not automatic, you need to call them manually.
  55740. */
  55741. export class HtmlElementTexture extends BaseTexture {
  55742. /**
  55743. * The texture URL.
  55744. */
  55745. element: HTMLVideoElement | HTMLCanvasElement;
  55746. private static readonly DefaultOptions;
  55747. private _textureMatrix;
  55748. private _engine;
  55749. private _isVideo;
  55750. private _generateMipMaps;
  55751. private _samplingMode;
  55752. /**
  55753. * Instantiates a HtmlElementTexture from the following parameters.
  55754. *
  55755. * @param name Defines the name of the texture
  55756. * @param element Defines the video or canvas the texture is filled with
  55757. * @param options Defines the other none mandatory texture creation options
  55758. */
  55759. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55760. private _createInternalTexture;
  55761. /**
  55762. * Returns the texture matrix used in most of the material.
  55763. */
  55764. getTextureMatrix(): Matrix;
  55765. /**
  55766. * Updates the content of the texture.
  55767. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55768. */
  55769. update(invertY?: Nullable<boolean>): void;
  55770. }
  55771. }
  55772. declare module "babylonjs/Materials/Textures/index" {
  55773. export * from "babylonjs/Materials/Textures/baseTexture";
  55774. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  55775. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  55776. export * from "babylonjs/Materials/Textures/cubeTexture";
  55777. export * from "babylonjs/Materials/Textures/dynamicTexture";
  55778. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  55779. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  55780. export * from "babylonjs/Materials/Textures/internalTexture";
  55781. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  55782. export * from "babylonjs/Materials/Textures/Loaders/index";
  55783. export * from "babylonjs/Materials/Textures/mirrorTexture";
  55784. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  55785. export * from "babylonjs/Materials/Textures/Procedurals/index";
  55786. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  55787. export * from "babylonjs/Materials/Textures/rawTexture";
  55788. export * from "babylonjs/Materials/Textures/rawTexture3D";
  55789. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  55790. export * from "babylonjs/Materials/Textures/refractionTexture";
  55791. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  55792. export * from "babylonjs/Materials/Textures/texture";
  55793. export * from "babylonjs/Materials/Textures/videoTexture";
  55794. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55795. }
  55796. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55797. /**
  55798. * Enum used to define the target of a block
  55799. */
  55800. export enum NodeMaterialBlockTargets {
  55801. /** Vertex shader */
  55802. Vertex = 1,
  55803. /** Fragment shader */
  55804. Fragment = 2,
  55805. /** Neutral */
  55806. Neutral = 4,
  55807. /** Vertex and Fragment */
  55808. VertexAndFragment = 3
  55809. }
  55810. }
  55811. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55812. /**
  55813. * Defines the kind of connection point for node based material
  55814. */
  55815. export enum NodeMaterialBlockConnectionPointTypes {
  55816. /** Float */
  55817. Float = 1,
  55818. /** Int */
  55819. Int = 2,
  55820. /** Vector2 */
  55821. Vector2 = 4,
  55822. /** Vector3 */
  55823. Vector3 = 8,
  55824. /** Vector4 */
  55825. Vector4 = 16,
  55826. /** Color3 */
  55827. Color3 = 32,
  55828. /** Color4 */
  55829. Color4 = 64,
  55830. /** Matrix */
  55831. Matrix = 128,
  55832. /** Detect type based on connection */
  55833. AutoDetect = 1024,
  55834. /** Output type that will be defined by input type */
  55835. BasedOnInput = 2048
  55836. }
  55837. }
  55838. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55839. /**
  55840. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55841. */
  55842. export enum NodeMaterialBlockConnectionPointMode {
  55843. /** Value is an uniform */
  55844. Uniform = 0,
  55845. /** Value is a mesh attribute */
  55846. Attribute = 1,
  55847. /** Value is a varying between vertex and fragment shaders */
  55848. Varying = 2,
  55849. /** Mode is undefined */
  55850. Undefined = 3
  55851. }
  55852. }
  55853. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55854. /**
  55855. * Enum used to define system values e.g. values automatically provided by the system
  55856. */
  55857. export enum NodeMaterialSystemValues {
  55858. /** World */
  55859. World = 1,
  55860. /** View */
  55861. View = 2,
  55862. /** Projection */
  55863. Projection = 3,
  55864. /** ViewProjection */
  55865. ViewProjection = 4,
  55866. /** WorldView */
  55867. WorldView = 5,
  55868. /** WorldViewProjection */
  55869. WorldViewProjection = 6,
  55870. /** CameraPosition */
  55871. CameraPosition = 7,
  55872. /** Fog Color */
  55873. FogColor = 8,
  55874. /** Delta time */
  55875. DeltaTime = 9
  55876. }
  55877. }
  55878. declare module "babylonjs/Materials/Node/Enums/index" {
  55879. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55880. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55881. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55882. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55883. }
  55884. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55885. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55886. /**
  55887. * Root class for all node material optimizers
  55888. */
  55889. export class NodeMaterialOptimizer {
  55890. /**
  55891. * Function used to optimize a NodeMaterial graph
  55892. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55893. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55894. */
  55895. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55896. }
  55897. }
  55898. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55899. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55900. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55901. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55902. import { Scene } from "babylonjs/scene";
  55903. /**
  55904. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55905. */
  55906. export class TransformBlock extends NodeMaterialBlock {
  55907. /**
  55908. * Defines the value to use to complement W value to transform it to a Vector4
  55909. */
  55910. complementW: number;
  55911. /**
  55912. * Defines the value to use to complement z value to transform it to a Vector4
  55913. */
  55914. complementZ: number;
  55915. /**
  55916. * Creates a new TransformBlock
  55917. * @param name defines the block name
  55918. */
  55919. constructor(name: string);
  55920. /**
  55921. * Gets the current class name
  55922. * @returns the class name
  55923. */
  55924. getClassName(): string;
  55925. /**
  55926. * Gets the vector input
  55927. */
  55928. readonly vector: NodeMaterialConnectionPoint;
  55929. /**
  55930. * Gets the output component
  55931. */
  55932. readonly output: NodeMaterialConnectionPoint;
  55933. /**
  55934. * Gets the matrix transform input
  55935. */
  55936. readonly transform: NodeMaterialConnectionPoint;
  55937. protected _buildBlock(state: NodeMaterialBuildState): this;
  55938. serialize(): any;
  55939. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55940. protected _dumpPropertiesCode(): string;
  55941. }
  55942. }
  55943. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55944. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55945. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55946. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55947. /**
  55948. * Block used to output the vertex position
  55949. */
  55950. export class VertexOutputBlock extends NodeMaterialBlock {
  55951. /**
  55952. * Creates a new VertexOutputBlock
  55953. * @param name defines the block name
  55954. */
  55955. constructor(name: string);
  55956. /**
  55957. * Gets the current class name
  55958. * @returns the class name
  55959. */
  55960. getClassName(): string;
  55961. /**
  55962. * Gets the vector input component
  55963. */
  55964. readonly vector: NodeMaterialConnectionPoint;
  55965. protected _buildBlock(state: NodeMaterialBuildState): this;
  55966. }
  55967. }
  55968. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55969. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55970. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55971. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55972. /**
  55973. * Block used to output the final color
  55974. */
  55975. export class FragmentOutputBlock extends NodeMaterialBlock {
  55976. /**
  55977. * Create a new FragmentOutputBlock
  55978. * @param name defines the block name
  55979. */
  55980. constructor(name: string);
  55981. /**
  55982. * Gets the current class name
  55983. * @returns the class name
  55984. */
  55985. getClassName(): string;
  55986. /**
  55987. * Gets the rgba input component
  55988. */
  55989. readonly rgba: NodeMaterialConnectionPoint;
  55990. /**
  55991. * Gets the rgb input component
  55992. */
  55993. readonly rgb: NodeMaterialConnectionPoint;
  55994. /**
  55995. * Gets the a input component
  55996. */
  55997. readonly a: NodeMaterialConnectionPoint;
  55998. protected _buildBlock(state: NodeMaterialBuildState): this;
  55999. }
  56000. }
  56001. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  56002. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56003. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56004. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56005. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56007. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56008. import { Effect } from "babylonjs/Materials/effect";
  56009. import { Mesh } from "babylonjs/Meshes/mesh";
  56010. import { Nullable } from "babylonjs/types";
  56011. import { Scene } from "babylonjs/scene";
  56012. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56013. /**
  56014. * Block used to read a reflection texture from a sampler
  56015. */
  56016. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56017. private _define3DName;
  56018. private _defineCubicName;
  56019. private _defineExplicitName;
  56020. private _defineProjectionName;
  56021. private _defineLocalCubicName;
  56022. private _defineSphericalName;
  56023. private _definePlanarName;
  56024. private _defineEquirectangularName;
  56025. private _defineMirroredEquirectangularFixedName;
  56026. private _defineEquirectangularFixedName;
  56027. private _defineSkyboxName;
  56028. private _cubeSamplerName;
  56029. private _2DSamplerName;
  56030. private _positionUVWName;
  56031. private _directionWName;
  56032. private _reflectionCoordsName;
  56033. private _reflection2DCoordsName;
  56034. private _reflectionColorName;
  56035. private _reflectionMatrixName;
  56036. /**
  56037. * Gets or sets the texture associated with the node
  56038. */
  56039. texture: Nullable<BaseTexture>;
  56040. /**
  56041. * Create a new TextureBlock
  56042. * @param name defines the block name
  56043. */
  56044. constructor(name: string);
  56045. /**
  56046. * Gets the current class name
  56047. * @returns the class name
  56048. */
  56049. getClassName(): string;
  56050. /**
  56051. * Gets the world position input component
  56052. */
  56053. readonly position: NodeMaterialConnectionPoint;
  56054. /**
  56055. * Gets the world position input component
  56056. */
  56057. readonly worldPosition: NodeMaterialConnectionPoint;
  56058. /**
  56059. * Gets the world normal input component
  56060. */
  56061. readonly worldNormal: NodeMaterialConnectionPoint;
  56062. /**
  56063. * Gets the world input component
  56064. */
  56065. readonly world: NodeMaterialConnectionPoint;
  56066. /**
  56067. * Gets the camera (or eye) position component
  56068. */
  56069. readonly cameraPosition: NodeMaterialConnectionPoint;
  56070. /**
  56071. * Gets the view input component
  56072. */
  56073. readonly view: NodeMaterialConnectionPoint;
  56074. /**
  56075. * Gets the rgb output component
  56076. */
  56077. readonly rgb: NodeMaterialConnectionPoint;
  56078. /**
  56079. * Gets the r output component
  56080. */
  56081. readonly r: NodeMaterialConnectionPoint;
  56082. /**
  56083. * Gets the g output component
  56084. */
  56085. readonly g: NodeMaterialConnectionPoint;
  56086. /**
  56087. * Gets the b output component
  56088. */
  56089. readonly b: NodeMaterialConnectionPoint;
  56090. autoConfigure(material: NodeMaterial): void;
  56091. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56092. isReady(): boolean;
  56093. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56094. private _injectVertexCode;
  56095. private _writeOutput;
  56096. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56097. protected _dumpPropertiesCode(): string;
  56098. serialize(): any;
  56099. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56100. }
  56101. }
  56102. declare module "babylonjs/Materials/Node/nodeMaterial" {
  56103. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56104. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56105. import { Scene } from "babylonjs/scene";
  56106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56107. import { Matrix } from "babylonjs/Maths/math.vector";
  56108. import { Mesh } from "babylonjs/Meshes/mesh";
  56109. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56110. import { Observable } from "babylonjs/Misc/observable";
  56111. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56112. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  56113. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56114. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  56115. import { Nullable } from "babylonjs/types";
  56116. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56117. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56118. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56119. /**
  56120. * Interface used to configure the node material editor
  56121. */
  56122. export interface INodeMaterialEditorOptions {
  56123. /** Define the URl to load node editor script */
  56124. editorURL?: string;
  56125. }
  56126. /** @hidden */
  56127. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56128. /** BONES */
  56129. NUM_BONE_INFLUENCERS: number;
  56130. BonesPerMesh: number;
  56131. BONETEXTURE: boolean;
  56132. /** MORPH TARGETS */
  56133. MORPHTARGETS: boolean;
  56134. MORPHTARGETS_NORMAL: boolean;
  56135. MORPHTARGETS_TANGENT: boolean;
  56136. MORPHTARGETS_UV: boolean;
  56137. NUM_MORPH_INFLUENCERS: number;
  56138. /** IMAGE PROCESSING */
  56139. IMAGEPROCESSING: boolean;
  56140. VIGNETTE: boolean;
  56141. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56142. VIGNETTEBLENDMODEOPAQUE: boolean;
  56143. TONEMAPPING: boolean;
  56144. TONEMAPPING_ACES: boolean;
  56145. CONTRAST: boolean;
  56146. EXPOSURE: boolean;
  56147. COLORCURVES: boolean;
  56148. COLORGRADING: boolean;
  56149. COLORGRADING3D: boolean;
  56150. SAMPLER3DGREENDEPTH: boolean;
  56151. SAMPLER3DBGRMAP: boolean;
  56152. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56153. /** MISC. */
  56154. BUMPDIRECTUV: number;
  56155. constructor();
  56156. setValue(name: string, value: boolean): void;
  56157. }
  56158. /**
  56159. * Class used to configure NodeMaterial
  56160. */
  56161. export interface INodeMaterialOptions {
  56162. /**
  56163. * Defines if blocks should emit comments
  56164. */
  56165. emitComments: boolean;
  56166. }
  56167. /**
  56168. * Class used to create a node based material built by assembling shader blocks
  56169. */
  56170. export class NodeMaterial extends PushMaterial {
  56171. private static _BuildIdGenerator;
  56172. private _options;
  56173. private _vertexCompilationState;
  56174. private _fragmentCompilationState;
  56175. private _sharedData;
  56176. private _buildId;
  56177. private _buildWasSuccessful;
  56178. private _cachedWorldViewMatrix;
  56179. private _cachedWorldViewProjectionMatrix;
  56180. private _optimizers;
  56181. private _animationFrame;
  56182. /** Define the URl to load node editor script */
  56183. static EditorURL: string;
  56184. private BJSNODEMATERIALEDITOR;
  56185. /** Get the inspector from bundle or global */
  56186. private _getGlobalNodeMaterialEditor;
  56187. /**
  56188. * Gets or sets data used by visual editor
  56189. * @see https://nme.babylonjs.com
  56190. */
  56191. editorData: any;
  56192. /**
  56193. * 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)
  56194. */
  56195. ignoreAlpha: boolean;
  56196. /**
  56197. * Defines the maximum number of lights that can be used in the material
  56198. */
  56199. maxSimultaneousLights: number;
  56200. /**
  56201. * Observable raised when the material is built
  56202. */
  56203. onBuildObservable: Observable<NodeMaterial>;
  56204. /**
  56205. * Gets or sets the root nodes of the material vertex shader
  56206. */
  56207. _vertexOutputNodes: NodeMaterialBlock[];
  56208. /**
  56209. * Gets or sets the root nodes of the material fragment (pixel) shader
  56210. */
  56211. _fragmentOutputNodes: NodeMaterialBlock[];
  56212. /** Gets or sets options to control the node material overall behavior */
  56213. options: INodeMaterialOptions;
  56214. /**
  56215. * Default configuration related to image processing available in the standard Material.
  56216. */
  56217. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56218. /**
  56219. * Gets the image processing configuration used either in this material.
  56220. */
  56221. /**
  56222. * Sets the Default image processing configuration used either in the this material.
  56223. *
  56224. * If sets to null, the scene one is in use.
  56225. */
  56226. imageProcessingConfiguration: ImageProcessingConfiguration;
  56227. /**
  56228. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  56229. */
  56230. attachedBlocks: NodeMaterialBlock[];
  56231. /**
  56232. * Create a new node based material
  56233. * @param name defines the material name
  56234. * @param scene defines the hosting scene
  56235. * @param options defines creation option
  56236. */
  56237. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  56238. /**
  56239. * Gets the current class name of the material e.g. "NodeMaterial"
  56240. * @returns the class name
  56241. */
  56242. getClassName(): string;
  56243. /**
  56244. * Keep track of the image processing observer to allow dispose and replace.
  56245. */
  56246. private _imageProcessingObserver;
  56247. /**
  56248. * Attaches a new image processing configuration to the Standard Material.
  56249. * @param configuration
  56250. */
  56251. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56252. /**
  56253. * Get a block by its name
  56254. * @param name defines the name of the block to retrieve
  56255. * @returns the required block or null if not found
  56256. */
  56257. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  56258. /**
  56259. * Get a block by its name
  56260. * @param predicate defines the predicate used to find the good candidate
  56261. * @returns the required block or null if not found
  56262. */
  56263. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  56264. /**
  56265. * Get an input block by its name
  56266. * @param predicate defines the predicate used to find the good candidate
  56267. * @returns the required input block or null if not found
  56268. */
  56269. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  56270. /**
  56271. * Gets the list of input blocks attached to this material
  56272. * @returns an array of InputBlocks
  56273. */
  56274. getInputBlocks(): InputBlock[];
  56275. /**
  56276. * Adds a new optimizer to the list of optimizers
  56277. * @param optimizer defines the optimizers to add
  56278. * @returns the current material
  56279. */
  56280. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56281. /**
  56282. * Remove an optimizer from the list of optimizers
  56283. * @param optimizer defines the optimizers to remove
  56284. * @returns the current material
  56285. */
  56286. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56287. /**
  56288. * Add a new block to the list of output nodes
  56289. * @param node defines the node to add
  56290. * @returns the current material
  56291. */
  56292. addOutputNode(node: NodeMaterialBlock): this;
  56293. /**
  56294. * Remove a block from the list of root nodes
  56295. * @param node defines the node to remove
  56296. * @returns the current material
  56297. */
  56298. removeOutputNode(node: NodeMaterialBlock): this;
  56299. private _addVertexOutputNode;
  56300. private _removeVertexOutputNode;
  56301. private _addFragmentOutputNode;
  56302. private _removeFragmentOutputNode;
  56303. /**
  56304. * Specifies if the material will require alpha blending
  56305. * @returns a boolean specifying if alpha blending is needed
  56306. */
  56307. needAlphaBlending(): boolean;
  56308. /**
  56309. * Specifies if this material should be rendered in alpha test mode
  56310. * @returns a boolean specifying if an alpha test is needed.
  56311. */
  56312. needAlphaTesting(): boolean;
  56313. private _initializeBlock;
  56314. private _resetDualBlocks;
  56315. /**
  56316. * Build the material and generates the inner effect
  56317. * @param verbose defines if the build should log activity
  56318. */
  56319. build(verbose?: boolean): void;
  56320. /**
  56321. * Runs an otpimization phase to try to improve the shader code
  56322. */
  56323. optimize(): void;
  56324. private _prepareDefinesForAttributes;
  56325. /**
  56326. * Get if the submesh is ready to be used and all its information available.
  56327. * Child classes can use it to update shaders
  56328. * @param mesh defines the mesh to check
  56329. * @param subMesh defines which submesh to check
  56330. * @param useInstances specifies that instances should be used
  56331. * @returns a boolean indicating that the submesh is ready or not
  56332. */
  56333. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56334. /**
  56335. * Get a string representing the shaders built by the current node graph
  56336. */
  56337. readonly compiledShaders: string;
  56338. /**
  56339. * Binds the world matrix to the material
  56340. * @param world defines the world transformation matrix
  56341. */
  56342. bindOnlyWorldMatrix(world: Matrix): void;
  56343. /**
  56344. * Binds the submesh to this material by preparing the effect and shader to draw
  56345. * @param world defines the world transformation matrix
  56346. * @param mesh defines the mesh containing the submesh
  56347. * @param subMesh defines the submesh to bind the material to
  56348. */
  56349. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56350. /**
  56351. * Gets the active textures from the material
  56352. * @returns an array of textures
  56353. */
  56354. getActiveTextures(): BaseTexture[];
  56355. /**
  56356. * Gets the list of texture blocks
  56357. * @returns an array of texture blocks
  56358. */
  56359. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56360. /**
  56361. * Specifies if the material uses a texture
  56362. * @param texture defines the texture to check against the material
  56363. * @returns a boolean specifying if the material uses the texture
  56364. */
  56365. hasTexture(texture: BaseTexture): boolean;
  56366. /**
  56367. * Disposes the material
  56368. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56369. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56370. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56371. */
  56372. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56373. /** Creates the node editor window. */
  56374. private _createNodeEditor;
  56375. /**
  56376. * Launch the node material editor
  56377. * @param config Define the configuration of the editor
  56378. * @return a promise fulfilled when the node editor is visible
  56379. */
  56380. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56381. /**
  56382. * Clear the current material
  56383. */
  56384. clear(): void;
  56385. /**
  56386. * Clear the current material and set it to a default state
  56387. */
  56388. setToDefault(): void;
  56389. /**
  56390. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56391. * @param url defines the url to load from
  56392. * @returns a promise that will fullfil when the material is fully loaded
  56393. */
  56394. loadAsync(url: string): Promise<void>;
  56395. private _gatherBlocks;
  56396. /**
  56397. * Generate a string containing the code declaration required to create an equivalent of this material
  56398. * @returns a string
  56399. */
  56400. generateCode(): string;
  56401. /**
  56402. * Serializes this material in a JSON representation
  56403. * @returns the serialized material object
  56404. */
  56405. serialize(): any;
  56406. private _restoreConnections;
  56407. /**
  56408. * Clear the current graph and load a new one from a serialization object
  56409. * @param source defines the JSON representation of the material
  56410. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56411. */
  56412. loadFromSerialization(source: any, rootUrl?: string): void;
  56413. /**
  56414. * Creates a node material from parsed material data
  56415. * @param source defines the JSON representation of the material
  56416. * @param scene defines the hosting scene
  56417. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56418. * @returns a new node material
  56419. */
  56420. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56421. /**
  56422. * Creates a new node material set to default basic configuration
  56423. * @param name defines the name of the material
  56424. * @param scene defines the hosting scene
  56425. * @returns a new NodeMaterial
  56426. */
  56427. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  56428. }
  56429. }
  56430. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  56431. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56432. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56433. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56434. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56435. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56436. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56437. import { Effect } from "babylonjs/Materials/effect";
  56438. import { Mesh } from "babylonjs/Meshes/mesh";
  56439. import { Nullable } from "babylonjs/types";
  56440. import { Texture } from "babylonjs/Materials/Textures/texture";
  56441. import { Scene } from "babylonjs/scene";
  56442. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56443. /**
  56444. * Block used to read a texture from a sampler
  56445. */
  56446. export class TextureBlock extends NodeMaterialBlock {
  56447. private _defineName;
  56448. private _linearDefineName;
  56449. private _tempTextureRead;
  56450. private _samplerName;
  56451. private _transformedUVName;
  56452. private _textureTransformName;
  56453. private _textureInfoName;
  56454. private _mainUVName;
  56455. private _mainUVDefineName;
  56456. /**
  56457. * Gets or sets the texture associated with the node
  56458. */
  56459. texture: Nullable<Texture>;
  56460. /**
  56461. * Create a new TextureBlock
  56462. * @param name defines the block name
  56463. */
  56464. constructor(name: string);
  56465. /**
  56466. * Gets the current class name
  56467. * @returns the class name
  56468. */
  56469. getClassName(): string;
  56470. /**
  56471. * Gets the uv input component
  56472. */
  56473. readonly uv: NodeMaterialConnectionPoint;
  56474. /**
  56475. * Gets the rgba output component
  56476. */
  56477. readonly rgba: NodeMaterialConnectionPoint;
  56478. /**
  56479. * Gets the rgb output component
  56480. */
  56481. readonly rgb: NodeMaterialConnectionPoint;
  56482. /**
  56483. * Gets the r output component
  56484. */
  56485. readonly r: NodeMaterialConnectionPoint;
  56486. /**
  56487. * Gets the g output component
  56488. */
  56489. readonly g: NodeMaterialConnectionPoint;
  56490. /**
  56491. * Gets the b output component
  56492. */
  56493. readonly b: NodeMaterialConnectionPoint;
  56494. /**
  56495. * Gets the a output component
  56496. */
  56497. readonly a: NodeMaterialConnectionPoint;
  56498. readonly target: NodeMaterialBlockTargets;
  56499. autoConfigure(material: NodeMaterial): void;
  56500. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56501. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56502. isReady(): boolean;
  56503. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56504. private readonly _isMixed;
  56505. private _injectVertexCode;
  56506. private _writeTextureRead;
  56507. private _writeOutput;
  56508. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56509. protected _dumpPropertiesCode(): string;
  56510. serialize(): any;
  56511. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56512. }
  56513. }
  56514. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  56515. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56516. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56517. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56518. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56519. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56520. import { Scene } from "babylonjs/scene";
  56521. /**
  56522. * Class used to store shared data between 2 NodeMaterialBuildState
  56523. */
  56524. export class NodeMaterialBuildStateSharedData {
  56525. /**
  56526. * Gets the list of emitted varyings
  56527. */
  56528. temps: string[];
  56529. /**
  56530. * Gets the list of emitted varyings
  56531. */
  56532. varyings: string[];
  56533. /**
  56534. * Gets the varying declaration string
  56535. */
  56536. varyingDeclaration: string;
  56537. /**
  56538. * Input blocks
  56539. */
  56540. inputBlocks: InputBlock[];
  56541. /**
  56542. * Input blocks
  56543. */
  56544. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  56545. /**
  56546. * Bindable blocks (Blocks that need to set data to the effect)
  56547. */
  56548. bindableBlocks: NodeMaterialBlock[];
  56549. /**
  56550. * List of blocks that can provide a compilation fallback
  56551. */
  56552. blocksWithFallbacks: NodeMaterialBlock[];
  56553. /**
  56554. * List of blocks that can provide a define update
  56555. */
  56556. blocksWithDefines: NodeMaterialBlock[];
  56557. /**
  56558. * List of blocks that can provide a repeatable content
  56559. */
  56560. repeatableContentBlocks: NodeMaterialBlock[];
  56561. /**
  56562. * List of blocks that can provide a dynamic list of uniforms
  56563. */
  56564. dynamicUniformBlocks: NodeMaterialBlock[];
  56565. /**
  56566. * List of blocks that can block the isReady function for the material
  56567. */
  56568. blockingBlocks: NodeMaterialBlock[];
  56569. /**
  56570. * Gets the list of animated inputs
  56571. */
  56572. animatedInputs: InputBlock[];
  56573. /**
  56574. * Build Id used to avoid multiple recompilations
  56575. */
  56576. buildId: number;
  56577. /** List of emitted variables */
  56578. variableNames: {
  56579. [key: string]: number;
  56580. };
  56581. /** List of emitted defines */
  56582. defineNames: {
  56583. [key: string]: number;
  56584. };
  56585. /** Should emit comments? */
  56586. emitComments: boolean;
  56587. /** Emit build activity */
  56588. verbose: boolean;
  56589. /** Gets or sets the hosting scene */
  56590. scene: Scene;
  56591. /**
  56592. * Gets the compilation hints emitted at compilation time
  56593. */
  56594. hints: {
  56595. needWorldViewMatrix: boolean;
  56596. needWorldViewProjectionMatrix: boolean;
  56597. needAlphaBlending: boolean;
  56598. needAlphaTesting: boolean;
  56599. };
  56600. /**
  56601. * List of compilation checks
  56602. */
  56603. checks: {
  56604. emitVertex: boolean;
  56605. emitFragment: boolean;
  56606. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  56607. };
  56608. /** Creates a new shared data */
  56609. constructor();
  56610. /**
  56611. * Emits console errors and exceptions if there is a failing check
  56612. */
  56613. emitErrors(): void;
  56614. }
  56615. }
  56616. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  56617. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56618. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56619. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  56620. /**
  56621. * Class used to store node based material build state
  56622. */
  56623. export class NodeMaterialBuildState {
  56624. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  56625. supportUniformBuffers: boolean;
  56626. /**
  56627. * Gets the list of emitted attributes
  56628. */
  56629. attributes: string[];
  56630. /**
  56631. * Gets the list of emitted uniforms
  56632. */
  56633. uniforms: string[];
  56634. /**
  56635. * Gets the list of emitted constants
  56636. */
  56637. constants: string[];
  56638. /**
  56639. * Gets the list of emitted samplers
  56640. */
  56641. samplers: string[];
  56642. /**
  56643. * Gets the list of emitted functions
  56644. */
  56645. functions: {
  56646. [key: string]: string;
  56647. };
  56648. /**
  56649. * Gets the list of emitted extensions
  56650. */
  56651. extensions: {
  56652. [key: string]: string;
  56653. };
  56654. /**
  56655. * Gets the target of the compilation state
  56656. */
  56657. target: NodeMaterialBlockTargets;
  56658. /**
  56659. * Gets the list of emitted counters
  56660. */
  56661. counters: {
  56662. [key: string]: number;
  56663. };
  56664. /**
  56665. * Shared data between multiple NodeMaterialBuildState instances
  56666. */
  56667. sharedData: NodeMaterialBuildStateSharedData;
  56668. /** @hidden */
  56669. _vertexState: NodeMaterialBuildState;
  56670. /** @hidden */
  56671. _attributeDeclaration: string;
  56672. /** @hidden */
  56673. _uniformDeclaration: string;
  56674. /** @hidden */
  56675. _constantDeclaration: string;
  56676. /** @hidden */
  56677. _samplerDeclaration: string;
  56678. /** @hidden */
  56679. _varyingTransfer: string;
  56680. private _repeatableContentAnchorIndex;
  56681. /** @hidden */
  56682. _builtCompilationString: string;
  56683. /**
  56684. * Gets the emitted compilation strings
  56685. */
  56686. compilationString: string;
  56687. /**
  56688. * Finalize the compilation strings
  56689. * @param state defines the current compilation state
  56690. */
  56691. finalize(state: NodeMaterialBuildState): void;
  56692. /** @hidden */
  56693. readonly _repeatableContentAnchor: string;
  56694. /** @hidden */
  56695. _getFreeVariableName(prefix: string): string;
  56696. /** @hidden */
  56697. _getFreeDefineName(prefix: string): string;
  56698. /** @hidden */
  56699. _excludeVariableName(name: string): void;
  56700. /** @hidden */
  56701. _emit2DSampler(name: string): void;
  56702. /** @hidden */
  56703. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  56704. /** @hidden */
  56705. _emitExtension(name: string, extension: string): void;
  56706. /** @hidden */
  56707. _emitFunction(name: string, code: string, comments: string): void;
  56708. /** @hidden */
  56709. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  56710. replaceStrings?: {
  56711. search: RegExp;
  56712. replace: string;
  56713. }[];
  56714. repeatKey?: string;
  56715. }): string;
  56716. /** @hidden */
  56717. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  56718. repeatKey?: string;
  56719. removeAttributes?: boolean;
  56720. removeUniforms?: boolean;
  56721. removeVaryings?: boolean;
  56722. removeIfDef?: boolean;
  56723. replaceStrings?: {
  56724. search: RegExp;
  56725. replace: string;
  56726. }[];
  56727. }, storeKey?: string): void;
  56728. /** @hidden */
  56729. _registerTempVariable(name: string): boolean;
  56730. /** @hidden */
  56731. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  56732. /** @hidden */
  56733. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  56734. /** @hidden */
  56735. _emitFloat(value: number): string;
  56736. }
  56737. }
  56738. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  56739. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56740. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56741. import { Nullable } from "babylonjs/types";
  56742. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56743. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56744. import { Effect } from "babylonjs/Materials/effect";
  56745. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56746. import { Mesh } from "babylonjs/Meshes/mesh";
  56747. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56748. import { Scene } from "babylonjs/scene";
  56749. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56750. /**
  56751. * Defines a block that can be used inside a node based material
  56752. */
  56753. export class NodeMaterialBlock {
  56754. private _buildId;
  56755. private _buildTarget;
  56756. private _target;
  56757. private _isFinalMerger;
  56758. private _isInput;
  56759. protected _isUnique: boolean;
  56760. /** @hidden */
  56761. _codeVariableName: string;
  56762. /** @hidden */
  56763. _inputs: NodeMaterialConnectionPoint[];
  56764. /** @hidden */
  56765. _outputs: NodeMaterialConnectionPoint[];
  56766. /** @hidden */
  56767. _preparationId: number;
  56768. /**
  56769. * Gets or sets the name of the block
  56770. */
  56771. name: string;
  56772. /**
  56773. * Gets or sets the unique id of the node
  56774. */
  56775. uniqueId: number;
  56776. /**
  56777. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  56778. */
  56779. readonly isUnique: boolean;
  56780. /**
  56781. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  56782. */
  56783. readonly isFinalMerger: boolean;
  56784. /**
  56785. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  56786. */
  56787. readonly isInput: boolean;
  56788. /**
  56789. * Gets or sets the build Id
  56790. */
  56791. buildId: number;
  56792. /**
  56793. * Gets or sets the target of the block
  56794. */
  56795. target: NodeMaterialBlockTargets;
  56796. /**
  56797. * Gets the list of input points
  56798. */
  56799. readonly inputs: NodeMaterialConnectionPoint[];
  56800. /** Gets the list of output points */
  56801. readonly outputs: NodeMaterialConnectionPoint[];
  56802. /**
  56803. * Find an input by its name
  56804. * @param name defines the name of the input to look for
  56805. * @returns the input or null if not found
  56806. */
  56807. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56808. /**
  56809. * Find an output by its name
  56810. * @param name defines the name of the outputto look for
  56811. * @returns the output or null if not found
  56812. */
  56813. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56814. /**
  56815. * Creates a new NodeMaterialBlock
  56816. * @param name defines the block name
  56817. * @param target defines the target of that block (Vertex by default)
  56818. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56819. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56820. */
  56821. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56822. /**
  56823. * Initialize the block and prepare the context for build
  56824. * @param state defines the state that will be used for the build
  56825. */
  56826. initialize(state: NodeMaterialBuildState): void;
  56827. /**
  56828. * Bind data to effect. Will only be called for blocks with isBindable === true
  56829. * @param effect defines the effect to bind data to
  56830. * @param nodeMaterial defines the hosting NodeMaterial
  56831. * @param mesh defines the mesh that will be rendered
  56832. */
  56833. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56834. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56835. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56836. protected _writeFloat(value: number): string;
  56837. /**
  56838. * Gets the current class name e.g. "NodeMaterialBlock"
  56839. * @returns the class name
  56840. */
  56841. getClassName(): string;
  56842. /**
  56843. * Register a new input. Must be called inside a block constructor
  56844. * @param name defines the connection point name
  56845. * @param type defines the connection point type
  56846. * @param isOptional defines a boolean indicating that this input can be omitted
  56847. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56848. * @returns the current block
  56849. */
  56850. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56851. /**
  56852. * Register a new output. Must be called inside a block constructor
  56853. * @param name defines the connection point name
  56854. * @param type defines the connection point type
  56855. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56856. * @returns the current block
  56857. */
  56858. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56859. /**
  56860. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56861. * @param forOutput defines an optional connection point to check compatibility with
  56862. * @returns the first available input or null
  56863. */
  56864. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56865. /**
  56866. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56867. * @param forBlock defines an optional block to check compatibility with
  56868. * @returns the first available input or null
  56869. */
  56870. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56871. /**
  56872. * Gets the sibling of the given output
  56873. * @param current defines the current output
  56874. * @returns the next output in the list or null
  56875. */
  56876. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56877. /**
  56878. * Connect current block with another block
  56879. * @param other defines the block to connect with
  56880. * @param options define the various options to help pick the right connections
  56881. * @returns the current block
  56882. */
  56883. connectTo(other: NodeMaterialBlock, options?: {
  56884. input?: string;
  56885. output?: string;
  56886. outputSwizzle?: string;
  56887. }): this | undefined;
  56888. protected _buildBlock(state: NodeMaterialBuildState): void;
  56889. /**
  56890. * Add uniforms, samplers and uniform buffers at compilation time
  56891. * @param state defines the state to update
  56892. * @param nodeMaterial defines the node material requesting the update
  56893. * @param defines defines the material defines to update
  56894. * @param uniformBuffers defines the list of uniform buffer names
  56895. */
  56896. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56897. /**
  56898. * Add potential fallbacks if shader compilation fails
  56899. * @param mesh defines the mesh to be rendered
  56900. * @param fallbacks defines the current prioritized list of fallbacks
  56901. */
  56902. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56903. /**
  56904. * Initialize defines for shader compilation
  56905. * @param mesh defines the mesh to be rendered
  56906. * @param nodeMaterial defines the node material requesting the update
  56907. * @param defines defines the material defines to update
  56908. * @param useInstances specifies that instances should be used
  56909. */
  56910. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56911. /**
  56912. * Update defines for shader compilation
  56913. * @param mesh defines the mesh to be rendered
  56914. * @param nodeMaterial defines the node material requesting the update
  56915. * @param defines defines the material defines to update
  56916. * @param useInstances specifies that instances should be used
  56917. */
  56918. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56919. /**
  56920. * Lets the block try to connect some inputs automatically
  56921. * @param material defines the hosting NodeMaterial
  56922. */
  56923. autoConfigure(material: NodeMaterial): void;
  56924. /**
  56925. * Function called when a block is declared as repeatable content generator
  56926. * @param vertexShaderState defines the current compilation state for the vertex shader
  56927. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56928. * @param mesh defines the mesh to be rendered
  56929. * @param defines defines the material defines to update
  56930. */
  56931. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56932. /**
  56933. * Checks if the block is ready
  56934. * @param mesh defines the mesh to be rendered
  56935. * @param nodeMaterial defines the node material requesting the update
  56936. * @param defines defines the material defines to update
  56937. * @param useInstances specifies that instances should be used
  56938. * @returns true if the block is ready
  56939. */
  56940. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56941. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56942. private _processBuild;
  56943. /**
  56944. * Compile the current node and generate the shader code
  56945. * @param state defines the current compilation state (uniforms, samplers, current string)
  56946. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56947. * @returns true if already built
  56948. */
  56949. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56950. protected _inputRename(name: string): string;
  56951. protected _outputRename(name: string): string;
  56952. protected _dumpPropertiesCode(): string;
  56953. /** @hidden */
  56954. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56955. /** @hidden */
  56956. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  56957. /**
  56958. * Clone the current block to a new identical block
  56959. * @param scene defines the hosting scene
  56960. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56961. * @returns a copy of the current block
  56962. */
  56963. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56964. /**
  56965. * Serializes this block in a JSON representation
  56966. * @returns the serialized block object
  56967. */
  56968. serialize(): any;
  56969. /** @hidden */
  56970. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56971. /**
  56972. * Release resources
  56973. */
  56974. dispose(): void;
  56975. }
  56976. }
  56977. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56978. /**
  56979. * Enum defining the type of animations supported by InputBlock
  56980. */
  56981. export enum AnimatedInputBlockTypes {
  56982. /** No animation */
  56983. None = 0,
  56984. /** Time based animation. Will only work for floats */
  56985. Time = 1
  56986. }
  56987. }
  56988. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56989. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56990. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56991. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56992. import { Nullable } from "babylonjs/types";
  56993. import { Effect } from "babylonjs/Materials/effect";
  56994. import { Matrix } from "babylonjs/Maths/math.vector";
  56995. import { Scene } from "babylonjs/scene";
  56996. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56997. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56998. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56999. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57000. /**
  57001. * Block used to expose an input value
  57002. */
  57003. export class InputBlock extends NodeMaterialBlock {
  57004. private _mode;
  57005. private _associatedVariableName;
  57006. private _storedValue;
  57007. private _valueCallback;
  57008. private _type;
  57009. private _animationType;
  57010. /** Gets or set a value used to limit the range of float values */
  57011. min: number;
  57012. /** Gets or set a value used to limit the range of float values */
  57013. max: number;
  57014. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57015. matrixMode: number;
  57016. /** @hidden */
  57017. _systemValue: Nullable<NodeMaterialSystemValues>;
  57018. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57019. visibleInInspector: boolean;
  57020. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57021. isConstant: boolean;
  57022. /**
  57023. * Gets or sets the connection point type (default is float)
  57024. */
  57025. readonly type: NodeMaterialBlockConnectionPointTypes;
  57026. /**
  57027. * Creates a new InputBlock
  57028. * @param name defines the block name
  57029. * @param target defines the target of that block (Vertex by default)
  57030. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57031. */
  57032. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57033. /**
  57034. * Gets the output component
  57035. */
  57036. readonly output: NodeMaterialConnectionPoint;
  57037. /**
  57038. * Set the source of this connection point to a vertex attribute
  57039. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57040. * @returns the current connection point
  57041. */
  57042. setAsAttribute(attributeName?: string): InputBlock;
  57043. /**
  57044. * Set the source of this connection point to a system value
  57045. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57046. * @returns the current connection point
  57047. */
  57048. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57049. /**
  57050. * Gets or sets the value of that point.
  57051. * Please note that this value will be ignored if valueCallback is defined
  57052. */
  57053. value: any;
  57054. /**
  57055. * Gets or sets a callback used to get the value of that point.
  57056. * Please note that setting this value will force the connection point to ignore the value property
  57057. */
  57058. valueCallback: () => any;
  57059. /**
  57060. * Gets or sets the associated variable name in the shader
  57061. */
  57062. associatedVariableName: string;
  57063. /** Gets or sets the type of animation applied to the input */
  57064. animationType: AnimatedInputBlockTypes;
  57065. /**
  57066. * Gets a boolean indicating that this connection point not defined yet
  57067. */
  57068. readonly isUndefined: boolean;
  57069. /**
  57070. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57071. * In this case the connection point name must be the name of the uniform to use.
  57072. * Can only be set on inputs
  57073. */
  57074. isUniform: boolean;
  57075. /**
  57076. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57077. * In this case the connection point name must be the name of the attribute to use
  57078. * Can only be set on inputs
  57079. */
  57080. isAttribute: boolean;
  57081. /**
  57082. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57083. * Can only be set on exit points
  57084. */
  57085. isVarying: boolean;
  57086. /**
  57087. * Gets a boolean indicating that the current connection point is a system value
  57088. */
  57089. readonly isSystemValue: boolean;
  57090. /**
  57091. * Gets or sets the current well known value or null if not defined as a system value
  57092. */
  57093. systemValue: Nullable<NodeMaterialSystemValues>;
  57094. /**
  57095. * Gets the current class name
  57096. * @returns the class name
  57097. */
  57098. getClassName(): string;
  57099. /**
  57100. * Animate the input if animationType !== None
  57101. * @param scene defines the rendering scene
  57102. */
  57103. animate(scene: Scene): void;
  57104. private _emitDefine;
  57105. initialize(state: NodeMaterialBuildState): void;
  57106. /**
  57107. * Set the input block to its default value (based on its type)
  57108. */
  57109. setDefaultValue(): void;
  57110. private _emitConstant;
  57111. private _emit;
  57112. /** @hidden */
  57113. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57114. /** @hidden */
  57115. _transmit(effect: Effect, scene: Scene): void;
  57116. protected _buildBlock(state: NodeMaterialBuildState): void;
  57117. protected _dumpPropertiesCode(): string;
  57118. serialize(): any;
  57119. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57120. }
  57121. }
  57122. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  57123. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57124. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57125. import { Nullable } from "babylonjs/types";
  57126. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57127. import { Observable } from "babylonjs/Misc/observable";
  57128. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57129. /**
  57130. * Enum used to define the compatibility state between two connection points
  57131. */
  57132. export enum NodeMaterialConnectionPointCompatibilityStates {
  57133. /** Points are compatibles */
  57134. Compatible = 0,
  57135. /** Points are incompatible because of their types */
  57136. TypeIncompatible = 1,
  57137. /** Points are incompatible because of their targets (vertex vs fragment) */
  57138. TargetIncompatible = 2
  57139. }
  57140. /**
  57141. * Defines a connection point for a block
  57142. */
  57143. export class NodeMaterialConnectionPoint {
  57144. /** @hidden */
  57145. _ownerBlock: NodeMaterialBlock;
  57146. /** @hidden */
  57147. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57148. private _endpoints;
  57149. private _associatedVariableName;
  57150. /** @hidden */
  57151. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57152. /** @hidden */
  57153. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57154. private _type;
  57155. /** @hidden */
  57156. _enforceAssociatedVariableName: boolean;
  57157. /**
  57158. * Gets or sets the additional types supported by this connection point
  57159. */
  57160. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57161. /**
  57162. * Gets or sets the additional types excluded by this connection point
  57163. */
  57164. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57165. /**
  57166. * Observable triggered when this point is connected
  57167. */
  57168. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  57169. /**
  57170. * Gets or sets the associated variable name in the shader
  57171. */
  57172. associatedVariableName: string;
  57173. /**
  57174. * Gets or sets the connection point type (default is float)
  57175. */
  57176. type: NodeMaterialBlockConnectionPointTypes;
  57177. /**
  57178. * Gets or sets the connection point name
  57179. */
  57180. name: string;
  57181. /**
  57182. * Gets or sets a boolean indicating that this connection point can be omitted
  57183. */
  57184. isOptional: boolean;
  57185. /**
  57186. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  57187. */
  57188. define: string;
  57189. /** @hidden */
  57190. _prioritizeVertex: boolean;
  57191. private _target;
  57192. /** Gets or sets the target of that connection point */
  57193. target: NodeMaterialBlockTargets;
  57194. /**
  57195. * Gets a boolean indicating that the current point is connected
  57196. */
  57197. readonly isConnected: boolean;
  57198. /**
  57199. * Gets a boolean indicating that the current point is connected to an input block
  57200. */
  57201. readonly isConnectedToInputBlock: boolean;
  57202. /**
  57203. * Gets a the connected input block (if any)
  57204. */
  57205. readonly connectInputBlock: Nullable<InputBlock>;
  57206. /** Get the other side of the connection (if any) */
  57207. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57208. /** Get the block that owns this connection point */
  57209. readonly ownerBlock: NodeMaterialBlock;
  57210. /** Get the block connected on the other side of this connection (if any) */
  57211. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  57212. /** Get the block connected on the endpoints of this connection (if any) */
  57213. readonly connectedBlocks: Array<NodeMaterialBlock>;
  57214. /** Gets the list of connected endpoints */
  57215. readonly endpoints: NodeMaterialConnectionPoint[];
  57216. /** Gets a boolean indicating if that output point is connected to at least one input */
  57217. readonly hasEndpoints: boolean;
  57218. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  57219. readonly isConnectedInVertexShader: boolean;
  57220. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  57221. readonly isConnectedInFragmentShader: boolean;
  57222. /**
  57223. * Creates a new connection point
  57224. * @param name defines the connection point name
  57225. * @param ownerBlock defines the block hosting this connection point
  57226. */
  57227. constructor(name: string, ownerBlock: NodeMaterialBlock);
  57228. /**
  57229. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  57230. * @returns the class name
  57231. */
  57232. getClassName(): string;
  57233. /**
  57234. * Gets a boolean indicating if the current point can be connected to another point
  57235. * @param connectionPoint defines the other connection point
  57236. * @returns a boolean
  57237. */
  57238. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  57239. /**
  57240. * Gets a number indicating if the current point can be connected to another point
  57241. * @param connectionPoint defines the other connection point
  57242. * @returns a number defining the compatibility state
  57243. */
  57244. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57245. /**
  57246. * Connect this point to another connection point
  57247. * @param connectionPoint defines the other connection point
  57248. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  57249. * @returns the current connection point
  57250. */
  57251. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  57252. /**
  57253. * Disconnect this point from one of his endpoint
  57254. * @param endpoint defines the other connection point
  57255. * @returns the current connection point
  57256. */
  57257. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  57258. /**
  57259. * Serializes this point in a JSON representation
  57260. * @returns the serialized point object
  57261. */
  57262. serialize(): any;
  57263. /**
  57264. * Release resources
  57265. */
  57266. dispose(): void;
  57267. }
  57268. }
  57269. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  57270. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57271. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57273. import { Mesh } from "babylonjs/Meshes/mesh";
  57274. import { Effect } from "babylonjs/Materials/effect";
  57275. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57276. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57277. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57278. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57279. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57280. /**
  57281. * Block used to add support for vertex skinning (bones)
  57282. */
  57283. export class BonesBlock extends NodeMaterialBlock {
  57284. /**
  57285. * Creates a new BonesBlock
  57286. * @param name defines the block name
  57287. */
  57288. constructor(name: string);
  57289. /**
  57290. * Initialize the block and prepare the context for build
  57291. * @param state defines the state that will be used for the build
  57292. */
  57293. initialize(state: NodeMaterialBuildState): void;
  57294. /**
  57295. * Gets the current class name
  57296. * @returns the class name
  57297. */
  57298. getClassName(): string;
  57299. /**
  57300. * Gets the matrix indices input component
  57301. */
  57302. readonly matricesIndices: NodeMaterialConnectionPoint;
  57303. /**
  57304. * Gets the matrix weights input component
  57305. */
  57306. readonly matricesWeights: NodeMaterialConnectionPoint;
  57307. /**
  57308. * Gets the extra matrix indices input component
  57309. */
  57310. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  57311. /**
  57312. * Gets the extra matrix weights input component
  57313. */
  57314. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  57315. /**
  57316. * Gets the world input component
  57317. */
  57318. readonly world: NodeMaterialConnectionPoint;
  57319. /**
  57320. * Gets the output component
  57321. */
  57322. readonly output: NodeMaterialConnectionPoint;
  57323. autoConfigure(material: NodeMaterial): void;
  57324. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57325. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57326. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57327. protected _buildBlock(state: NodeMaterialBuildState): this;
  57328. }
  57329. }
  57330. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  57331. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57332. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57333. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57335. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57336. /**
  57337. * Block used to add support for instances
  57338. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57339. */
  57340. export class InstancesBlock extends NodeMaterialBlock {
  57341. /**
  57342. * Creates a new InstancesBlock
  57343. * @param name defines the block name
  57344. */
  57345. constructor(name: string);
  57346. /**
  57347. * Gets the current class name
  57348. * @returns the class name
  57349. */
  57350. getClassName(): string;
  57351. /**
  57352. * Gets the first world row input component
  57353. */
  57354. readonly world0: NodeMaterialConnectionPoint;
  57355. /**
  57356. * Gets the second world row input component
  57357. */
  57358. readonly world1: NodeMaterialConnectionPoint;
  57359. /**
  57360. * Gets the third world row input component
  57361. */
  57362. readonly world2: NodeMaterialConnectionPoint;
  57363. /**
  57364. * Gets the forth world row input component
  57365. */
  57366. readonly world3: NodeMaterialConnectionPoint;
  57367. /**
  57368. * Gets the world input component
  57369. */
  57370. readonly world: NodeMaterialConnectionPoint;
  57371. /**
  57372. * Gets the output component
  57373. */
  57374. readonly output: NodeMaterialConnectionPoint;
  57375. autoConfigure(material: NodeMaterial): void;
  57376. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57377. protected _buildBlock(state: NodeMaterialBuildState): this;
  57378. }
  57379. }
  57380. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  57381. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57382. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57383. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57385. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57386. import { Effect } from "babylonjs/Materials/effect";
  57387. import { Mesh } from "babylonjs/Meshes/mesh";
  57388. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57389. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57390. /**
  57391. * Block used to add morph targets support to vertex shader
  57392. */
  57393. export class MorphTargetsBlock extends NodeMaterialBlock {
  57394. private _repeatableContentAnchor;
  57395. private _repeatebleContentGenerated;
  57396. /**
  57397. * Create a new MorphTargetsBlock
  57398. * @param name defines the block name
  57399. */
  57400. constructor(name: string);
  57401. /**
  57402. * Gets the current class name
  57403. * @returns the class name
  57404. */
  57405. getClassName(): string;
  57406. /**
  57407. * Gets the position input component
  57408. */
  57409. readonly position: NodeMaterialConnectionPoint;
  57410. /**
  57411. * Gets the normal input component
  57412. */
  57413. readonly normal: NodeMaterialConnectionPoint;
  57414. /**
  57415. * Gets the tangent input component
  57416. */
  57417. readonly tangent: NodeMaterialConnectionPoint;
  57418. /**
  57419. * Gets the tangent input component
  57420. */
  57421. readonly uv: NodeMaterialConnectionPoint;
  57422. /**
  57423. * Gets the position output component
  57424. */
  57425. readonly positionOutput: NodeMaterialConnectionPoint;
  57426. /**
  57427. * Gets the normal output component
  57428. */
  57429. readonly normalOutput: NodeMaterialConnectionPoint;
  57430. /**
  57431. * Gets the tangent output component
  57432. */
  57433. readonly tangentOutput: NodeMaterialConnectionPoint;
  57434. /**
  57435. * Gets the tangent output component
  57436. */
  57437. readonly uvOutput: NodeMaterialConnectionPoint;
  57438. initialize(state: NodeMaterialBuildState): void;
  57439. autoConfigure(material: NodeMaterial): void;
  57440. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57441. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57442. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57443. protected _buildBlock(state: NodeMaterialBuildState): this;
  57444. }
  57445. }
  57446. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  57447. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57448. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57449. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57450. import { Nullable } from "babylonjs/types";
  57451. import { Scene } from "babylonjs/scene";
  57452. import { Effect } from "babylonjs/Materials/effect";
  57453. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57454. import { Mesh } from "babylonjs/Meshes/mesh";
  57455. import { Light } from "babylonjs/Lights/light";
  57456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57457. /**
  57458. * Block used to get data information from a light
  57459. */
  57460. export class LightInformationBlock extends NodeMaterialBlock {
  57461. private _lightDataUniformName;
  57462. private _lightColorUniformName;
  57463. private _lightTypeDefineName;
  57464. /**
  57465. * Gets or sets the light associated with this block
  57466. */
  57467. light: Nullable<Light>;
  57468. /**
  57469. * Creates a new LightInformationBlock
  57470. * @param name defines the block name
  57471. */
  57472. constructor(name: string);
  57473. /**
  57474. * Gets the current class name
  57475. * @returns the class name
  57476. */
  57477. getClassName(): string;
  57478. /**
  57479. * Gets the world position input component
  57480. */
  57481. readonly worldPosition: NodeMaterialConnectionPoint;
  57482. /**
  57483. * Gets the direction output component
  57484. */
  57485. readonly direction: NodeMaterialConnectionPoint;
  57486. /**
  57487. * Gets the direction output component
  57488. */
  57489. readonly color: NodeMaterialConnectionPoint;
  57490. /**
  57491. * Gets the direction output component
  57492. */
  57493. readonly intensity: NodeMaterialConnectionPoint;
  57494. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57495. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57496. protected _buildBlock(state: NodeMaterialBuildState): this;
  57497. serialize(): any;
  57498. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57499. }
  57500. }
  57501. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  57502. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  57503. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  57504. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  57505. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  57506. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  57507. }
  57508. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  57509. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57510. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57511. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57513. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57514. import { Effect } from "babylonjs/Materials/effect";
  57515. import { Mesh } from "babylonjs/Meshes/mesh";
  57516. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57517. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57518. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57519. /**
  57520. * Block used to add image processing support to fragment shader
  57521. */
  57522. export class ImageProcessingBlock extends NodeMaterialBlock {
  57523. /**
  57524. * Create a new ImageProcessingBlock
  57525. * @param name defines the block name
  57526. */
  57527. constructor(name: string);
  57528. /**
  57529. * Gets the current class name
  57530. * @returns the class name
  57531. */
  57532. getClassName(): string;
  57533. /**
  57534. * Gets the color input component
  57535. */
  57536. readonly color: NodeMaterialConnectionPoint;
  57537. /**
  57538. * Gets the output component
  57539. */
  57540. readonly output: NodeMaterialConnectionPoint;
  57541. /**
  57542. * Initialize the block and prepare the context for build
  57543. * @param state defines the state that will be used for the build
  57544. */
  57545. initialize(state: NodeMaterialBuildState): void;
  57546. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  57547. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57548. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57549. protected _buildBlock(state: NodeMaterialBuildState): this;
  57550. }
  57551. }
  57552. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  57553. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57554. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57555. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57556. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57558. import { Effect } from "babylonjs/Materials/effect";
  57559. import { Mesh } from "babylonjs/Meshes/mesh";
  57560. import { Scene } from "babylonjs/scene";
  57561. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57562. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57563. /**
  57564. * Block used to pertub normals based on a normal map
  57565. */
  57566. export class PerturbNormalBlock extends NodeMaterialBlock {
  57567. private _tangentSpaceParameterName;
  57568. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57569. invertX: boolean;
  57570. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  57571. invertY: boolean;
  57572. /**
  57573. * Create a new PerturbNormalBlock
  57574. * @param name defines the block name
  57575. */
  57576. constructor(name: string);
  57577. /**
  57578. * Gets the current class name
  57579. * @returns the class name
  57580. */
  57581. getClassName(): string;
  57582. /**
  57583. * Gets the world position input component
  57584. */
  57585. readonly worldPosition: NodeMaterialConnectionPoint;
  57586. /**
  57587. * Gets the world normal input component
  57588. */
  57589. readonly worldNormal: NodeMaterialConnectionPoint;
  57590. /**
  57591. * Gets the uv input component
  57592. */
  57593. readonly uv: NodeMaterialConnectionPoint;
  57594. /**
  57595. * Gets the normal map color input component
  57596. */
  57597. readonly normalMapColor: NodeMaterialConnectionPoint;
  57598. /**
  57599. * Gets the strength input component
  57600. */
  57601. readonly strength: NodeMaterialConnectionPoint;
  57602. /**
  57603. * Gets the output component
  57604. */
  57605. readonly output: NodeMaterialConnectionPoint;
  57606. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57607. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57608. autoConfigure(material: NodeMaterial): void;
  57609. protected _buildBlock(state: NodeMaterialBuildState): this;
  57610. protected _dumpPropertiesCode(): string;
  57611. serialize(): any;
  57612. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57613. }
  57614. }
  57615. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  57616. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57617. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57618. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57619. /**
  57620. * Block used to discard a pixel if a value is smaller than a cutoff
  57621. */
  57622. export class DiscardBlock extends NodeMaterialBlock {
  57623. /**
  57624. * Create a new DiscardBlock
  57625. * @param name defines the block name
  57626. */
  57627. constructor(name: string);
  57628. /**
  57629. * Gets the current class name
  57630. * @returns the class name
  57631. */
  57632. getClassName(): string;
  57633. /**
  57634. * Gets the color input component
  57635. */
  57636. readonly value: NodeMaterialConnectionPoint;
  57637. /**
  57638. * Gets the cutoff input component
  57639. */
  57640. readonly cutoff: NodeMaterialConnectionPoint;
  57641. protected _buildBlock(state: NodeMaterialBuildState): this;
  57642. }
  57643. }
  57644. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  57645. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57646. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57647. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57648. /**
  57649. * Block used to test if the fragment shader is front facing
  57650. */
  57651. export class FrontFacingBlock extends NodeMaterialBlock {
  57652. /**
  57653. * Creates a new FrontFacingBlock
  57654. * @param name defines the block name
  57655. */
  57656. constructor(name: string);
  57657. /**
  57658. * Gets the current class name
  57659. * @returns the class name
  57660. */
  57661. getClassName(): string;
  57662. /**
  57663. * Gets the output component
  57664. */
  57665. readonly output: NodeMaterialConnectionPoint;
  57666. protected _buildBlock(state: NodeMaterialBuildState): this;
  57667. }
  57668. }
  57669. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  57670. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  57671. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  57672. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  57673. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  57674. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  57675. }
  57676. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  57677. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57678. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57679. import { Mesh } from "babylonjs/Meshes/mesh";
  57680. import { Effect } from "babylonjs/Materials/effect";
  57681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57683. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57684. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57685. /**
  57686. * Block used to add support for scene fog
  57687. */
  57688. export class FogBlock extends NodeMaterialBlock {
  57689. private _fogDistanceName;
  57690. private _fogParameters;
  57691. /**
  57692. * Create a new FogBlock
  57693. * @param name defines the block name
  57694. */
  57695. constructor(name: string);
  57696. /**
  57697. * Gets the current class name
  57698. * @returns the class name
  57699. */
  57700. getClassName(): string;
  57701. /**
  57702. * Gets the world position input component
  57703. */
  57704. readonly worldPosition: NodeMaterialConnectionPoint;
  57705. /**
  57706. * Gets the view input component
  57707. */
  57708. readonly view: NodeMaterialConnectionPoint;
  57709. /**
  57710. * Gets the color input component
  57711. */
  57712. readonly input: NodeMaterialConnectionPoint;
  57713. /**
  57714. * Gets the fog color input component
  57715. */
  57716. readonly fogColor: NodeMaterialConnectionPoint;
  57717. /**
  57718. * Gets the output component
  57719. */
  57720. readonly output: NodeMaterialConnectionPoint;
  57721. autoConfigure(material: NodeMaterial): void;
  57722. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57723. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57724. protected _buildBlock(state: NodeMaterialBuildState): this;
  57725. }
  57726. }
  57727. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  57728. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57729. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57730. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57732. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57733. import { Effect } from "babylonjs/Materials/effect";
  57734. import { Mesh } from "babylonjs/Meshes/mesh";
  57735. import { Light } from "babylonjs/Lights/light";
  57736. import { Nullable } from "babylonjs/types";
  57737. import { Scene } from "babylonjs/scene";
  57738. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57739. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57740. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57741. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57742. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  57743. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57744. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57745. /**
  57746. * Block used to add light in the fragment shader
  57747. */
  57748. export class LightBlock extends NodeMaterialBlock {
  57749. private _lightId;
  57750. /**
  57751. * Gets or sets the light associated with this block
  57752. */
  57753. light: Nullable<Light>;
  57754. /**
  57755. * Create a new LightBlock
  57756. * @param name defines the block name
  57757. */
  57758. constructor(name: string);
  57759. /**
  57760. * Gets the current class name
  57761. * @returns the class name
  57762. */
  57763. getClassName(): string;
  57764. /**
  57765. * Gets the world position input component
  57766. */
  57767. readonly worldPosition: NodeMaterialConnectionPoint;
  57768. /**
  57769. * Gets the world normal input component
  57770. */
  57771. readonly worldNormal: NodeMaterialConnectionPoint;
  57772. /**
  57773. * Gets the camera (or eye) position component
  57774. */
  57775. readonly cameraPosition: NodeMaterialConnectionPoint;
  57776. /**
  57777. * Gets the glossiness component
  57778. */
  57779. readonly glossiness: NodeMaterialConnectionPoint;
  57780. /**
  57781. * Gets the glossinness power component
  57782. */
  57783. readonly glossPower: NodeMaterialConnectionPoint;
  57784. /**
  57785. * Gets the diffuse color component
  57786. */
  57787. readonly diffuseColor: NodeMaterialConnectionPoint;
  57788. /**
  57789. * Gets the specular color component
  57790. */
  57791. readonly specularColor: NodeMaterialConnectionPoint;
  57792. /**
  57793. * Gets the diffuse output component
  57794. */
  57795. readonly diffuseOutput: NodeMaterialConnectionPoint;
  57796. /**
  57797. * Gets the specular output component
  57798. */
  57799. readonly specularOutput: NodeMaterialConnectionPoint;
  57800. autoConfigure(material: NodeMaterial): void;
  57801. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57802. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57803. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57804. private _injectVertexCode;
  57805. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57806. serialize(): any;
  57807. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57808. }
  57809. }
  57810. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  57811. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  57812. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  57813. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57814. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57815. }
  57816. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  57817. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57818. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57819. }
  57820. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  57821. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57822. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57823. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57824. /**
  57825. * Block used to multiply 2 values
  57826. */
  57827. export class MultiplyBlock extends NodeMaterialBlock {
  57828. /**
  57829. * Creates a new MultiplyBlock
  57830. * @param name defines the block name
  57831. */
  57832. constructor(name: string);
  57833. /**
  57834. * Gets the current class name
  57835. * @returns the class name
  57836. */
  57837. getClassName(): string;
  57838. /**
  57839. * Gets the left operand input component
  57840. */
  57841. readonly left: NodeMaterialConnectionPoint;
  57842. /**
  57843. * Gets the right operand input component
  57844. */
  57845. readonly right: NodeMaterialConnectionPoint;
  57846. /**
  57847. * Gets the output component
  57848. */
  57849. readonly output: NodeMaterialConnectionPoint;
  57850. protected _buildBlock(state: NodeMaterialBuildState): this;
  57851. }
  57852. }
  57853. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  57854. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57855. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57856. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57857. /**
  57858. * Block used to add 2 vectors
  57859. */
  57860. export class AddBlock extends NodeMaterialBlock {
  57861. /**
  57862. * Creates a new AddBlock
  57863. * @param name defines the block name
  57864. */
  57865. constructor(name: string);
  57866. /**
  57867. * Gets the current class name
  57868. * @returns the class name
  57869. */
  57870. getClassName(): string;
  57871. /**
  57872. * Gets the left operand input component
  57873. */
  57874. readonly left: NodeMaterialConnectionPoint;
  57875. /**
  57876. * Gets the right operand input component
  57877. */
  57878. readonly right: NodeMaterialConnectionPoint;
  57879. /**
  57880. * Gets the output component
  57881. */
  57882. readonly output: NodeMaterialConnectionPoint;
  57883. protected _buildBlock(state: NodeMaterialBuildState): this;
  57884. }
  57885. }
  57886. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57887. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57888. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57889. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57890. /**
  57891. * Block used to scale a vector by a float
  57892. */
  57893. export class ScaleBlock extends NodeMaterialBlock {
  57894. /**
  57895. * Creates a new ScaleBlock
  57896. * @param name defines the block name
  57897. */
  57898. constructor(name: string);
  57899. /**
  57900. * Gets the current class name
  57901. * @returns the class name
  57902. */
  57903. getClassName(): string;
  57904. /**
  57905. * Gets the input component
  57906. */
  57907. readonly input: NodeMaterialConnectionPoint;
  57908. /**
  57909. * Gets the factor input component
  57910. */
  57911. readonly factor: NodeMaterialConnectionPoint;
  57912. /**
  57913. * Gets the output component
  57914. */
  57915. readonly output: NodeMaterialConnectionPoint;
  57916. protected _buildBlock(state: NodeMaterialBuildState): this;
  57917. }
  57918. }
  57919. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57920. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57921. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57922. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57923. import { Scene } from "babylonjs/scene";
  57924. /**
  57925. * Block used to clamp a float
  57926. */
  57927. export class ClampBlock extends NodeMaterialBlock {
  57928. /** Gets or sets the minimum range */
  57929. minimum: number;
  57930. /** Gets or sets the maximum range */
  57931. maximum: number;
  57932. /**
  57933. * Creates a new ClampBlock
  57934. * @param name defines the block name
  57935. */
  57936. constructor(name: string);
  57937. /**
  57938. * Gets the current class name
  57939. * @returns the class name
  57940. */
  57941. getClassName(): string;
  57942. /**
  57943. * Gets the value input component
  57944. */
  57945. readonly value: NodeMaterialConnectionPoint;
  57946. /**
  57947. * Gets the output component
  57948. */
  57949. readonly output: NodeMaterialConnectionPoint;
  57950. protected _buildBlock(state: NodeMaterialBuildState): this;
  57951. protected _dumpPropertiesCode(): string;
  57952. serialize(): any;
  57953. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57954. }
  57955. }
  57956. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57958. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57959. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57960. /**
  57961. * Block used to apply a cross product between 2 vectors
  57962. */
  57963. export class CrossBlock extends NodeMaterialBlock {
  57964. /**
  57965. * Creates a new CrossBlock
  57966. * @param name defines the block name
  57967. */
  57968. constructor(name: string);
  57969. /**
  57970. * Gets the current class name
  57971. * @returns the class name
  57972. */
  57973. getClassName(): string;
  57974. /**
  57975. * Gets the left operand input component
  57976. */
  57977. readonly left: NodeMaterialConnectionPoint;
  57978. /**
  57979. * Gets the right operand input component
  57980. */
  57981. readonly right: NodeMaterialConnectionPoint;
  57982. /**
  57983. * Gets the output component
  57984. */
  57985. readonly output: NodeMaterialConnectionPoint;
  57986. protected _buildBlock(state: NodeMaterialBuildState): this;
  57987. }
  57988. }
  57989. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57990. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57991. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57992. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57993. /**
  57994. * Block used to apply a dot product between 2 vectors
  57995. */
  57996. export class DotBlock extends NodeMaterialBlock {
  57997. /**
  57998. * Creates a new DotBlock
  57999. * @param name defines the block name
  58000. */
  58001. constructor(name: string);
  58002. /**
  58003. * Gets the current class name
  58004. * @returns the class name
  58005. */
  58006. getClassName(): string;
  58007. /**
  58008. * Gets the left operand input component
  58009. */
  58010. readonly left: NodeMaterialConnectionPoint;
  58011. /**
  58012. * Gets the right operand input component
  58013. */
  58014. readonly right: NodeMaterialConnectionPoint;
  58015. /**
  58016. * Gets the output component
  58017. */
  58018. readonly output: NodeMaterialConnectionPoint;
  58019. protected _buildBlock(state: NodeMaterialBuildState): this;
  58020. }
  58021. }
  58022. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  58023. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58024. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58025. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58026. import { Vector2 } from "babylonjs/Maths/math.vector";
  58027. import { Scene } from "babylonjs/scene";
  58028. /**
  58029. * Block used to remap a float from a range to a new one
  58030. */
  58031. export class RemapBlock extends NodeMaterialBlock {
  58032. /**
  58033. * Gets or sets the source range
  58034. */
  58035. sourceRange: Vector2;
  58036. /**
  58037. * Gets or sets the target range
  58038. */
  58039. targetRange: Vector2;
  58040. /**
  58041. * Creates a new RemapBlock
  58042. * @param name defines the block name
  58043. */
  58044. constructor(name: string);
  58045. /**
  58046. * Gets the current class name
  58047. * @returns the class name
  58048. */
  58049. getClassName(): string;
  58050. /**
  58051. * Gets the input component
  58052. */
  58053. readonly input: NodeMaterialConnectionPoint;
  58054. /**
  58055. * Gets the source min input component
  58056. */
  58057. readonly sourceMin: NodeMaterialConnectionPoint;
  58058. /**
  58059. * Gets the source max input component
  58060. */
  58061. readonly sourceMax: NodeMaterialConnectionPoint;
  58062. /**
  58063. * Gets the target min input component
  58064. */
  58065. readonly targetMin: NodeMaterialConnectionPoint;
  58066. /**
  58067. * Gets the target max input component
  58068. */
  58069. readonly targetMax: NodeMaterialConnectionPoint;
  58070. /**
  58071. * Gets the output component
  58072. */
  58073. readonly output: NodeMaterialConnectionPoint;
  58074. protected _buildBlock(state: NodeMaterialBuildState): this;
  58075. protected _dumpPropertiesCode(): string;
  58076. serialize(): any;
  58077. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58078. }
  58079. }
  58080. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  58081. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58082. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58083. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58084. /**
  58085. * Block used to normalize a vector
  58086. */
  58087. export class NormalizeBlock extends NodeMaterialBlock {
  58088. /**
  58089. * Creates a new NormalizeBlock
  58090. * @param name defines the block name
  58091. */
  58092. constructor(name: string);
  58093. /**
  58094. * Gets the current class name
  58095. * @returns the class name
  58096. */
  58097. getClassName(): string;
  58098. /**
  58099. * Gets the input component
  58100. */
  58101. readonly input: NodeMaterialConnectionPoint;
  58102. /**
  58103. * Gets the output component
  58104. */
  58105. readonly output: NodeMaterialConnectionPoint;
  58106. protected _buildBlock(state: NodeMaterialBuildState): this;
  58107. }
  58108. }
  58109. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  58110. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58111. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58112. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58113. import { Scene } from "babylonjs/scene";
  58114. /**
  58115. * Operations supported by the Trigonometry block
  58116. */
  58117. export enum TrigonometryBlockOperations {
  58118. /** Cos */
  58119. Cos = 0,
  58120. /** Sin */
  58121. Sin = 1,
  58122. /** Abs */
  58123. Abs = 2,
  58124. /** Exp */
  58125. Exp = 3,
  58126. /** Exp2 */
  58127. Exp2 = 4,
  58128. /** Round */
  58129. Round = 5,
  58130. /** Floor */
  58131. Floor = 6,
  58132. /** Ceiling */
  58133. Ceiling = 7,
  58134. /** Square root */
  58135. Sqrt = 8,
  58136. /** Log */
  58137. Log = 9,
  58138. /** Tangent */
  58139. Tan = 10,
  58140. /** Arc tangent */
  58141. ArcTan = 11,
  58142. /** Arc cosinus */
  58143. ArcCos = 12,
  58144. /** Arc sinus */
  58145. ArcSin = 13,
  58146. /** Fraction */
  58147. Fract = 14,
  58148. /** Sign */
  58149. Sign = 15,
  58150. /** To radians (from degrees) */
  58151. Radians = 16,
  58152. /** To degrees (from radians) */
  58153. Degrees = 17
  58154. }
  58155. /**
  58156. * Block used to apply trigonometry operation to floats
  58157. */
  58158. export class TrigonometryBlock extends NodeMaterialBlock {
  58159. /**
  58160. * Gets or sets the operation applied by the block
  58161. */
  58162. operation: TrigonometryBlockOperations;
  58163. /**
  58164. * Creates a new TrigonometryBlock
  58165. * @param name defines the block name
  58166. */
  58167. constructor(name: string);
  58168. /**
  58169. * Gets the current class name
  58170. * @returns the class name
  58171. */
  58172. getClassName(): string;
  58173. /**
  58174. * Gets the input component
  58175. */
  58176. readonly input: NodeMaterialConnectionPoint;
  58177. /**
  58178. * Gets the output component
  58179. */
  58180. readonly output: NodeMaterialConnectionPoint;
  58181. protected _buildBlock(state: NodeMaterialBuildState): this;
  58182. serialize(): any;
  58183. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58184. protected _dumpPropertiesCode(): string;
  58185. }
  58186. }
  58187. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  58188. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58189. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58190. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58191. /**
  58192. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58193. */
  58194. export class ColorMergerBlock extends NodeMaterialBlock {
  58195. /**
  58196. * Create a new ColorMergerBlock
  58197. * @param name defines the block name
  58198. */
  58199. constructor(name: string);
  58200. /**
  58201. * Gets the current class name
  58202. * @returns the class name
  58203. */
  58204. getClassName(): string;
  58205. /**
  58206. * Gets the r component (input)
  58207. */
  58208. readonly r: NodeMaterialConnectionPoint;
  58209. /**
  58210. * Gets the g component (input)
  58211. */
  58212. readonly g: NodeMaterialConnectionPoint;
  58213. /**
  58214. * Gets the b component (input)
  58215. */
  58216. readonly b: NodeMaterialConnectionPoint;
  58217. /**
  58218. * Gets the a component (input)
  58219. */
  58220. readonly a: NodeMaterialConnectionPoint;
  58221. /**
  58222. * Gets the rgba component (output)
  58223. */
  58224. readonly rgba: NodeMaterialConnectionPoint;
  58225. /**
  58226. * Gets the rgb component (output)
  58227. */
  58228. readonly rgb: NodeMaterialConnectionPoint;
  58229. protected _buildBlock(state: NodeMaterialBuildState): this;
  58230. }
  58231. }
  58232. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  58233. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58234. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58235. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58236. /**
  58237. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58238. */
  58239. export class VectorMergerBlock extends NodeMaterialBlock {
  58240. /**
  58241. * Create a new VectorMergerBlock
  58242. * @param name defines the block name
  58243. */
  58244. constructor(name: string);
  58245. /**
  58246. * Gets the current class name
  58247. * @returns the class name
  58248. */
  58249. getClassName(): string;
  58250. /**
  58251. * Gets the x component (input)
  58252. */
  58253. readonly x: NodeMaterialConnectionPoint;
  58254. /**
  58255. * Gets the y component (input)
  58256. */
  58257. readonly y: NodeMaterialConnectionPoint;
  58258. /**
  58259. * Gets the z component (input)
  58260. */
  58261. readonly z: NodeMaterialConnectionPoint;
  58262. /**
  58263. * Gets the w component (input)
  58264. */
  58265. readonly w: NodeMaterialConnectionPoint;
  58266. /**
  58267. * Gets the xyzw component (output)
  58268. */
  58269. readonly xyzw: NodeMaterialConnectionPoint;
  58270. /**
  58271. * Gets the xyz component (output)
  58272. */
  58273. readonly xyz: NodeMaterialConnectionPoint;
  58274. /**
  58275. * Gets the xy component (output)
  58276. */
  58277. readonly xy: NodeMaterialConnectionPoint;
  58278. protected _buildBlock(state: NodeMaterialBuildState): this;
  58279. }
  58280. }
  58281. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  58282. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58283. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58284. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58285. /**
  58286. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  58287. */
  58288. export class ColorSplitterBlock extends NodeMaterialBlock {
  58289. /**
  58290. * Create a new ColorSplitterBlock
  58291. * @param name defines the block name
  58292. */
  58293. constructor(name: string);
  58294. /**
  58295. * Gets the current class name
  58296. * @returns the class name
  58297. */
  58298. getClassName(): string;
  58299. /**
  58300. * Gets the rgba component (input)
  58301. */
  58302. readonly rgba: NodeMaterialConnectionPoint;
  58303. /**
  58304. * Gets the rgb component (input)
  58305. */
  58306. readonly rgbIn: NodeMaterialConnectionPoint;
  58307. /**
  58308. * Gets the rgb component (output)
  58309. */
  58310. readonly rgbOut: NodeMaterialConnectionPoint;
  58311. /**
  58312. * Gets the r component (output)
  58313. */
  58314. readonly r: NodeMaterialConnectionPoint;
  58315. /**
  58316. * Gets the g component (output)
  58317. */
  58318. readonly g: NodeMaterialConnectionPoint;
  58319. /**
  58320. * Gets the b component (output)
  58321. */
  58322. readonly b: NodeMaterialConnectionPoint;
  58323. /**
  58324. * Gets the a component (output)
  58325. */
  58326. readonly a: NodeMaterialConnectionPoint;
  58327. protected _inputRename(name: string): string;
  58328. protected _outputRename(name: string): string;
  58329. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58330. }
  58331. }
  58332. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  58333. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58334. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58335. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58336. /**
  58337. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58338. */
  58339. export class VectorSplitterBlock extends NodeMaterialBlock {
  58340. /**
  58341. * Create a new VectorSplitterBlock
  58342. * @param name defines the block name
  58343. */
  58344. constructor(name: string);
  58345. /**
  58346. * Gets the current class name
  58347. * @returns the class name
  58348. */
  58349. getClassName(): string;
  58350. /**
  58351. * Gets the xyzw component (input)
  58352. */
  58353. readonly xyzw: NodeMaterialConnectionPoint;
  58354. /**
  58355. * Gets the xyz component (input)
  58356. */
  58357. readonly xyzIn: NodeMaterialConnectionPoint;
  58358. /**
  58359. * Gets the xy component (input)
  58360. */
  58361. readonly xyIn: NodeMaterialConnectionPoint;
  58362. /**
  58363. * Gets the xyz component (output)
  58364. */
  58365. readonly xyzOut: NodeMaterialConnectionPoint;
  58366. /**
  58367. * Gets the xy component (output)
  58368. */
  58369. readonly xyOut: NodeMaterialConnectionPoint;
  58370. /**
  58371. * Gets the x component (output)
  58372. */
  58373. readonly x: NodeMaterialConnectionPoint;
  58374. /**
  58375. * Gets the y component (output)
  58376. */
  58377. readonly y: NodeMaterialConnectionPoint;
  58378. /**
  58379. * Gets the z component (output)
  58380. */
  58381. readonly z: NodeMaterialConnectionPoint;
  58382. /**
  58383. * Gets the w component (output)
  58384. */
  58385. readonly w: NodeMaterialConnectionPoint;
  58386. protected _inputRename(name: string): string;
  58387. protected _outputRename(name: string): string;
  58388. protected _buildBlock(state: NodeMaterialBuildState): this;
  58389. }
  58390. }
  58391. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  58392. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58393. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58394. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58395. /**
  58396. * Block used to lerp between 2 values
  58397. */
  58398. export class LerpBlock extends NodeMaterialBlock {
  58399. /**
  58400. * Creates a new LerpBlock
  58401. * @param name defines the block name
  58402. */
  58403. constructor(name: string);
  58404. /**
  58405. * Gets the current class name
  58406. * @returns the class name
  58407. */
  58408. getClassName(): string;
  58409. /**
  58410. * Gets the left operand input component
  58411. */
  58412. readonly left: NodeMaterialConnectionPoint;
  58413. /**
  58414. * Gets the right operand input component
  58415. */
  58416. readonly right: NodeMaterialConnectionPoint;
  58417. /**
  58418. * Gets the gradient operand input component
  58419. */
  58420. readonly gradient: NodeMaterialConnectionPoint;
  58421. /**
  58422. * Gets the output component
  58423. */
  58424. readonly output: NodeMaterialConnectionPoint;
  58425. protected _buildBlock(state: NodeMaterialBuildState): this;
  58426. }
  58427. }
  58428. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  58429. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58430. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58431. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58432. /**
  58433. * Block used to divide 2 vectors
  58434. */
  58435. export class DivideBlock extends NodeMaterialBlock {
  58436. /**
  58437. * Creates a new DivideBlock
  58438. * @param name defines the block name
  58439. */
  58440. constructor(name: string);
  58441. /**
  58442. * Gets the current class name
  58443. * @returns the class name
  58444. */
  58445. getClassName(): string;
  58446. /**
  58447. * Gets the left operand input component
  58448. */
  58449. readonly left: NodeMaterialConnectionPoint;
  58450. /**
  58451. * Gets the right operand input component
  58452. */
  58453. readonly right: NodeMaterialConnectionPoint;
  58454. /**
  58455. * Gets the output component
  58456. */
  58457. readonly output: NodeMaterialConnectionPoint;
  58458. protected _buildBlock(state: NodeMaterialBuildState): this;
  58459. }
  58460. }
  58461. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  58462. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58463. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58464. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58465. /**
  58466. * Block used to subtract 2 vectors
  58467. */
  58468. export class SubtractBlock extends NodeMaterialBlock {
  58469. /**
  58470. * Creates a new SubtractBlock
  58471. * @param name defines the block name
  58472. */
  58473. constructor(name: string);
  58474. /**
  58475. * Gets the current class name
  58476. * @returns the class name
  58477. */
  58478. getClassName(): string;
  58479. /**
  58480. * Gets the left operand input component
  58481. */
  58482. readonly left: NodeMaterialConnectionPoint;
  58483. /**
  58484. * Gets the right operand input component
  58485. */
  58486. readonly right: NodeMaterialConnectionPoint;
  58487. /**
  58488. * Gets the output component
  58489. */
  58490. readonly output: NodeMaterialConnectionPoint;
  58491. protected _buildBlock(state: NodeMaterialBuildState): this;
  58492. }
  58493. }
  58494. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  58495. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58496. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58497. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58498. /**
  58499. * Block used to step a value
  58500. */
  58501. export class StepBlock extends NodeMaterialBlock {
  58502. /**
  58503. * Creates a new StepBlock
  58504. * @param name defines the block name
  58505. */
  58506. constructor(name: string);
  58507. /**
  58508. * Gets the current class name
  58509. * @returns the class name
  58510. */
  58511. getClassName(): string;
  58512. /**
  58513. * Gets the value operand input component
  58514. */
  58515. readonly value: NodeMaterialConnectionPoint;
  58516. /**
  58517. * Gets the edge operand input component
  58518. */
  58519. readonly edge: NodeMaterialConnectionPoint;
  58520. /**
  58521. * Gets the output component
  58522. */
  58523. readonly output: NodeMaterialConnectionPoint;
  58524. protected _buildBlock(state: NodeMaterialBuildState): this;
  58525. }
  58526. }
  58527. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  58528. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58529. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58530. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58531. /**
  58532. * Block used to get the opposite (1 - x) of a value
  58533. */
  58534. export class OneMinusBlock extends NodeMaterialBlock {
  58535. /**
  58536. * Creates a new OneMinusBlock
  58537. * @param name defines the block name
  58538. */
  58539. constructor(name: string);
  58540. /**
  58541. * Gets the current class name
  58542. * @returns the class name
  58543. */
  58544. getClassName(): string;
  58545. /**
  58546. * Gets the input component
  58547. */
  58548. readonly input: NodeMaterialConnectionPoint;
  58549. /**
  58550. * Gets the output component
  58551. */
  58552. readonly output: NodeMaterialConnectionPoint;
  58553. protected _buildBlock(state: NodeMaterialBuildState): this;
  58554. }
  58555. }
  58556. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  58557. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58558. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58559. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58560. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58561. /**
  58562. * Block used to get the view direction
  58563. */
  58564. export class ViewDirectionBlock extends NodeMaterialBlock {
  58565. /**
  58566. * Creates a new ViewDirectionBlock
  58567. * @param name defines the block name
  58568. */
  58569. constructor(name: string);
  58570. /**
  58571. * Gets the current class name
  58572. * @returns the class name
  58573. */
  58574. getClassName(): string;
  58575. /**
  58576. * Gets the world position component
  58577. */
  58578. readonly worldPosition: NodeMaterialConnectionPoint;
  58579. /**
  58580. * Gets the camera position component
  58581. */
  58582. readonly cameraPosition: NodeMaterialConnectionPoint;
  58583. /**
  58584. * Gets the output component
  58585. */
  58586. readonly output: NodeMaterialConnectionPoint;
  58587. autoConfigure(material: NodeMaterial): void;
  58588. protected _buildBlock(state: NodeMaterialBuildState): this;
  58589. }
  58590. }
  58591. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  58592. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58593. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58594. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58595. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58596. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  58597. /**
  58598. * Block used to compute fresnel value
  58599. */
  58600. export class FresnelBlock extends NodeMaterialBlock {
  58601. /**
  58602. * Create a new FresnelBlock
  58603. * @param name defines the block name
  58604. */
  58605. constructor(name: string);
  58606. /**
  58607. * Gets the current class name
  58608. * @returns the class name
  58609. */
  58610. getClassName(): string;
  58611. /**
  58612. * Gets the world normal input component
  58613. */
  58614. readonly worldNormal: NodeMaterialConnectionPoint;
  58615. /**
  58616. * Gets the view direction input component
  58617. */
  58618. readonly viewDirection: NodeMaterialConnectionPoint;
  58619. /**
  58620. * Gets the bias input component
  58621. */
  58622. readonly bias: NodeMaterialConnectionPoint;
  58623. /**
  58624. * Gets the camera (or eye) position component
  58625. */
  58626. readonly power: NodeMaterialConnectionPoint;
  58627. /**
  58628. * Gets the fresnel output component
  58629. */
  58630. readonly fresnel: NodeMaterialConnectionPoint;
  58631. autoConfigure(material: NodeMaterial): void;
  58632. protected _buildBlock(state: NodeMaterialBuildState): this;
  58633. }
  58634. }
  58635. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  58636. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58637. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58638. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58639. /**
  58640. * Block used to get the max of 2 values
  58641. */
  58642. export class MaxBlock extends NodeMaterialBlock {
  58643. /**
  58644. * Creates a new MaxBlock
  58645. * @param name defines the block name
  58646. */
  58647. constructor(name: string);
  58648. /**
  58649. * Gets the current class name
  58650. * @returns the class name
  58651. */
  58652. getClassName(): string;
  58653. /**
  58654. * Gets the left operand input component
  58655. */
  58656. readonly left: NodeMaterialConnectionPoint;
  58657. /**
  58658. * Gets the right operand input component
  58659. */
  58660. readonly right: NodeMaterialConnectionPoint;
  58661. /**
  58662. * Gets the output component
  58663. */
  58664. readonly output: NodeMaterialConnectionPoint;
  58665. protected _buildBlock(state: NodeMaterialBuildState): this;
  58666. }
  58667. }
  58668. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  58669. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58670. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58671. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58672. /**
  58673. * Block used to get the min of 2 values
  58674. */
  58675. export class MinBlock extends NodeMaterialBlock {
  58676. /**
  58677. * Creates a new MinBlock
  58678. * @param name defines the block name
  58679. */
  58680. constructor(name: string);
  58681. /**
  58682. * Gets the current class name
  58683. * @returns the class name
  58684. */
  58685. getClassName(): string;
  58686. /**
  58687. * Gets the left operand input component
  58688. */
  58689. readonly left: NodeMaterialConnectionPoint;
  58690. /**
  58691. * Gets the right operand input component
  58692. */
  58693. readonly right: NodeMaterialConnectionPoint;
  58694. /**
  58695. * Gets the output component
  58696. */
  58697. readonly output: NodeMaterialConnectionPoint;
  58698. protected _buildBlock(state: NodeMaterialBuildState): this;
  58699. }
  58700. }
  58701. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  58702. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58703. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58704. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58705. /**
  58706. * Block used to get the distance between 2 values
  58707. */
  58708. export class DistanceBlock extends NodeMaterialBlock {
  58709. /**
  58710. * Creates a new DistanceBlock
  58711. * @param name defines the block name
  58712. */
  58713. constructor(name: string);
  58714. /**
  58715. * Gets the current class name
  58716. * @returns the class name
  58717. */
  58718. getClassName(): string;
  58719. /**
  58720. * Gets the left operand input component
  58721. */
  58722. readonly left: NodeMaterialConnectionPoint;
  58723. /**
  58724. * Gets the right operand input component
  58725. */
  58726. readonly right: NodeMaterialConnectionPoint;
  58727. /**
  58728. * Gets the output component
  58729. */
  58730. readonly output: NodeMaterialConnectionPoint;
  58731. protected _buildBlock(state: NodeMaterialBuildState): this;
  58732. }
  58733. }
  58734. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  58735. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58736. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58737. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58738. /**
  58739. * Block used to get the length of a vector
  58740. */
  58741. export class LengthBlock extends NodeMaterialBlock {
  58742. /**
  58743. * Creates a new LengthBlock
  58744. * @param name defines the block name
  58745. */
  58746. constructor(name: string);
  58747. /**
  58748. * Gets the current class name
  58749. * @returns the class name
  58750. */
  58751. getClassName(): string;
  58752. /**
  58753. * Gets the value input component
  58754. */
  58755. readonly value: NodeMaterialConnectionPoint;
  58756. /**
  58757. * Gets the output component
  58758. */
  58759. readonly output: NodeMaterialConnectionPoint;
  58760. protected _buildBlock(state: NodeMaterialBuildState): this;
  58761. }
  58762. }
  58763. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  58764. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58765. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58766. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58767. /**
  58768. * Block used to get negative version of a value (i.e. x * -1)
  58769. */
  58770. export class NegateBlock extends NodeMaterialBlock {
  58771. /**
  58772. * Creates a new NegateBlock
  58773. * @param name defines the block name
  58774. */
  58775. constructor(name: string);
  58776. /**
  58777. * Gets the current class name
  58778. * @returns the class name
  58779. */
  58780. getClassName(): string;
  58781. /**
  58782. * Gets the value input component
  58783. */
  58784. readonly value: NodeMaterialConnectionPoint;
  58785. /**
  58786. * Gets the output component
  58787. */
  58788. readonly output: NodeMaterialConnectionPoint;
  58789. protected _buildBlock(state: NodeMaterialBuildState): this;
  58790. }
  58791. }
  58792. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  58793. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58794. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58795. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58796. /**
  58797. * Block used to get the value of the first parameter raised to the power of the second
  58798. */
  58799. export class PowBlock extends NodeMaterialBlock {
  58800. /**
  58801. * Creates a new PowBlock
  58802. * @param name defines the block name
  58803. */
  58804. constructor(name: string);
  58805. /**
  58806. * Gets the current class name
  58807. * @returns the class name
  58808. */
  58809. getClassName(): string;
  58810. /**
  58811. * Gets the value operand input component
  58812. */
  58813. readonly value: NodeMaterialConnectionPoint;
  58814. /**
  58815. * Gets the power operand input component
  58816. */
  58817. readonly power: NodeMaterialConnectionPoint;
  58818. /**
  58819. * Gets the output component
  58820. */
  58821. readonly output: NodeMaterialConnectionPoint;
  58822. protected _buildBlock(state: NodeMaterialBuildState): this;
  58823. }
  58824. }
  58825. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  58826. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58827. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58828. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58829. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58830. /**
  58831. * Block used to get a random number
  58832. */
  58833. export class RandomNumberBlock extends NodeMaterialBlock {
  58834. /**
  58835. * Creates a new RandomNumberBlock
  58836. * @param name defines the block name
  58837. */
  58838. constructor(name: string);
  58839. /**
  58840. * Gets the current class name
  58841. * @returns the class name
  58842. */
  58843. getClassName(): string;
  58844. /**
  58845. * Gets the seed input component
  58846. */
  58847. readonly seed: NodeMaterialConnectionPoint;
  58848. /**
  58849. * Gets the output component
  58850. */
  58851. readonly output: NodeMaterialConnectionPoint;
  58852. protected _buildBlock(state: NodeMaterialBuildState): this;
  58853. }
  58854. }
  58855. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  58856. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58857. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58858. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58859. /**
  58860. * Block used to compute arc tangent of 2 values
  58861. */
  58862. export class ArcTan2Block extends NodeMaterialBlock {
  58863. /**
  58864. * Creates a new ArcTan2Block
  58865. * @param name defines the block name
  58866. */
  58867. constructor(name: string);
  58868. /**
  58869. * Gets the current class name
  58870. * @returns the class name
  58871. */
  58872. getClassName(): string;
  58873. /**
  58874. * Gets the x operand input component
  58875. */
  58876. readonly x: NodeMaterialConnectionPoint;
  58877. /**
  58878. * Gets the y operand input component
  58879. */
  58880. readonly y: NodeMaterialConnectionPoint;
  58881. /**
  58882. * Gets the output component
  58883. */
  58884. readonly output: NodeMaterialConnectionPoint;
  58885. protected _buildBlock(state: NodeMaterialBuildState): this;
  58886. }
  58887. }
  58888. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58889. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58890. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58891. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58892. /**
  58893. * Block used to smooth step a value
  58894. */
  58895. export class SmoothStepBlock extends NodeMaterialBlock {
  58896. /**
  58897. * Creates a new SmoothStepBlock
  58898. * @param name defines the block name
  58899. */
  58900. constructor(name: string);
  58901. /**
  58902. * Gets the current class name
  58903. * @returns the class name
  58904. */
  58905. getClassName(): string;
  58906. /**
  58907. * Gets the value operand input component
  58908. */
  58909. readonly value: NodeMaterialConnectionPoint;
  58910. /**
  58911. * Gets the first edge operand input component
  58912. */
  58913. readonly edge0: NodeMaterialConnectionPoint;
  58914. /**
  58915. * Gets the second edge operand input component
  58916. */
  58917. readonly edge1: NodeMaterialConnectionPoint;
  58918. /**
  58919. * Gets the output component
  58920. */
  58921. readonly output: NodeMaterialConnectionPoint;
  58922. protected _buildBlock(state: NodeMaterialBuildState): this;
  58923. }
  58924. }
  58925. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58926. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58927. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58928. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58929. /**
  58930. * Block used to get the reciprocal (1 / x) of a value
  58931. */
  58932. export class ReciprocalBlock extends NodeMaterialBlock {
  58933. /**
  58934. * Creates a new ReciprocalBlock
  58935. * @param name defines the block name
  58936. */
  58937. constructor(name: string);
  58938. /**
  58939. * Gets the current class name
  58940. * @returns the class name
  58941. */
  58942. getClassName(): string;
  58943. /**
  58944. * Gets the input component
  58945. */
  58946. readonly input: NodeMaterialConnectionPoint;
  58947. /**
  58948. * Gets the output component
  58949. */
  58950. readonly output: NodeMaterialConnectionPoint;
  58951. protected _buildBlock(state: NodeMaterialBuildState): this;
  58952. }
  58953. }
  58954. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58955. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58956. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58957. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58958. /**
  58959. * Block used to replace a color by another one
  58960. */
  58961. export class ReplaceColorBlock extends NodeMaterialBlock {
  58962. /**
  58963. * Creates a new ReplaceColorBlock
  58964. * @param name defines the block name
  58965. */
  58966. constructor(name: string);
  58967. /**
  58968. * Gets the current class name
  58969. * @returns the class name
  58970. */
  58971. getClassName(): string;
  58972. /**
  58973. * Gets the value input component
  58974. */
  58975. readonly value: NodeMaterialConnectionPoint;
  58976. /**
  58977. * Gets the reference input component
  58978. */
  58979. readonly reference: NodeMaterialConnectionPoint;
  58980. /**
  58981. * Gets the distance input component
  58982. */
  58983. readonly distance: NodeMaterialConnectionPoint;
  58984. /**
  58985. * Gets the replacement input component
  58986. */
  58987. readonly replacement: NodeMaterialConnectionPoint;
  58988. /**
  58989. * Gets the output component
  58990. */
  58991. readonly output: NodeMaterialConnectionPoint;
  58992. protected _buildBlock(state: NodeMaterialBuildState): this;
  58993. }
  58994. }
  58995. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58996. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58997. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58998. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58999. /**
  59000. * Block used to posterize a value
  59001. * @see https://en.wikipedia.org/wiki/Posterization
  59002. */
  59003. export class PosterizeBlock extends NodeMaterialBlock {
  59004. /**
  59005. * Creates a new PosterizeBlock
  59006. * @param name defines the block name
  59007. */
  59008. constructor(name: string);
  59009. /**
  59010. * Gets the current class name
  59011. * @returns the class name
  59012. */
  59013. getClassName(): string;
  59014. /**
  59015. * Gets the value input component
  59016. */
  59017. readonly value: NodeMaterialConnectionPoint;
  59018. /**
  59019. * Gets the steps input component
  59020. */
  59021. readonly steps: NodeMaterialConnectionPoint;
  59022. /**
  59023. * Gets the output component
  59024. */
  59025. readonly output: NodeMaterialConnectionPoint;
  59026. protected _buildBlock(state: NodeMaterialBuildState): this;
  59027. }
  59028. }
  59029. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  59030. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59031. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59032. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59033. import { Scene } from "babylonjs/scene";
  59034. /**
  59035. * Operations supported by the Wave block
  59036. */
  59037. export enum WaveBlockKind {
  59038. /** SawTooth */
  59039. SawTooth = 0,
  59040. /** Square */
  59041. Square = 1,
  59042. /** Triangle */
  59043. Triangle = 2
  59044. }
  59045. /**
  59046. * Block used to apply wave operation to floats
  59047. */
  59048. export class WaveBlock extends NodeMaterialBlock {
  59049. /**
  59050. * Gets or sets the kibnd of wave to be applied by the block
  59051. */
  59052. kind: WaveBlockKind;
  59053. /**
  59054. * Creates a new WaveBlock
  59055. * @param name defines the block name
  59056. */
  59057. constructor(name: string);
  59058. /**
  59059. * Gets the current class name
  59060. * @returns the class name
  59061. */
  59062. getClassName(): string;
  59063. /**
  59064. * Gets the input component
  59065. */
  59066. readonly input: NodeMaterialConnectionPoint;
  59067. /**
  59068. * Gets the output component
  59069. */
  59070. readonly output: NodeMaterialConnectionPoint;
  59071. protected _buildBlock(state: NodeMaterialBuildState): this;
  59072. serialize(): any;
  59073. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59074. }
  59075. }
  59076. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  59077. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59078. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59079. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59080. import { Color3 } from "babylonjs/Maths/math.color";
  59081. import { Scene } from "babylonjs/scene";
  59082. /**
  59083. * Class used to store a color step for the GradientBlock
  59084. */
  59085. export class GradientBlockColorStep {
  59086. /**
  59087. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59088. */
  59089. step: number;
  59090. /**
  59091. * Gets or sets the color associated with this step
  59092. */
  59093. color: Color3;
  59094. /**
  59095. * Creates a new GradientBlockColorStep
  59096. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59097. * @param color defines the color associated with this step
  59098. */
  59099. constructor(
  59100. /**
  59101. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59102. */
  59103. step: number,
  59104. /**
  59105. * Gets or sets the color associated with this step
  59106. */
  59107. color: Color3);
  59108. }
  59109. /**
  59110. * Block used to return a color from a gradient based on an input value between 0 and 1
  59111. */
  59112. export class GradientBlock extends NodeMaterialBlock {
  59113. /**
  59114. * Gets or sets the list of color steps
  59115. */
  59116. colorSteps: GradientBlockColorStep[];
  59117. /**
  59118. * Creates a new GradientBlock
  59119. * @param name defines the block name
  59120. */
  59121. constructor(name: string);
  59122. /**
  59123. * Gets the current class name
  59124. * @returns the class name
  59125. */
  59126. getClassName(): string;
  59127. /**
  59128. * Gets the gradient input component
  59129. */
  59130. readonly gradient: NodeMaterialConnectionPoint;
  59131. /**
  59132. * Gets the output component
  59133. */
  59134. readonly output: NodeMaterialConnectionPoint;
  59135. private _writeColorConstant;
  59136. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59137. serialize(): any;
  59138. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59139. protected _dumpPropertiesCode(): string;
  59140. }
  59141. }
  59142. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  59143. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59144. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59145. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59146. /**
  59147. * Block used to normalize lerp between 2 values
  59148. */
  59149. export class NLerpBlock extends NodeMaterialBlock {
  59150. /**
  59151. * Creates a new NLerpBlock
  59152. * @param name defines the block name
  59153. */
  59154. constructor(name: string);
  59155. /**
  59156. * Gets the current class name
  59157. * @returns the class name
  59158. */
  59159. getClassName(): string;
  59160. /**
  59161. * Gets the left operand input component
  59162. */
  59163. readonly left: NodeMaterialConnectionPoint;
  59164. /**
  59165. * Gets the right operand input component
  59166. */
  59167. readonly right: NodeMaterialConnectionPoint;
  59168. /**
  59169. * Gets the gradient operand input component
  59170. */
  59171. readonly gradient: NodeMaterialConnectionPoint;
  59172. /**
  59173. * Gets the output component
  59174. */
  59175. readonly output: NodeMaterialConnectionPoint;
  59176. protected _buildBlock(state: NodeMaterialBuildState): this;
  59177. }
  59178. }
  59179. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  59180. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59181. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59182. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59183. import { Scene } from "babylonjs/scene";
  59184. /**
  59185. * block used to Generate a Worley Noise 3D Noise Pattern
  59186. */
  59187. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59188. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59189. manhattanDistance: boolean;
  59190. /**
  59191. * Creates a new WorleyNoise3DBlock
  59192. * @param name defines the block name
  59193. */
  59194. constructor(name: string);
  59195. /**
  59196. * Gets the current class name
  59197. * @returns the class name
  59198. */
  59199. getClassName(): string;
  59200. /**
  59201. * Gets the position input component
  59202. */
  59203. readonly position: NodeMaterialConnectionPoint;
  59204. /**
  59205. * Gets the jitter input component
  59206. */
  59207. readonly jitter: NodeMaterialConnectionPoint;
  59208. /**
  59209. * Gets the output component
  59210. */
  59211. readonly output: NodeMaterialConnectionPoint;
  59212. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59213. /**
  59214. * Exposes the properties to the UI?
  59215. */
  59216. protected _dumpPropertiesCode(): string;
  59217. /**
  59218. * Exposes the properties to the Seralize?
  59219. */
  59220. serialize(): any;
  59221. /**
  59222. * Exposes the properties to the deseralize?
  59223. */
  59224. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59225. }
  59226. }
  59227. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  59228. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59229. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59230. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59231. /**
  59232. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59233. */
  59234. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59235. /**
  59236. * Creates a new SimplexPerlin3DBlock
  59237. * @param name defines the block name
  59238. */
  59239. constructor(name: string);
  59240. /**
  59241. * Gets the current class name
  59242. * @returns the class name
  59243. */
  59244. getClassName(): string;
  59245. /**
  59246. * Gets the position operand input component
  59247. */
  59248. readonly position: NodeMaterialConnectionPoint;
  59249. /**
  59250. * Gets the output component
  59251. */
  59252. readonly output: NodeMaterialConnectionPoint;
  59253. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59254. }
  59255. }
  59256. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  59257. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59258. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59259. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59260. /**
  59261. * Block used to blend normals
  59262. */
  59263. export class NormalBlendBlock extends NodeMaterialBlock {
  59264. /**
  59265. * Creates a new NormalBlendBlock
  59266. * @param name defines the block name
  59267. */
  59268. constructor(name: string);
  59269. /**
  59270. * Gets the current class name
  59271. * @returns the class name
  59272. */
  59273. getClassName(): string;
  59274. /**
  59275. * Gets the first input component
  59276. */
  59277. readonly input0: NodeMaterialConnectionPoint;
  59278. /**
  59279. * Gets the second input component
  59280. */
  59281. readonly input1: NodeMaterialConnectionPoint;
  59282. /**
  59283. * Gets the output component
  59284. */
  59285. readonly output: NodeMaterialConnectionPoint;
  59286. protected _buildBlock(state: NodeMaterialBuildState): this;
  59287. }
  59288. }
  59289. declare module "babylonjs/Materials/Node/Blocks/index" {
  59290. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  59291. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  59292. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  59293. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  59294. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  59295. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  59296. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  59297. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  59298. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  59299. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  59300. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  59301. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  59302. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  59303. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  59304. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  59305. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  59306. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  59307. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  59308. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  59309. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  59310. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  59311. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  59312. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  59313. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  59314. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  59315. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  59316. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  59317. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  59318. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  59319. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  59320. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  59321. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  59322. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  59323. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  59324. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  59325. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  59326. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  59327. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  59328. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  59329. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  59330. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  59331. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  59332. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  59333. }
  59334. declare module "babylonjs/Materials/Node/Optimizers/index" {
  59335. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59336. }
  59337. declare module "babylonjs/Materials/Node/index" {
  59338. export * from "babylonjs/Materials/Node/Enums/index";
  59339. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59340. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  59341. export * from "babylonjs/Materials/Node/nodeMaterial";
  59342. export * from "babylonjs/Materials/Node/Blocks/index";
  59343. export * from "babylonjs/Materials/Node/Optimizers/index";
  59344. }
  59345. declare module "babylonjs/Materials/effectRenderer" {
  59346. import { Nullable } from "babylonjs/types";
  59347. import { Texture } from "babylonjs/Materials/Textures/texture";
  59348. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59349. import { Viewport } from "babylonjs/Maths/math.viewport";
  59350. import { Observable } from "babylonjs/Misc/observable";
  59351. import { Effect } from "babylonjs/Materials/effect";
  59352. import "babylonjs/Engines/Extensions/engine.renderTarget";
  59353. import "babylonjs/Shaders/postprocess.vertex";
  59354. /**
  59355. * Effect Render Options
  59356. */
  59357. export interface IEffectRendererOptions {
  59358. /**
  59359. * Defines the vertices positions.
  59360. */
  59361. positions?: number[];
  59362. /**
  59363. * Defines the indices.
  59364. */
  59365. indices?: number[];
  59366. }
  59367. /**
  59368. * Helper class to render one or more effects
  59369. */
  59370. export class EffectRenderer {
  59371. private engine;
  59372. private static _DefaultOptions;
  59373. private _vertexBuffers;
  59374. private _indexBuffer;
  59375. private _ringBufferIndex;
  59376. private _ringScreenBuffer;
  59377. private _fullscreenViewport;
  59378. private _getNextFrameBuffer;
  59379. /**
  59380. * Creates an effect renderer
  59381. * @param engine the engine to use for rendering
  59382. * @param options defines the options of the effect renderer
  59383. */
  59384. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59385. /**
  59386. * Sets the current viewport in normalized coordinates 0-1
  59387. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59388. */
  59389. setViewport(viewport?: Viewport): void;
  59390. /**
  59391. * Binds the embedded attributes buffer to the effect.
  59392. * @param effect Defines the effect to bind the attributes for
  59393. */
  59394. bindBuffers(effect: Effect): void;
  59395. /**
  59396. * Sets the current effect wrapper to use during draw.
  59397. * The effect needs to be ready before calling this api.
  59398. * This also sets the default full screen position attribute.
  59399. * @param effectWrapper Defines the effect to draw with
  59400. */
  59401. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59402. /**
  59403. * Draws a full screen quad.
  59404. */
  59405. draw(): void;
  59406. /**
  59407. * renders one or more effects to a specified texture
  59408. * @param effectWrappers list of effects to renderer
  59409. * @param outputTexture texture to draw to, if null it will render to the screen
  59410. */
  59411. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  59412. /**
  59413. * Disposes of the effect renderer
  59414. */
  59415. dispose(): void;
  59416. }
  59417. /**
  59418. * Options to create an EffectWrapper
  59419. */
  59420. interface EffectWrapperCreationOptions {
  59421. /**
  59422. * Engine to use to create the effect
  59423. */
  59424. engine: ThinEngine;
  59425. /**
  59426. * Fragment shader for the effect
  59427. */
  59428. fragmentShader: string;
  59429. /**
  59430. * Vertex shader for the effect
  59431. */
  59432. vertexShader?: string;
  59433. /**
  59434. * Attributes to use in the shader
  59435. */
  59436. attributeNames?: Array<string>;
  59437. /**
  59438. * Uniforms to use in the shader
  59439. */
  59440. uniformNames?: Array<string>;
  59441. /**
  59442. * Texture sampler names to use in the shader
  59443. */
  59444. samplerNames?: Array<string>;
  59445. /**
  59446. * The friendly name of the effect displayed in Spector.
  59447. */
  59448. name?: string;
  59449. }
  59450. /**
  59451. * Wraps an effect to be used for rendering
  59452. */
  59453. export class EffectWrapper {
  59454. /**
  59455. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59456. */
  59457. onApplyObservable: Observable<{}>;
  59458. /**
  59459. * The underlying effect
  59460. */
  59461. effect: Effect;
  59462. /**
  59463. * Creates an effect to be renderer
  59464. * @param creationOptions options to create the effect
  59465. */
  59466. constructor(creationOptions: EffectWrapperCreationOptions);
  59467. /**
  59468. * Disposes of the effect wrapper
  59469. */
  59470. dispose(): void;
  59471. }
  59472. }
  59473. declare module "babylonjs/Materials/index" {
  59474. export * from "babylonjs/Materials/Background/index";
  59475. export * from "babylonjs/Materials/colorCurves";
  59476. export * from "babylonjs/Materials/iEffectFallbacks";
  59477. export * from "babylonjs/Materials/effectFallbacks";
  59478. export * from "babylonjs/Materials/effect";
  59479. export * from "babylonjs/Materials/fresnelParameters";
  59480. export * from "babylonjs/Materials/imageProcessingConfiguration";
  59481. export * from "babylonjs/Materials/material";
  59482. export * from "babylonjs/Materials/materialDefines";
  59483. export * from "babylonjs/Materials/materialHelper";
  59484. export * from "babylonjs/Materials/multiMaterial";
  59485. export * from "babylonjs/Materials/PBR/index";
  59486. export * from "babylonjs/Materials/pushMaterial";
  59487. export * from "babylonjs/Materials/shaderMaterial";
  59488. export * from "babylonjs/Materials/standardMaterial";
  59489. export * from "babylonjs/Materials/Textures/index";
  59490. export * from "babylonjs/Materials/uniformBuffer";
  59491. export * from "babylonjs/Materials/materialFlags";
  59492. export * from "babylonjs/Materials/Node/index";
  59493. export * from "babylonjs/Materials/effectRenderer";
  59494. }
  59495. declare module "babylonjs/Maths/index" {
  59496. export * from "babylonjs/Maths/math.scalar";
  59497. export * from "babylonjs/Maths/math";
  59498. export * from "babylonjs/Maths/sphericalPolynomial";
  59499. }
  59500. declare module "babylonjs/Misc/workerPool" {
  59501. import { IDisposable } from "babylonjs/scene";
  59502. /**
  59503. * Helper class to push actions to a pool of workers.
  59504. */
  59505. export class WorkerPool implements IDisposable {
  59506. private _workerInfos;
  59507. private _pendingActions;
  59508. /**
  59509. * Constructor
  59510. * @param workers Array of workers to use for actions
  59511. */
  59512. constructor(workers: Array<Worker>);
  59513. /**
  59514. * Terminates all workers and clears any pending actions.
  59515. */
  59516. dispose(): void;
  59517. /**
  59518. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59519. * pended until a worker has completed its action.
  59520. * @param action The action to perform. Call onComplete when the action is complete.
  59521. */
  59522. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59523. private _execute;
  59524. }
  59525. }
  59526. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  59527. import { IDisposable } from "babylonjs/scene";
  59528. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59529. /**
  59530. * Configuration for Draco compression
  59531. */
  59532. export interface IDracoCompressionConfiguration {
  59533. /**
  59534. * Configuration for the decoder.
  59535. */
  59536. decoder: {
  59537. /**
  59538. * The url to the WebAssembly module.
  59539. */
  59540. wasmUrl?: string;
  59541. /**
  59542. * The url to the WebAssembly binary.
  59543. */
  59544. wasmBinaryUrl?: string;
  59545. /**
  59546. * The url to the fallback JavaScript module.
  59547. */
  59548. fallbackUrl?: string;
  59549. };
  59550. }
  59551. /**
  59552. * Draco compression (https://google.github.io/draco/)
  59553. *
  59554. * This class wraps the Draco module.
  59555. *
  59556. * **Encoder**
  59557. *
  59558. * The encoder is not currently implemented.
  59559. *
  59560. * **Decoder**
  59561. *
  59562. * 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.
  59563. *
  59564. * To update the configuration, use the following code:
  59565. * ```javascript
  59566. * DracoCompression.Configuration = {
  59567. * decoder: {
  59568. * wasmUrl: "<url to the WebAssembly library>",
  59569. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  59570. * fallbackUrl: "<url to the fallback JavaScript library>",
  59571. * }
  59572. * };
  59573. * ```
  59574. *
  59575. * 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.
  59576. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  59577. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  59578. *
  59579. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  59580. * ```javascript
  59581. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  59582. * ```
  59583. *
  59584. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  59585. */
  59586. export class DracoCompression implements IDisposable {
  59587. private _workerPoolPromise?;
  59588. private _decoderModulePromise?;
  59589. /**
  59590. * The configuration. Defaults to the following urls:
  59591. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  59592. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  59593. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  59594. */
  59595. static Configuration: IDracoCompressionConfiguration;
  59596. /**
  59597. * Returns true if the decoder configuration is available.
  59598. */
  59599. static readonly DecoderAvailable: boolean;
  59600. /**
  59601. * Default number of workers to create when creating the draco compression object.
  59602. */
  59603. static DefaultNumWorkers: number;
  59604. private static GetDefaultNumWorkers;
  59605. private static _Default;
  59606. /**
  59607. * Default instance for the draco compression object.
  59608. */
  59609. static readonly Default: DracoCompression;
  59610. /**
  59611. * Constructor
  59612. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59613. */
  59614. constructor(numWorkers?: number);
  59615. /**
  59616. * Stop all async operations and release resources.
  59617. */
  59618. dispose(): void;
  59619. /**
  59620. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  59621. * @returns a promise that resolves when ready
  59622. */
  59623. whenReadyAsync(): Promise<void>;
  59624. /**
  59625. * Decode Draco compressed mesh data to vertex data.
  59626. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  59627. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  59628. * @returns A promise that resolves with the decoded vertex data
  59629. */
  59630. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  59631. [kind: string]: number;
  59632. }): Promise<VertexData>;
  59633. }
  59634. }
  59635. declare module "babylonjs/Meshes/Compression/index" {
  59636. export * from "babylonjs/Meshes/Compression/dracoCompression";
  59637. }
  59638. declare module "babylonjs/Meshes/csg" {
  59639. import { Nullable } from "babylonjs/types";
  59640. import { Scene } from "babylonjs/scene";
  59641. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59642. import { Mesh } from "babylonjs/Meshes/mesh";
  59643. import { Material } from "babylonjs/Materials/material";
  59644. /**
  59645. * Class for building Constructive Solid Geometry
  59646. */
  59647. export class CSG {
  59648. private polygons;
  59649. /**
  59650. * The world matrix
  59651. */
  59652. matrix: Matrix;
  59653. /**
  59654. * Stores the position
  59655. */
  59656. position: Vector3;
  59657. /**
  59658. * Stores the rotation
  59659. */
  59660. rotation: Vector3;
  59661. /**
  59662. * Stores the rotation quaternion
  59663. */
  59664. rotationQuaternion: Nullable<Quaternion>;
  59665. /**
  59666. * Stores the scaling vector
  59667. */
  59668. scaling: Vector3;
  59669. /**
  59670. * Convert the Mesh to CSG
  59671. * @param mesh The Mesh to convert to CSG
  59672. * @returns A new CSG from the Mesh
  59673. */
  59674. static FromMesh(mesh: Mesh): CSG;
  59675. /**
  59676. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  59677. * @param polygons Polygons used to construct a CSG solid
  59678. */
  59679. private static FromPolygons;
  59680. /**
  59681. * Clones, or makes a deep copy, of the CSG
  59682. * @returns A new CSG
  59683. */
  59684. clone(): CSG;
  59685. /**
  59686. * Unions this CSG with another CSG
  59687. * @param csg The CSG to union against this CSG
  59688. * @returns The unioned CSG
  59689. */
  59690. union(csg: CSG): CSG;
  59691. /**
  59692. * Unions this CSG with another CSG in place
  59693. * @param csg The CSG to union against this CSG
  59694. */
  59695. unionInPlace(csg: CSG): void;
  59696. /**
  59697. * Subtracts this CSG with another CSG
  59698. * @param csg The CSG to subtract against this CSG
  59699. * @returns A new CSG
  59700. */
  59701. subtract(csg: CSG): CSG;
  59702. /**
  59703. * Subtracts this CSG with another CSG in place
  59704. * @param csg The CSG to subtact against this CSG
  59705. */
  59706. subtractInPlace(csg: CSG): void;
  59707. /**
  59708. * Intersect this CSG with another CSG
  59709. * @param csg The CSG to intersect against this CSG
  59710. * @returns A new CSG
  59711. */
  59712. intersect(csg: CSG): CSG;
  59713. /**
  59714. * Intersects this CSG with another CSG in place
  59715. * @param csg The CSG to intersect against this CSG
  59716. */
  59717. intersectInPlace(csg: CSG): void;
  59718. /**
  59719. * Return a new CSG solid with solid and empty space switched. This solid is
  59720. * not modified.
  59721. * @returns A new CSG solid with solid and empty space switched
  59722. */
  59723. inverse(): CSG;
  59724. /**
  59725. * Inverses the CSG in place
  59726. */
  59727. inverseInPlace(): void;
  59728. /**
  59729. * This is used to keep meshes transformations so they can be restored
  59730. * when we build back a Babylon Mesh
  59731. * NB : All CSG operations are performed in world coordinates
  59732. * @param csg The CSG to copy the transform attributes from
  59733. * @returns This CSG
  59734. */
  59735. copyTransformAttributes(csg: CSG): CSG;
  59736. /**
  59737. * Build Raw mesh from CSG
  59738. * Coordinates here are in world space
  59739. * @param name The name of the mesh geometry
  59740. * @param scene The Scene
  59741. * @param keepSubMeshes Specifies if the submeshes should be kept
  59742. * @returns A new Mesh
  59743. */
  59744. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59745. /**
  59746. * Build Mesh from CSG taking material and transforms into account
  59747. * @param name The name of the Mesh
  59748. * @param material The material of the Mesh
  59749. * @param scene The Scene
  59750. * @param keepSubMeshes Specifies if submeshes should be kept
  59751. * @returns The new Mesh
  59752. */
  59753. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59754. }
  59755. }
  59756. declare module "babylonjs/Meshes/trailMesh" {
  59757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59758. import { Mesh } from "babylonjs/Meshes/mesh";
  59759. import { Scene } from "babylonjs/scene";
  59760. /**
  59761. * Class used to create a trail following a mesh
  59762. */
  59763. export class TrailMesh extends Mesh {
  59764. private _generator;
  59765. private _autoStart;
  59766. private _running;
  59767. private _diameter;
  59768. private _length;
  59769. private _sectionPolygonPointsCount;
  59770. private _sectionVectors;
  59771. private _sectionNormalVectors;
  59772. private _beforeRenderObserver;
  59773. /**
  59774. * @constructor
  59775. * @param name The value used by scene.getMeshByName() to do a lookup.
  59776. * @param generator The mesh to generate a trail.
  59777. * @param scene The scene to add this mesh to.
  59778. * @param diameter Diameter of trailing mesh. Default is 1.
  59779. * @param length Length of trailing mesh. Default is 60.
  59780. * @param autoStart Automatically start trailing mesh. Default true.
  59781. */
  59782. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  59783. /**
  59784. * "TrailMesh"
  59785. * @returns "TrailMesh"
  59786. */
  59787. getClassName(): string;
  59788. private _createMesh;
  59789. /**
  59790. * Start trailing mesh.
  59791. */
  59792. start(): void;
  59793. /**
  59794. * Stop trailing mesh.
  59795. */
  59796. stop(): void;
  59797. /**
  59798. * Update trailing mesh geometry.
  59799. */
  59800. update(): void;
  59801. /**
  59802. * Returns a new TrailMesh object.
  59803. * @param name is a string, the name given to the new mesh
  59804. * @param newGenerator use new generator object for cloned trail mesh
  59805. * @returns a new mesh
  59806. */
  59807. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  59808. /**
  59809. * Serializes this trail mesh
  59810. * @param serializationObject object to write serialization to
  59811. */
  59812. serialize(serializationObject: any): void;
  59813. /**
  59814. * Parses a serialized trail mesh
  59815. * @param parsedMesh the serialized mesh
  59816. * @param scene the scene to create the trail mesh in
  59817. * @returns the created trail mesh
  59818. */
  59819. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  59820. }
  59821. }
  59822. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  59823. import { Nullable } from "babylonjs/types";
  59824. import { Scene } from "babylonjs/scene";
  59825. import { Vector4 } from "babylonjs/Maths/math.vector";
  59826. import { Color4 } from "babylonjs/Maths/math.color";
  59827. import { Mesh } from "babylonjs/Meshes/mesh";
  59828. /**
  59829. * Class containing static functions to help procedurally build meshes
  59830. */
  59831. export class TiledBoxBuilder {
  59832. /**
  59833. * Creates a box mesh
  59834. * 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)
  59835. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59837. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59839. * @param name defines the name of the mesh
  59840. * @param options defines the options used to create the mesh
  59841. * @param scene defines the hosting scene
  59842. * @returns the box mesh
  59843. */
  59844. static CreateTiledBox(name: string, options: {
  59845. pattern?: number;
  59846. width?: number;
  59847. height?: number;
  59848. depth?: number;
  59849. tileSize?: number;
  59850. tileWidth?: number;
  59851. tileHeight?: number;
  59852. alignHorizontal?: number;
  59853. alignVertical?: number;
  59854. faceUV?: Vector4[];
  59855. faceColors?: Color4[];
  59856. sideOrientation?: number;
  59857. updatable?: boolean;
  59858. }, scene?: Nullable<Scene>): Mesh;
  59859. }
  59860. }
  59861. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  59862. import { Vector4 } from "babylonjs/Maths/math.vector";
  59863. import { Mesh } from "babylonjs/Meshes/mesh";
  59864. /**
  59865. * Class containing static functions to help procedurally build meshes
  59866. */
  59867. export class TorusKnotBuilder {
  59868. /**
  59869. * Creates a torus knot mesh
  59870. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59871. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59872. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59873. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59875. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59877. * @param name defines the name of the mesh
  59878. * @param options defines the options used to create the mesh
  59879. * @param scene defines the hosting scene
  59880. * @returns the torus knot mesh
  59881. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59882. */
  59883. static CreateTorusKnot(name: string, options: {
  59884. radius?: number;
  59885. tube?: number;
  59886. radialSegments?: number;
  59887. tubularSegments?: number;
  59888. p?: number;
  59889. q?: number;
  59890. updatable?: boolean;
  59891. sideOrientation?: number;
  59892. frontUVs?: Vector4;
  59893. backUVs?: Vector4;
  59894. }, scene: any): Mesh;
  59895. }
  59896. }
  59897. declare module "babylonjs/Meshes/polygonMesh" {
  59898. import { Scene } from "babylonjs/scene";
  59899. import { Vector2 } from "babylonjs/Maths/math.vector";
  59900. import { Mesh } from "babylonjs/Meshes/mesh";
  59901. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59902. import { Path2 } from "babylonjs/Maths/math.path";
  59903. /**
  59904. * Polygon
  59905. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  59906. */
  59907. export class Polygon {
  59908. /**
  59909. * Creates a rectangle
  59910. * @param xmin bottom X coord
  59911. * @param ymin bottom Y coord
  59912. * @param xmax top X coord
  59913. * @param ymax top Y coord
  59914. * @returns points that make the resulting rectation
  59915. */
  59916. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  59917. /**
  59918. * Creates a circle
  59919. * @param radius radius of circle
  59920. * @param cx scale in x
  59921. * @param cy scale in y
  59922. * @param numberOfSides number of sides that make up the circle
  59923. * @returns points that make the resulting circle
  59924. */
  59925. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  59926. /**
  59927. * Creates a polygon from input string
  59928. * @param input Input polygon data
  59929. * @returns the parsed points
  59930. */
  59931. static Parse(input: string): Vector2[];
  59932. /**
  59933. * Starts building a polygon from x and y coordinates
  59934. * @param x x coordinate
  59935. * @param y y coordinate
  59936. * @returns the started path2
  59937. */
  59938. static StartingAt(x: number, y: number): Path2;
  59939. }
  59940. /**
  59941. * Builds a polygon
  59942. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  59943. */
  59944. export class PolygonMeshBuilder {
  59945. private _points;
  59946. private _outlinepoints;
  59947. private _holes;
  59948. private _name;
  59949. private _scene;
  59950. private _epoints;
  59951. private _eholes;
  59952. private _addToepoint;
  59953. /**
  59954. * Babylon reference to the earcut plugin.
  59955. */
  59956. bjsEarcut: any;
  59957. /**
  59958. * Creates a PolygonMeshBuilder
  59959. * @param name name of the builder
  59960. * @param contours Path of the polygon
  59961. * @param scene scene to add to when creating the mesh
  59962. * @param earcutInjection can be used to inject your own earcut reference
  59963. */
  59964. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  59965. /**
  59966. * Adds a whole within the polygon
  59967. * @param hole Array of points defining the hole
  59968. * @returns this
  59969. */
  59970. addHole(hole: Vector2[]): PolygonMeshBuilder;
  59971. /**
  59972. * Creates the polygon
  59973. * @param updatable If the mesh should be updatable
  59974. * @param depth The depth of the mesh created
  59975. * @returns the created mesh
  59976. */
  59977. build(updatable?: boolean, depth?: number): Mesh;
  59978. /**
  59979. * Creates the polygon
  59980. * @param depth The depth of the mesh created
  59981. * @returns the created VertexData
  59982. */
  59983. buildVertexData(depth?: number): VertexData;
  59984. /**
  59985. * Adds a side to the polygon
  59986. * @param positions points that make the polygon
  59987. * @param normals normals of the polygon
  59988. * @param uvs uvs of the polygon
  59989. * @param indices indices of the polygon
  59990. * @param bounds bounds of the polygon
  59991. * @param points points of the polygon
  59992. * @param depth depth of the polygon
  59993. * @param flip flip of the polygon
  59994. */
  59995. private addSide;
  59996. }
  59997. }
  59998. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59999. import { Scene } from "babylonjs/scene";
  60000. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60001. import { Color4 } from "babylonjs/Maths/math.color";
  60002. import { Mesh } from "babylonjs/Meshes/mesh";
  60003. import { Nullable } from "babylonjs/types";
  60004. /**
  60005. * Class containing static functions to help procedurally build meshes
  60006. */
  60007. export class PolygonBuilder {
  60008. /**
  60009. * Creates a polygon mesh
  60010. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60011. * * 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
  60012. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60015. * * Remember you can only change the shape positions, not their number when updating a polygon
  60016. * @param name defines the name of the mesh
  60017. * @param options defines the options used to create the mesh
  60018. * @param scene defines the hosting scene
  60019. * @param earcutInjection can be used to inject your own earcut reference
  60020. * @returns the polygon mesh
  60021. */
  60022. static CreatePolygon(name: string, options: {
  60023. shape: Vector3[];
  60024. holes?: Vector3[][];
  60025. depth?: number;
  60026. faceUV?: Vector4[];
  60027. faceColors?: Color4[];
  60028. updatable?: boolean;
  60029. sideOrientation?: number;
  60030. frontUVs?: Vector4;
  60031. backUVs?: Vector4;
  60032. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60033. /**
  60034. * Creates an extruded polygon mesh, with depth in the Y direction.
  60035. * * 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)
  60036. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60037. * @param name defines the name of the mesh
  60038. * @param options defines the options used to create the mesh
  60039. * @param scene defines the hosting scene
  60040. * @param earcutInjection can be used to inject your own earcut reference
  60041. * @returns the polygon mesh
  60042. */
  60043. static ExtrudePolygon(name: string, options: {
  60044. shape: Vector3[];
  60045. holes?: Vector3[][];
  60046. depth?: number;
  60047. faceUV?: Vector4[];
  60048. faceColors?: Color4[];
  60049. updatable?: boolean;
  60050. sideOrientation?: number;
  60051. frontUVs?: Vector4;
  60052. backUVs?: Vector4;
  60053. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60054. }
  60055. }
  60056. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  60057. import { Scene } from "babylonjs/scene";
  60058. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60059. import { Mesh } from "babylonjs/Meshes/mesh";
  60060. import { Nullable } from "babylonjs/types";
  60061. /**
  60062. * Class containing static functions to help procedurally build meshes
  60063. */
  60064. export class LatheBuilder {
  60065. /**
  60066. * Creates lathe mesh.
  60067. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60068. * * 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
  60069. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60070. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60071. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60072. * * 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
  60073. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60074. * * 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
  60075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60076. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60077. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60079. * @param name defines the name of the mesh
  60080. * @param options defines the options used to create the mesh
  60081. * @param scene defines the hosting scene
  60082. * @returns the lathe mesh
  60083. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60084. */
  60085. static CreateLathe(name: string, options: {
  60086. shape: Vector3[];
  60087. radius?: number;
  60088. tessellation?: number;
  60089. clip?: number;
  60090. arc?: number;
  60091. closed?: boolean;
  60092. updatable?: boolean;
  60093. sideOrientation?: number;
  60094. frontUVs?: Vector4;
  60095. backUVs?: Vector4;
  60096. cap?: number;
  60097. invertUV?: boolean;
  60098. }, scene?: Nullable<Scene>): Mesh;
  60099. }
  60100. }
  60101. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  60102. import { Nullable } from "babylonjs/types";
  60103. import { Scene } from "babylonjs/scene";
  60104. import { Vector4 } from "babylonjs/Maths/math.vector";
  60105. import { Mesh } from "babylonjs/Meshes/mesh";
  60106. /**
  60107. * Class containing static functions to help procedurally build meshes
  60108. */
  60109. export class TiledPlaneBuilder {
  60110. /**
  60111. * Creates a tiled plane mesh
  60112. * * The parameter `pattern` will, depending on value, do nothing or
  60113. * * * flip (reflect about central vertical) alternate tiles across and up
  60114. * * * flip every tile on alternate rows
  60115. * * * rotate (180 degs) alternate tiles across and up
  60116. * * * rotate every tile on alternate rows
  60117. * * * flip and rotate alternate tiles across and up
  60118. * * * flip and rotate every tile on alternate rows
  60119. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60120. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60121. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60122. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60123. * * 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)
  60124. * * 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)
  60125. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60126. * @param name defines the name of the mesh
  60127. * @param options defines the options used to create the mesh
  60128. * @param scene defines the hosting scene
  60129. * @returns the box mesh
  60130. */
  60131. static CreateTiledPlane(name: string, options: {
  60132. pattern?: number;
  60133. tileSize?: number;
  60134. tileWidth?: number;
  60135. tileHeight?: number;
  60136. size?: number;
  60137. width?: number;
  60138. height?: number;
  60139. alignHorizontal?: number;
  60140. alignVertical?: number;
  60141. sideOrientation?: number;
  60142. frontUVs?: Vector4;
  60143. backUVs?: Vector4;
  60144. updatable?: boolean;
  60145. }, scene?: Nullable<Scene>): Mesh;
  60146. }
  60147. }
  60148. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  60149. import { Nullable } from "babylonjs/types";
  60150. import { Scene } from "babylonjs/scene";
  60151. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60152. import { Mesh } from "babylonjs/Meshes/mesh";
  60153. /**
  60154. * Class containing static functions to help procedurally build meshes
  60155. */
  60156. export class TubeBuilder {
  60157. /**
  60158. * Creates a tube mesh.
  60159. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60160. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60161. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60162. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60163. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60164. * * 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)
  60165. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60166. * * 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
  60167. * * 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
  60168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60169. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60170. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60172. * @param name defines the name of the mesh
  60173. * @param options defines the options used to create the mesh
  60174. * @param scene defines the hosting scene
  60175. * @returns the tube mesh
  60176. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60177. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60178. */
  60179. static CreateTube(name: string, options: {
  60180. path: Vector3[];
  60181. radius?: number;
  60182. tessellation?: number;
  60183. radiusFunction?: {
  60184. (i: number, distance: number): number;
  60185. };
  60186. cap?: number;
  60187. arc?: number;
  60188. updatable?: boolean;
  60189. sideOrientation?: number;
  60190. frontUVs?: Vector4;
  60191. backUVs?: Vector4;
  60192. instance?: Mesh;
  60193. invertUV?: boolean;
  60194. }, scene?: Nullable<Scene>): Mesh;
  60195. }
  60196. }
  60197. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  60198. import { Scene } from "babylonjs/scene";
  60199. import { Vector4 } from "babylonjs/Maths/math.vector";
  60200. import { Mesh } from "babylonjs/Meshes/mesh";
  60201. import { Nullable } from "babylonjs/types";
  60202. /**
  60203. * Class containing static functions to help procedurally build meshes
  60204. */
  60205. export class IcoSphereBuilder {
  60206. /**
  60207. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60208. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60209. * * 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`)
  60210. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60211. * * 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
  60212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60213. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60215. * @param name defines the name of the mesh
  60216. * @param options defines the options used to create the mesh
  60217. * @param scene defines the hosting scene
  60218. * @returns the icosahedron mesh
  60219. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60220. */
  60221. static CreateIcoSphere(name: string, options: {
  60222. radius?: number;
  60223. radiusX?: number;
  60224. radiusY?: number;
  60225. radiusZ?: number;
  60226. flat?: boolean;
  60227. subdivisions?: number;
  60228. sideOrientation?: number;
  60229. frontUVs?: Vector4;
  60230. backUVs?: Vector4;
  60231. updatable?: boolean;
  60232. }, scene?: Nullable<Scene>): Mesh;
  60233. }
  60234. }
  60235. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  60236. import { Vector3 } from "babylonjs/Maths/math.vector";
  60237. import { Mesh } from "babylonjs/Meshes/mesh";
  60238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60239. /**
  60240. * Class containing static functions to help procedurally build meshes
  60241. */
  60242. export class DecalBuilder {
  60243. /**
  60244. * Creates a decal mesh.
  60245. * 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
  60246. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60247. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60248. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60249. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60250. * @param name defines the name of the mesh
  60251. * @param sourceMesh defines the mesh where the decal must be applied
  60252. * @param options defines the options used to create the mesh
  60253. * @param scene defines the hosting scene
  60254. * @returns the decal mesh
  60255. * @see https://doc.babylonjs.com/how_to/decals
  60256. */
  60257. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60258. position?: Vector3;
  60259. normal?: Vector3;
  60260. size?: Vector3;
  60261. angle?: number;
  60262. }): Mesh;
  60263. }
  60264. }
  60265. declare module "babylonjs/Meshes/meshBuilder" {
  60266. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  60267. import { Nullable } from "babylonjs/types";
  60268. import { Scene } from "babylonjs/scene";
  60269. import { Mesh } from "babylonjs/Meshes/mesh";
  60270. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  60271. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  60272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60273. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60274. import { Plane } from "babylonjs/Maths/math.plane";
  60275. /**
  60276. * Class containing static functions to help procedurally build meshes
  60277. */
  60278. export class MeshBuilder {
  60279. /**
  60280. * Creates a box mesh
  60281. * * The parameter `size` sets the size (float) of each box side (default 1)
  60282. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60283. * * 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)
  60284. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60285. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60286. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60288. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60289. * @param name defines the name of the mesh
  60290. * @param options defines the options used to create the mesh
  60291. * @param scene defines the hosting scene
  60292. * @returns the box mesh
  60293. */
  60294. static CreateBox(name: string, options: {
  60295. size?: number;
  60296. width?: number;
  60297. height?: number;
  60298. depth?: number;
  60299. faceUV?: Vector4[];
  60300. faceColors?: Color4[];
  60301. sideOrientation?: number;
  60302. frontUVs?: Vector4;
  60303. backUVs?: Vector4;
  60304. updatable?: boolean;
  60305. }, scene?: Nullable<Scene>): Mesh;
  60306. /**
  60307. * Creates a tiled box mesh
  60308. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60310. * @param name defines the name of the mesh
  60311. * @param options defines the options used to create the mesh
  60312. * @param scene defines the hosting scene
  60313. * @returns the tiled box mesh
  60314. */
  60315. static CreateTiledBox(name: string, options: {
  60316. pattern?: number;
  60317. size?: number;
  60318. width?: number;
  60319. height?: number;
  60320. depth: number;
  60321. tileSize?: number;
  60322. tileWidth?: number;
  60323. tileHeight?: number;
  60324. faceUV?: Vector4[];
  60325. faceColors?: Color4[];
  60326. alignHorizontal?: number;
  60327. alignVertical?: number;
  60328. sideOrientation?: number;
  60329. updatable?: boolean;
  60330. }, scene?: Nullable<Scene>): Mesh;
  60331. /**
  60332. * Creates a sphere mesh
  60333. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60334. * * 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`)
  60335. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60336. * * 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
  60337. * * 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)
  60338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60339. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60341. * @param name defines the name of the mesh
  60342. * @param options defines the options used to create the mesh
  60343. * @param scene defines the hosting scene
  60344. * @returns the sphere mesh
  60345. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  60346. */
  60347. static CreateSphere(name: string, options: {
  60348. segments?: number;
  60349. diameter?: number;
  60350. diameterX?: number;
  60351. diameterY?: number;
  60352. diameterZ?: number;
  60353. arc?: number;
  60354. slice?: number;
  60355. sideOrientation?: number;
  60356. frontUVs?: Vector4;
  60357. backUVs?: Vector4;
  60358. updatable?: boolean;
  60359. }, scene?: Nullable<Scene>): Mesh;
  60360. /**
  60361. * Creates a plane polygonal mesh. By default, this is a disc
  60362. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  60363. * * 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
  60364. * * 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
  60365. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60366. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60368. * @param name defines the name of the mesh
  60369. * @param options defines the options used to create the mesh
  60370. * @param scene defines the hosting scene
  60371. * @returns the plane polygonal mesh
  60372. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  60373. */
  60374. static CreateDisc(name: string, options: {
  60375. radius?: number;
  60376. tessellation?: number;
  60377. arc?: number;
  60378. updatable?: boolean;
  60379. sideOrientation?: number;
  60380. frontUVs?: Vector4;
  60381. backUVs?: Vector4;
  60382. }, scene?: Nullable<Scene>): Mesh;
  60383. /**
  60384. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60385. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60386. * * 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`)
  60387. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60388. * * 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
  60389. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60390. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60392. * @param name defines the name of the mesh
  60393. * @param options defines the options used to create the mesh
  60394. * @param scene defines the hosting scene
  60395. * @returns the icosahedron mesh
  60396. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60397. */
  60398. static CreateIcoSphere(name: string, options: {
  60399. radius?: number;
  60400. radiusX?: number;
  60401. radiusY?: number;
  60402. radiusZ?: number;
  60403. flat?: boolean;
  60404. subdivisions?: number;
  60405. sideOrientation?: number;
  60406. frontUVs?: Vector4;
  60407. backUVs?: Vector4;
  60408. updatable?: boolean;
  60409. }, scene?: Nullable<Scene>): Mesh;
  60410. /**
  60411. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60412. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60413. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60414. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60415. * * 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
  60416. * * 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
  60417. * * 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
  60418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60419. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60420. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60421. * * 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
  60422. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60423. * * 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
  60424. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60426. * @param name defines the name of the mesh
  60427. * @param options defines the options used to create the mesh
  60428. * @param scene defines the hosting scene
  60429. * @returns the ribbon mesh
  60430. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60431. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60432. */
  60433. static CreateRibbon(name: string, options: {
  60434. pathArray: Vector3[][];
  60435. closeArray?: boolean;
  60436. closePath?: boolean;
  60437. offset?: number;
  60438. updatable?: boolean;
  60439. sideOrientation?: number;
  60440. frontUVs?: Vector4;
  60441. backUVs?: Vector4;
  60442. instance?: Mesh;
  60443. invertUV?: boolean;
  60444. uvs?: Vector2[];
  60445. colors?: Color4[];
  60446. }, scene?: Nullable<Scene>): Mesh;
  60447. /**
  60448. * Creates a cylinder or a cone mesh
  60449. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  60450. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  60451. * * 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.
  60452. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  60453. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  60454. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  60455. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  60456. * * 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).
  60457. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  60458. * * 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).
  60459. * * 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
  60460. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  60461. * * 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
  60462. * * 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.
  60463. * * If `enclose` is false, a ring surface is one element.
  60464. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  60465. * * 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
  60466. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60467. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60469. * @param name defines the name of the mesh
  60470. * @param options defines the options used to create the mesh
  60471. * @param scene defines the hosting scene
  60472. * @returns the cylinder mesh
  60473. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  60474. */
  60475. static CreateCylinder(name: string, options: {
  60476. height?: number;
  60477. diameterTop?: number;
  60478. diameterBottom?: number;
  60479. diameter?: number;
  60480. tessellation?: number;
  60481. subdivisions?: number;
  60482. arc?: number;
  60483. faceColors?: Color4[];
  60484. faceUV?: Vector4[];
  60485. updatable?: boolean;
  60486. hasRings?: boolean;
  60487. enclose?: boolean;
  60488. cap?: number;
  60489. sideOrientation?: number;
  60490. frontUVs?: Vector4;
  60491. backUVs?: Vector4;
  60492. }, scene?: Nullable<Scene>): Mesh;
  60493. /**
  60494. * Creates a torus mesh
  60495. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  60496. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  60497. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  60498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60501. * @param name defines the name of the mesh
  60502. * @param options defines the options used to create the mesh
  60503. * @param scene defines the hosting scene
  60504. * @returns the torus mesh
  60505. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  60506. */
  60507. static CreateTorus(name: string, options: {
  60508. diameter?: number;
  60509. thickness?: number;
  60510. tessellation?: number;
  60511. updatable?: boolean;
  60512. sideOrientation?: number;
  60513. frontUVs?: Vector4;
  60514. backUVs?: Vector4;
  60515. }, scene?: Nullable<Scene>): Mesh;
  60516. /**
  60517. * Creates a torus knot mesh
  60518. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60519. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60520. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60521. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60522. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60523. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60525. * @param name defines the name of the mesh
  60526. * @param options defines the options used to create the mesh
  60527. * @param scene defines the hosting scene
  60528. * @returns the torus knot mesh
  60529. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60530. */
  60531. static CreateTorusKnot(name: string, options: {
  60532. radius?: number;
  60533. tube?: number;
  60534. radialSegments?: number;
  60535. tubularSegments?: number;
  60536. p?: number;
  60537. q?: number;
  60538. updatable?: boolean;
  60539. sideOrientation?: number;
  60540. frontUVs?: Vector4;
  60541. backUVs?: Vector4;
  60542. }, scene?: Nullable<Scene>): Mesh;
  60543. /**
  60544. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  60545. * * 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
  60546. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  60547. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  60548. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  60549. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  60550. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  60551. * * 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
  60552. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  60553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60554. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  60555. * @param name defines the name of the new line system
  60556. * @param options defines the options used to create the line system
  60557. * @param scene defines the hosting scene
  60558. * @returns a new line system mesh
  60559. */
  60560. static CreateLineSystem(name: string, options: {
  60561. lines: Vector3[][];
  60562. updatable?: boolean;
  60563. instance?: Nullable<LinesMesh>;
  60564. colors?: Nullable<Color4[][]>;
  60565. useVertexAlpha?: boolean;
  60566. }, scene: Nullable<Scene>): LinesMesh;
  60567. /**
  60568. * Creates a line mesh
  60569. * 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
  60570. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60571. * * The parameter `points` is an array successive Vector3
  60572. * * 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
  60573. * * The optional parameter `colors` is an array of successive Color4, one per line point
  60574. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  60575. * * When updating an instance, remember that only point positions can change, not the number of points
  60576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60577. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  60578. * @param name defines the name of the new line system
  60579. * @param options defines the options used to create the line system
  60580. * @param scene defines the hosting scene
  60581. * @returns a new line mesh
  60582. */
  60583. static CreateLines(name: string, options: {
  60584. points: Vector3[];
  60585. updatable?: boolean;
  60586. instance?: Nullable<LinesMesh>;
  60587. colors?: Color4[];
  60588. useVertexAlpha?: boolean;
  60589. }, scene?: Nullable<Scene>): LinesMesh;
  60590. /**
  60591. * Creates a dashed line mesh
  60592. * * 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
  60593. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60594. * * The parameter `points` is an array successive Vector3
  60595. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  60596. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  60597. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  60598. * * 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
  60599. * * When updating an instance, remember that only point positions can change, not the number of points
  60600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60601. * @param name defines the name of the mesh
  60602. * @param options defines the options used to create the mesh
  60603. * @param scene defines the hosting scene
  60604. * @returns the dashed line mesh
  60605. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  60606. */
  60607. static CreateDashedLines(name: string, options: {
  60608. points: Vector3[];
  60609. dashSize?: number;
  60610. gapSize?: number;
  60611. dashNb?: number;
  60612. updatable?: boolean;
  60613. instance?: LinesMesh;
  60614. }, scene?: Nullable<Scene>): LinesMesh;
  60615. /**
  60616. * 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.
  60617. * * 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.
  60618. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60619. * * 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.
  60620. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60621. * * 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
  60622. * * 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
  60623. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60628. * @param name defines the name of the mesh
  60629. * @param options defines the options used to create the mesh
  60630. * @param scene defines the hosting scene
  60631. * @returns the extruded shape mesh
  60632. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60633. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60634. */
  60635. static ExtrudeShape(name: string, options: {
  60636. shape: Vector3[];
  60637. path: Vector3[];
  60638. scale?: number;
  60639. rotation?: number;
  60640. cap?: number;
  60641. updatable?: boolean;
  60642. sideOrientation?: number;
  60643. frontUVs?: Vector4;
  60644. backUVs?: Vector4;
  60645. instance?: Mesh;
  60646. invertUV?: boolean;
  60647. }, scene?: Nullable<Scene>): Mesh;
  60648. /**
  60649. * Creates an custom extruded shape mesh.
  60650. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60651. * * 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.
  60652. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60653. * * 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
  60654. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60655. * * 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
  60656. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60657. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60658. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60659. * * 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
  60660. * * 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
  60661. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60663. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60664. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60666. * @param name defines the name of the mesh
  60667. * @param options defines the options used to create the mesh
  60668. * @param scene defines the hosting scene
  60669. * @returns the custom extruded shape mesh
  60670. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60671. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60672. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60673. */
  60674. static ExtrudeShapeCustom(name: string, options: {
  60675. shape: Vector3[];
  60676. path: Vector3[];
  60677. scaleFunction?: any;
  60678. rotationFunction?: any;
  60679. ribbonCloseArray?: boolean;
  60680. ribbonClosePath?: boolean;
  60681. cap?: number;
  60682. updatable?: boolean;
  60683. sideOrientation?: number;
  60684. frontUVs?: Vector4;
  60685. backUVs?: Vector4;
  60686. instance?: Mesh;
  60687. invertUV?: boolean;
  60688. }, scene?: Nullable<Scene>): Mesh;
  60689. /**
  60690. * Creates lathe mesh.
  60691. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60692. * * 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
  60693. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60694. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60695. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60696. * * 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
  60697. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60698. * * 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
  60699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60700. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60701. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60703. * @param name defines the name of the mesh
  60704. * @param options defines the options used to create the mesh
  60705. * @param scene defines the hosting scene
  60706. * @returns the lathe mesh
  60707. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60708. */
  60709. static CreateLathe(name: string, options: {
  60710. shape: Vector3[];
  60711. radius?: number;
  60712. tessellation?: number;
  60713. clip?: number;
  60714. arc?: number;
  60715. closed?: boolean;
  60716. updatable?: boolean;
  60717. sideOrientation?: number;
  60718. frontUVs?: Vector4;
  60719. backUVs?: Vector4;
  60720. cap?: number;
  60721. invertUV?: boolean;
  60722. }, scene?: Nullable<Scene>): Mesh;
  60723. /**
  60724. * Creates a tiled plane mesh
  60725. * * You can set a limited pattern arrangement with the tiles
  60726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60727. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60729. * @param name defines the name of the mesh
  60730. * @param options defines the options used to create the mesh
  60731. * @param scene defines the hosting scene
  60732. * @returns the plane mesh
  60733. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60734. */
  60735. static CreateTiledPlane(name: string, options: {
  60736. pattern?: number;
  60737. tileSize?: number;
  60738. tileWidth?: number;
  60739. tileHeight?: number;
  60740. size?: number;
  60741. width?: number;
  60742. height?: number;
  60743. alignHorizontal?: number;
  60744. alignVertical?: number;
  60745. sideOrientation?: number;
  60746. frontUVs?: Vector4;
  60747. backUVs?: Vector4;
  60748. updatable?: boolean;
  60749. }, scene?: Nullable<Scene>): Mesh;
  60750. /**
  60751. * Creates a plane mesh
  60752. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  60753. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  60754. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  60755. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60756. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60758. * @param name defines the name of the mesh
  60759. * @param options defines the options used to create the mesh
  60760. * @param scene defines the hosting scene
  60761. * @returns the plane mesh
  60762. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60763. */
  60764. static CreatePlane(name: string, options: {
  60765. size?: number;
  60766. width?: number;
  60767. height?: number;
  60768. sideOrientation?: number;
  60769. frontUVs?: Vector4;
  60770. backUVs?: Vector4;
  60771. updatable?: boolean;
  60772. sourcePlane?: Plane;
  60773. }, scene?: Nullable<Scene>): Mesh;
  60774. /**
  60775. * Creates a ground mesh
  60776. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  60777. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  60778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60779. * @param name defines the name of the mesh
  60780. * @param options defines the options used to create the mesh
  60781. * @param scene defines the hosting scene
  60782. * @returns the ground mesh
  60783. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  60784. */
  60785. static CreateGround(name: string, options: {
  60786. width?: number;
  60787. height?: number;
  60788. subdivisions?: number;
  60789. subdivisionsX?: number;
  60790. subdivisionsY?: number;
  60791. updatable?: boolean;
  60792. }, scene?: Nullable<Scene>): Mesh;
  60793. /**
  60794. * Creates a tiled ground mesh
  60795. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  60796. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  60797. * * 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
  60798. * * 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
  60799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60800. * @param name defines the name of the mesh
  60801. * @param options defines the options used to create the mesh
  60802. * @param scene defines the hosting scene
  60803. * @returns the tiled ground mesh
  60804. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  60805. */
  60806. static CreateTiledGround(name: string, options: {
  60807. xmin: number;
  60808. zmin: number;
  60809. xmax: number;
  60810. zmax: number;
  60811. subdivisions?: {
  60812. w: number;
  60813. h: number;
  60814. };
  60815. precision?: {
  60816. w: number;
  60817. h: number;
  60818. };
  60819. updatable?: boolean;
  60820. }, scene?: Nullable<Scene>): Mesh;
  60821. /**
  60822. * Creates a ground mesh from a height map
  60823. * * The parameter `url` sets the URL of the height map image resource.
  60824. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  60825. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  60826. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  60827. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  60828. * * 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.
  60829. * * 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).
  60830. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  60831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60832. * @param name defines the name of the mesh
  60833. * @param url defines the url to the height map
  60834. * @param options defines the options used to create the mesh
  60835. * @param scene defines the hosting scene
  60836. * @returns the ground mesh
  60837. * @see https://doc.babylonjs.com/babylon101/height_map
  60838. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  60839. */
  60840. static CreateGroundFromHeightMap(name: string, url: string, options: {
  60841. width?: number;
  60842. height?: number;
  60843. subdivisions?: number;
  60844. minHeight?: number;
  60845. maxHeight?: number;
  60846. colorFilter?: Color3;
  60847. alphaFilter?: number;
  60848. updatable?: boolean;
  60849. onReady?: (mesh: GroundMesh) => void;
  60850. }, scene?: Nullable<Scene>): GroundMesh;
  60851. /**
  60852. * Creates a polygon mesh
  60853. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60854. * * 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
  60855. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60857. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60858. * * Remember you can only change the shape positions, not their number when updating a polygon
  60859. * @param name defines the name of the mesh
  60860. * @param options defines the options used to create the mesh
  60861. * @param scene defines the hosting scene
  60862. * @param earcutInjection can be used to inject your own earcut reference
  60863. * @returns the polygon mesh
  60864. */
  60865. static CreatePolygon(name: string, options: {
  60866. shape: Vector3[];
  60867. holes?: Vector3[][];
  60868. depth?: number;
  60869. faceUV?: Vector4[];
  60870. faceColors?: Color4[];
  60871. updatable?: boolean;
  60872. sideOrientation?: number;
  60873. frontUVs?: Vector4;
  60874. backUVs?: Vector4;
  60875. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60876. /**
  60877. * Creates an extruded polygon mesh, with depth in the Y direction.
  60878. * * 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)
  60879. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60880. * @param name defines the name of the mesh
  60881. * @param options defines the options used to create the mesh
  60882. * @param scene defines the hosting scene
  60883. * @param earcutInjection can be used to inject your own earcut reference
  60884. * @returns the polygon mesh
  60885. */
  60886. static ExtrudePolygon(name: string, options: {
  60887. shape: Vector3[];
  60888. holes?: Vector3[][];
  60889. depth?: number;
  60890. faceUV?: Vector4[];
  60891. faceColors?: Color4[];
  60892. updatable?: boolean;
  60893. sideOrientation?: number;
  60894. frontUVs?: Vector4;
  60895. backUVs?: Vector4;
  60896. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60897. /**
  60898. * Creates a tube mesh.
  60899. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60900. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60901. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60902. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60903. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60904. * * 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)
  60905. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60906. * * 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
  60907. * * 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
  60908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60909. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60910. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60912. * @param name defines the name of the mesh
  60913. * @param options defines the options used to create the mesh
  60914. * @param scene defines the hosting scene
  60915. * @returns the tube mesh
  60916. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60917. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60918. */
  60919. static CreateTube(name: string, options: {
  60920. path: Vector3[];
  60921. radius?: number;
  60922. tessellation?: number;
  60923. radiusFunction?: {
  60924. (i: number, distance: number): number;
  60925. };
  60926. cap?: number;
  60927. arc?: number;
  60928. updatable?: boolean;
  60929. sideOrientation?: number;
  60930. frontUVs?: Vector4;
  60931. backUVs?: Vector4;
  60932. instance?: Mesh;
  60933. invertUV?: boolean;
  60934. }, scene?: Nullable<Scene>): Mesh;
  60935. /**
  60936. * Creates a polyhedron mesh
  60937. * * 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
  60938. * * The parameter `size` (positive float, default 1) sets the polygon size
  60939. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  60940. * * 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`
  60941. * * 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
  60942. * * 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)`)
  60943. * * 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
  60944. * * 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
  60945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60948. * @param name defines the name of the mesh
  60949. * @param options defines the options used to create the mesh
  60950. * @param scene defines the hosting scene
  60951. * @returns the polyhedron mesh
  60952. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  60953. */
  60954. static CreatePolyhedron(name: string, options: {
  60955. type?: number;
  60956. size?: number;
  60957. sizeX?: number;
  60958. sizeY?: number;
  60959. sizeZ?: number;
  60960. custom?: any;
  60961. faceUV?: Vector4[];
  60962. faceColors?: Color4[];
  60963. flat?: boolean;
  60964. updatable?: boolean;
  60965. sideOrientation?: number;
  60966. frontUVs?: Vector4;
  60967. backUVs?: Vector4;
  60968. }, scene?: Nullable<Scene>): Mesh;
  60969. /**
  60970. * Creates a decal mesh.
  60971. * 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
  60972. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60973. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60974. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60975. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60976. * @param name defines the name of the mesh
  60977. * @param sourceMesh defines the mesh where the decal must be applied
  60978. * @param options defines the options used to create the mesh
  60979. * @param scene defines the hosting scene
  60980. * @returns the decal mesh
  60981. * @see https://doc.babylonjs.com/how_to/decals
  60982. */
  60983. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60984. position?: Vector3;
  60985. normal?: Vector3;
  60986. size?: Vector3;
  60987. angle?: number;
  60988. }): Mesh;
  60989. }
  60990. }
  60991. declare module "babylonjs/Meshes/meshSimplification" {
  60992. import { Mesh } from "babylonjs/Meshes/mesh";
  60993. /**
  60994. * A simplifier interface for future simplification implementations
  60995. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60996. */
  60997. export interface ISimplifier {
  60998. /**
  60999. * Simplification of a given mesh according to the given settings.
  61000. * Since this requires computation, it is assumed that the function runs async.
  61001. * @param settings The settings of the simplification, including quality and distance
  61002. * @param successCallback A callback that will be called after the mesh was simplified.
  61003. * @param errorCallback in case of an error, this callback will be called. optional.
  61004. */
  61005. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61006. }
  61007. /**
  61008. * Expected simplification settings.
  61009. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61010. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61011. */
  61012. export interface ISimplificationSettings {
  61013. /**
  61014. * Gets or sets the expected quality
  61015. */
  61016. quality: number;
  61017. /**
  61018. * Gets or sets the distance when this optimized version should be used
  61019. */
  61020. distance: number;
  61021. /**
  61022. * Gets an already optimized mesh
  61023. */
  61024. optimizeMesh?: boolean;
  61025. }
  61026. /**
  61027. * Class used to specify simplification options
  61028. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61029. */
  61030. export class SimplificationSettings implements ISimplificationSettings {
  61031. /** expected quality */
  61032. quality: number;
  61033. /** distance when this optimized version should be used */
  61034. distance: number;
  61035. /** already optimized mesh */
  61036. optimizeMesh?: boolean | undefined;
  61037. /**
  61038. * Creates a SimplificationSettings
  61039. * @param quality expected quality
  61040. * @param distance distance when this optimized version should be used
  61041. * @param optimizeMesh already optimized mesh
  61042. */
  61043. constructor(
  61044. /** expected quality */
  61045. quality: number,
  61046. /** distance when this optimized version should be used */
  61047. distance: number,
  61048. /** already optimized mesh */
  61049. optimizeMesh?: boolean | undefined);
  61050. }
  61051. /**
  61052. * Interface used to define a simplification task
  61053. */
  61054. export interface ISimplificationTask {
  61055. /**
  61056. * Array of settings
  61057. */
  61058. settings: Array<ISimplificationSettings>;
  61059. /**
  61060. * Simplification type
  61061. */
  61062. simplificationType: SimplificationType;
  61063. /**
  61064. * Mesh to simplify
  61065. */
  61066. mesh: Mesh;
  61067. /**
  61068. * Callback called on success
  61069. */
  61070. successCallback?: () => void;
  61071. /**
  61072. * Defines if parallel processing can be used
  61073. */
  61074. parallelProcessing: boolean;
  61075. }
  61076. /**
  61077. * Queue used to order the simplification tasks
  61078. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61079. */
  61080. export class SimplificationQueue {
  61081. private _simplificationArray;
  61082. /**
  61083. * Gets a boolean indicating that the process is still running
  61084. */
  61085. running: boolean;
  61086. /**
  61087. * Creates a new queue
  61088. */
  61089. constructor();
  61090. /**
  61091. * Adds a new simplification task
  61092. * @param task defines a task to add
  61093. */
  61094. addTask(task: ISimplificationTask): void;
  61095. /**
  61096. * Execute next task
  61097. */
  61098. executeNext(): void;
  61099. /**
  61100. * Execute a simplification task
  61101. * @param task defines the task to run
  61102. */
  61103. runSimplification(task: ISimplificationTask): void;
  61104. private getSimplifier;
  61105. }
  61106. /**
  61107. * The implemented types of simplification
  61108. * At the moment only Quadratic Error Decimation is implemented
  61109. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61110. */
  61111. export enum SimplificationType {
  61112. /** Quadratic error decimation */
  61113. QUADRATIC = 0
  61114. }
  61115. }
  61116. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  61117. import { Scene } from "babylonjs/scene";
  61118. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  61119. import { ISceneComponent } from "babylonjs/sceneComponent";
  61120. module "babylonjs/scene" {
  61121. interface Scene {
  61122. /** @hidden (Backing field) */
  61123. _simplificationQueue: SimplificationQueue;
  61124. /**
  61125. * Gets or sets the simplification queue attached to the scene
  61126. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61127. */
  61128. simplificationQueue: SimplificationQueue;
  61129. }
  61130. }
  61131. module "babylonjs/Meshes/mesh" {
  61132. interface Mesh {
  61133. /**
  61134. * Simplify the mesh according to the given array of settings.
  61135. * Function will return immediately and will simplify async
  61136. * @param settings a collection of simplification settings
  61137. * @param parallelProcessing should all levels calculate parallel or one after the other
  61138. * @param simplificationType the type of simplification to run
  61139. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61140. * @returns the current mesh
  61141. */
  61142. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61143. }
  61144. }
  61145. /**
  61146. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61147. * created in a scene
  61148. */
  61149. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61150. /**
  61151. * The component name helpfull to identify the component in the list of scene components.
  61152. */
  61153. readonly name: string;
  61154. /**
  61155. * The scene the component belongs to.
  61156. */
  61157. scene: Scene;
  61158. /**
  61159. * Creates a new instance of the component for the given scene
  61160. * @param scene Defines the scene to register the component in
  61161. */
  61162. constructor(scene: Scene);
  61163. /**
  61164. * Registers the component in a given scene
  61165. */
  61166. register(): void;
  61167. /**
  61168. * Rebuilds the elements related to this component in case of
  61169. * context lost for instance.
  61170. */
  61171. rebuild(): void;
  61172. /**
  61173. * Disposes the component and the associated ressources
  61174. */
  61175. dispose(): void;
  61176. private _beforeCameraUpdate;
  61177. }
  61178. }
  61179. declare module "babylonjs/Meshes/Builders/index" {
  61180. export * from "babylonjs/Meshes/Builders/boxBuilder";
  61181. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  61182. export * from "babylonjs/Meshes/Builders/discBuilder";
  61183. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  61184. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  61185. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  61186. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  61187. export * from "babylonjs/Meshes/Builders/torusBuilder";
  61188. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  61189. export * from "babylonjs/Meshes/Builders/linesBuilder";
  61190. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  61191. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  61192. export * from "babylonjs/Meshes/Builders/latheBuilder";
  61193. export * from "babylonjs/Meshes/Builders/planeBuilder";
  61194. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  61195. export * from "babylonjs/Meshes/Builders/groundBuilder";
  61196. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  61197. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  61198. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  61199. export * from "babylonjs/Meshes/Builders/decalBuilder";
  61200. }
  61201. declare module "babylonjs/Meshes/index" {
  61202. export * from "babylonjs/Meshes/abstractMesh";
  61203. export * from "babylonjs/Meshes/buffer";
  61204. export * from "babylonjs/Meshes/Compression/index";
  61205. export * from "babylonjs/Meshes/csg";
  61206. export * from "babylonjs/Meshes/geometry";
  61207. export * from "babylonjs/Meshes/groundMesh";
  61208. export * from "babylonjs/Meshes/trailMesh";
  61209. export * from "babylonjs/Meshes/instancedMesh";
  61210. export * from "babylonjs/Meshes/linesMesh";
  61211. export * from "babylonjs/Meshes/mesh";
  61212. export * from "babylonjs/Meshes/mesh.vertexData";
  61213. export * from "babylonjs/Meshes/meshBuilder";
  61214. export * from "babylonjs/Meshes/meshSimplification";
  61215. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  61216. export * from "babylonjs/Meshes/polygonMesh";
  61217. export * from "babylonjs/Meshes/subMesh";
  61218. export * from "babylonjs/Meshes/meshLODLevel";
  61219. export * from "babylonjs/Meshes/transformNode";
  61220. export * from "babylonjs/Meshes/Builders/index";
  61221. export * from "babylonjs/Meshes/dataBuffer";
  61222. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  61223. }
  61224. declare module "babylonjs/Morph/index" {
  61225. export * from "babylonjs/Morph/morphTarget";
  61226. export * from "babylonjs/Morph/morphTargetManager";
  61227. }
  61228. declare module "babylonjs/Navigation/INavigationEngine" {
  61229. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61230. import { Vector3 } from "babylonjs/Maths/math";
  61231. import { Mesh } from "babylonjs/Meshes/mesh";
  61232. import { Scene } from "babylonjs/scene";
  61233. /**
  61234. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61235. */
  61236. export interface INavigationEnginePlugin {
  61237. /**
  61238. * plugin name
  61239. */
  61240. name: string;
  61241. /**
  61242. * Creates a navigation mesh
  61243. * @param meshes array of all the geometry used to compute the navigatio mesh
  61244. * @param parameters bunch of parameters used to filter geometry
  61245. */
  61246. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61247. /**
  61248. * Create a navigation mesh debug mesh
  61249. * @param scene is where the mesh will be added
  61250. * @returns debug display mesh
  61251. */
  61252. createDebugNavMesh(scene: Scene): Mesh;
  61253. /**
  61254. * Get a navigation mesh constrained position, closest to the parameter position
  61255. * @param position world position
  61256. * @returns the closest point to position constrained by the navigation mesh
  61257. */
  61258. getClosestPoint(position: Vector3): Vector3;
  61259. /**
  61260. * Get a navigation mesh constrained position, within a particular radius
  61261. * @param position world position
  61262. * @param maxRadius the maximum distance to the constrained world position
  61263. * @returns the closest point to position constrained by the navigation mesh
  61264. */
  61265. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61266. /**
  61267. * Compute the final position from a segment made of destination-position
  61268. * @param position world position
  61269. * @param destination world position
  61270. * @returns the resulting point along the navmesh
  61271. */
  61272. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61273. /**
  61274. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61275. * @param start world position
  61276. * @param end world position
  61277. * @returns array containing world position composing the path
  61278. */
  61279. computePath(start: Vector3, end: Vector3): Vector3[];
  61280. /**
  61281. * If this plugin is supported
  61282. * @returns true if plugin is supported
  61283. */
  61284. isSupported(): boolean;
  61285. /**
  61286. * Create a new Crowd so you can add agents
  61287. * @param maxAgents the maximum agent count in the crowd
  61288. * @param maxAgentRadius the maximum radius an agent can have
  61289. * @param scene to attach the crowd to
  61290. * @returns the crowd you can add agents to
  61291. */
  61292. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61293. /**
  61294. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61295. * The queries will try to find a solution within those bounds
  61296. * default is (1,1,1)
  61297. * @param extent x,y,z value that define the extent around the queries point of reference
  61298. */
  61299. setDefaultQueryExtent(extent: Vector3): void;
  61300. /**
  61301. * Get the Bounding box extent specified by setDefaultQueryExtent
  61302. * @returns the box extent values
  61303. */
  61304. getDefaultQueryExtent(): Vector3;
  61305. /**
  61306. * Release all resources
  61307. */
  61308. dispose(): void;
  61309. }
  61310. /**
  61311. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61312. */
  61313. export interface ICrowd {
  61314. /**
  61315. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61316. * You can attach anything to that node. The node position is updated in the scene update tick.
  61317. * @param pos world position that will be constrained by the navigation mesh
  61318. * @param parameters agent parameters
  61319. * @param transform hooked to the agent that will be update by the scene
  61320. * @returns agent index
  61321. */
  61322. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61323. /**
  61324. * Returns the agent position in world space
  61325. * @param index agent index returned by addAgent
  61326. * @returns world space position
  61327. */
  61328. getAgentPosition(index: number): Vector3;
  61329. /**
  61330. * Gets the agent velocity in world space
  61331. * @param index agent index returned by addAgent
  61332. * @returns world space velocity
  61333. */
  61334. getAgentVelocity(index: number): Vector3;
  61335. /**
  61336. * remove a particular agent previously created
  61337. * @param index agent index returned by addAgent
  61338. */
  61339. removeAgent(index: number): void;
  61340. /**
  61341. * get the list of all agents attached to this crowd
  61342. * @returns list of agent indices
  61343. */
  61344. getAgents(): number[];
  61345. /**
  61346. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61347. * @param deltaTime in seconds
  61348. */
  61349. update(deltaTime: number): void;
  61350. /**
  61351. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61352. * @param index agent index returned by addAgent
  61353. * @param destination targeted world position
  61354. */
  61355. agentGoto(index: number, destination: Vector3): void;
  61356. /**
  61357. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61358. * The queries will try to find a solution within those bounds
  61359. * default is (1,1,1)
  61360. * @param extent x,y,z value that define the extent around the queries point of reference
  61361. */
  61362. setDefaultQueryExtent(extent: Vector3): void;
  61363. /**
  61364. * Get the Bounding box extent specified by setDefaultQueryExtent
  61365. * @returns the box extent values
  61366. */
  61367. getDefaultQueryExtent(): Vector3;
  61368. /**
  61369. * Release all resources
  61370. */
  61371. dispose(): void;
  61372. }
  61373. /**
  61374. * Configures an agent
  61375. */
  61376. export interface IAgentParameters {
  61377. /**
  61378. * Agent radius. [Limit: >= 0]
  61379. */
  61380. radius: number;
  61381. /**
  61382. * Agent height. [Limit: > 0]
  61383. */
  61384. height: number;
  61385. /**
  61386. * Maximum allowed acceleration. [Limit: >= 0]
  61387. */
  61388. maxAcceleration: number;
  61389. /**
  61390. * Maximum allowed speed. [Limit: >= 0]
  61391. */
  61392. maxSpeed: number;
  61393. /**
  61394. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  61395. */
  61396. collisionQueryRange: number;
  61397. /**
  61398. * The path visibility optimization range. [Limit: > 0]
  61399. */
  61400. pathOptimizationRange: number;
  61401. /**
  61402. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  61403. */
  61404. separationWeight: number;
  61405. }
  61406. /**
  61407. * Configures the navigation mesh creation
  61408. */
  61409. export interface INavMeshParameters {
  61410. /**
  61411. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  61412. */
  61413. cs: number;
  61414. /**
  61415. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  61416. */
  61417. ch: number;
  61418. /**
  61419. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  61420. */
  61421. walkableSlopeAngle: number;
  61422. /**
  61423. * Minimum floor to 'ceiling' height that will still allow the floor area to
  61424. * be considered walkable. [Limit: >= 3] [Units: vx]
  61425. */
  61426. walkableHeight: number;
  61427. /**
  61428. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  61429. */
  61430. walkableClimb: number;
  61431. /**
  61432. * The distance to erode/shrink the walkable area of the heightfield away from
  61433. * obstructions. [Limit: >=0] [Units: vx]
  61434. */
  61435. walkableRadius: number;
  61436. /**
  61437. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  61438. */
  61439. maxEdgeLen: number;
  61440. /**
  61441. * The maximum distance a simplfied contour's border edges should deviate
  61442. * the original raw contour. [Limit: >=0] [Units: vx]
  61443. */
  61444. maxSimplificationError: number;
  61445. /**
  61446. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  61447. */
  61448. minRegionArea: number;
  61449. /**
  61450. * Any regions with a span count smaller than this value will, if possible,
  61451. * be merged with larger regions. [Limit: >=0] [Units: vx]
  61452. */
  61453. mergeRegionArea: number;
  61454. /**
  61455. * The maximum number of vertices allowed for polygons generated during the
  61456. * contour to polygon conversion process. [Limit: >= 3]
  61457. */
  61458. maxVertsPerPoly: number;
  61459. /**
  61460. * Sets the sampling distance to use when generating the detail mesh.
  61461. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  61462. */
  61463. detailSampleDist: number;
  61464. /**
  61465. * The maximum distance the detail mesh surface should deviate from heightfield
  61466. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  61467. */
  61468. detailSampleMaxError: number;
  61469. }
  61470. }
  61471. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  61472. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  61473. import { Mesh } from "babylonjs/Meshes/mesh";
  61474. import { Scene } from "babylonjs/scene";
  61475. import { Vector3 } from "babylonjs/Maths/math";
  61476. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61477. /**
  61478. * RecastJS navigation plugin
  61479. */
  61480. export class RecastJSPlugin implements INavigationEnginePlugin {
  61481. /**
  61482. * Reference to the Recast library
  61483. */
  61484. bjsRECAST: any;
  61485. /**
  61486. * plugin name
  61487. */
  61488. name: string;
  61489. /**
  61490. * the first navmesh created. We might extend this to support multiple navmeshes
  61491. */
  61492. navMesh: any;
  61493. /**
  61494. * Initializes the recastJS plugin
  61495. * @param recastInjection can be used to inject your own recast reference
  61496. */
  61497. constructor(recastInjection?: any);
  61498. /**
  61499. * Creates a navigation mesh
  61500. * @param meshes array of all the geometry used to compute the navigatio mesh
  61501. * @param parameters bunch of parameters used to filter geometry
  61502. */
  61503. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61504. /**
  61505. * Create a navigation mesh debug mesh
  61506. * @param scene is where the mesh will be added
  61507. * @returns debug display mesh
  61508. */
  61509. createDebugNavMesh(scene: Scene): Mesh;
  61510. /**
  61511. * Get a navigation mesh constrained position, closest to the parameter position
  61512. * @param position world position
  61513. * @returns the closest point to position constrained by the navigation mesh
  61514. */
  61515. getClosestPoint(position: Vector3): Vector3;
  61516. /**
  61517. * Get a navigation mesh constrained position, within a particular radius
  61518. * @param position world position
  61519. * @param maxRadius the maximum distance to the constrained world position
  61520. * @returns the closest point to position constrained by the navigation mesh
  61521. */
  61522. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61523. /**
  61524. * Compute the final position from a segment made of destination-position
  61525. * @param position world position
  61526. * @param destination world position
  61527. * @returns the resulting point along the navmesh
  61528. */
  61529. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61530. /**
  61531. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61532. * @param start world position
  61533. * @param end world position
  61534. * @returns array containing world position composing the path
  61535. */
  61536. computePath(start: Vector3, end: Vector3): Vector3[];
  61537. /**
  61538. * Create a new Crowd so you can add agents
  61539. * @param maxAgents the maximum agent count in the crowd
  61540. * @param maxAgentRadius the maximum radius an agent can have
  61541. * @param scene to attach the crowd to
  61542. * @returns the crowd you can add agents to
  61543. */
  61544. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61545. /**
  61546. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61547. * The queries will try to find a solution within those bounds
  61548. * default is (1,1,1)
  61549. * @param extent x,y,z value that define the extent around the queries point of reference
  61550. */
  61551. setDefaultQueryExtent(extent: Vector3): void;
  61552. /**
  61553. * Get the Bounding box extent specified by setDefaultQueryExtent
  61554. * @returns the box extent values
  61555. */
  61556. getDefaultQueryExtent(): Vector3;
  61557. /**
  61558. * Disposes
  61559. */
  61560. dispose(): void;
  61561. /**
  61562. * If this plugin is supported
  61563. * @returns true if plugin is supported
  61564. */
  61565. isSupported(): boolean;
  61566. }
  61567. /**
  61568. * Recast detour crowd implementation
  61569. */
  61570. export class RecastJSCrowd implements ICrowd {
  61571. /**
  61572. * Recast/detour plugin
  61573. */
  61574. bjsRECASTPlugin: RecastJSPlugin;
  61575. /**
  61576. * Link to the detour crowd
  61577. */
  61578. recastCrowd: any;
  61579. /**
  61580. * One transform per agent
  61581. */
  61582. transforms: TransformNode[];
  61583. /**
  61584. * All agents created
  61585. */
  61586. agents: number[];
  61587. /**
  61588. * Link to the scene is kept to unregister the crowd from the scene
  61589. */
  61590. private _scene;
  61591. /**
  61592. * Observer for crowd updates
  61593. */
  61594. private _onBeforeAnimationsObserver;
  61595. /**
  61596. * Constructor
  61597. * @param plugin recastJS plugin
  61598. * @param maxAgents the maximum agent count in the crowd
  61599. * @param maxAgentRadius the maximum radius an agent can have
  61600. * @param scene to attach the crowd to
  61601. * @returns the crowd you can add agents to
  61602. */
  61603. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  61604. /**
  61605. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61606. * You can attach anything to that node. The node position is updated in the scene update tick.
  61607. * @param pos world position that will be constrained by the navigation mesh
  61608. * @param parameters agent parameters
  61609. * @param transform hooked to the agent that will be update by the scene
  61610. * @returns agent index
  61611. */
  61612. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61613. /**
  61614. * Returns the agent position in world space
  61615. * @param index agent index returned by addAgent
  61616. * @returns world space position
  61617. */
  61618. getAgentPosition(index: number): Vector3;
  61619. /**
  61620. * Returns the agent velocity in world space
  61621. * @param index agent index returned by addAgent
  61622. * @returns world space velocity
  61623. */
  61624. getAgentVelocity(index: number): Vector3;
  61625. /**
  61626. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61627. * @param index agent index returned by addAgent
  61628. * @param destination targeted world position
  61629. */
  61630. agentGoto(index: number, destination: Vector3): void;
  61631. /**
  61632. * remove a particular agent previously created
  61633. * @param index agent index returned by addAgent
  61634. */
  61635. removeAgent(index: number): void;
  61636. /**
  61637. * get the list of all agents attached to this crowd
  61638. * @returns list of agent indices
  61639. */
  61640. getAgents(): number[];
  61641. /**
  61642. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61643. * @param deltaTime in seconds
  61644. */
  61645. update(deltaTime: number): void;
  61646. /**
  61647. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61648. * The queries will try to find a solution within those bounds
  61649. * default is (1,1,1)
  61650. * @param extent x,y,z value that define the extent around the queries point of reference
  61651. */
  61652. setDefaultQueryExtent(extent: Vector3): void;
  61653. /**
  61654. * Get the Bounding box extent specified by setDefaultQueryExtent
  61655. * @returns the box extent values
  61656. */
  61657. getDefaultQueryExtent(): Vector3;
  61658. /**
  61659. * Release all resources
  61660. */
  61661. dispose(): void;
  61662. }
  61663. }
  61664. declare module "babylonjs/Navigation/Plugins/index" {
  61665. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  61666. }
  61667. declare module "babylonjs/Navigation/index" {
  61668. export * from "babylonjs/Navigation/INavigationEngine";
  61669. export * from "babylonjs/Navigation/Plugins/index";
  61670. }
  61671. declare module "babylonjs/Offline/database" {
  61672. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  61673. /**
  61674. * Class used to enable access to IndexedDB
  61675. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61676. */
  61677. export class Database implements IOfflineProvider {
  61678. private _callbackManifestChecked;
  61679. private _currentSceneUrl;
  61680. private _db;
  61681. private _enableSceneOffline;
  61682. private _enableTexturesOffline;
  61683. private _manifestVersionFound;
  61684. private _mustUpdateRessources;
  61685. private _hasReachedQuota;
  61686. private _isSupported;
  61687. private _idbFactory;
  61688. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  61689. private static IsUASupportingBlobStorage;
  61690. /**
  61691. * Gets a boolean indicating if Database storate is enabled (off by default)
  61692. */
  61693. static IDBStorageEnabled: boolean;
  61694. /**
  61695. * Gets a boolean indicating if scene must be saved in the database
  61696. */
  61697. readonly enableSceneOffline: boolean;
  61698. /**
  61699. * Gets a boolean indicating if textures must be saved in the database
  61700. */
  61701. readonly enableTexturesOffline: boolean;
  61702. /**
  61703. * Creates a new Database
  61704. * @param urlToScene defines the url to load the scene
  61705. * @param callbackManifestChecked defines the callback to use when manifest is checked
  61706. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  61707. */
  61708. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  61709. private static _ParseURL;
  61710. private static _ReturnFullUrlLocation;
  61711. private _checkManifestFile;
  61712. /**
  61713. * Open the database and make it available
  61714. * @param successCallback defines the callback to call on success
  61715. * @param errorCallback defines the callback to call on error
  61716. */
  61717. open(successCallback: () => void, errorCallback: () => void): void;
  61718. /**
  61719. * Loads an image from the database
  61720. * @param url defines the url to load from
  61721. * @param image defines the target DOM image
  61722. */
  61723. loadImage(url: string, image: HTMLImageElement): void;
  61724. private _loadImageFromDBAsync;
  61725. private _saveImageIntoDBAsync;
  61726. private _checkVersionFromDB;
  61727. private _loadVersionFromDBAsync;
  61728. private _saveVersionIntoDBAsync;
  61729. /**
  61730. * Loads a file from database
  61731. * @param url defines the URL to load from
  61732. * @param sceneLoaded defines a callback to call on success
  61733. * @param progressCallBack defines a callback to call when progress changed
  61734. * @param errorCallback defines a callback to call on error
  61735. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61736. */
  61737. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61738. private _loadFileAsync;
  61739. private _saveFileAsync;
  61740. /**
  61741. * Validates if xhr data is correct
  61742. * @param xhr defines the request to validate
  61743. * @param dataType defines the expected data type
  61744. * @returns true if data is correct
  61745. */
  61746. private static _ValidateXHRData;
  61747. }
  61748. }
  61749. declare module "babylonjs/Offline/index" {
  61750. export * from "babylonjs/Offline/database";
  61751. export * from "babylonjs/Offline/IOfflineProvider";
  61752. }
  61753. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  61754. /** @hidden */
  61755. export var gpuUpdateParticlesPixelShader: {
  61756. name: string;
  61757. shader: string;
  61758. };
  61759. }
  61760. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  61761. /** @hidden */
  61762. export var gpuUpdateParticlesVertexShader: {
  61763. name: string;
  61764. shader: string;
  61765. };
  61766. }
  61767. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  61768. /** @hidden */
  61769. export var clipPlaneFragmentDeclaration2: {
  61770. name: string;
  61771. shader: string;
  61772. };
  61773. }
  61774. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  61775. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  61776. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61777. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61778. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61779. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  61780. /** @hidden */
  61781. export var gpuRenderParticlesPixelShader: {
  61782. name: string;
  61783. shader: string;
  61784. };
  61785. }
  61786. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  61787. /** @hidden */
  61788. export var clipPlaneVertexDeclaration2: {
  61789. name: string;
  61790. shader: string;
  61791. };
  61792. }
  61793. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  61794. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  61795. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  61796. /** @hidden */
  61797. export var gpuRenderParticlesVertexShader: {
  61798. name: string;
  61799. shader: string;
  61800. };
  61801. }
  61802. declare module "babylonjs/Particles/gpuParticleSystem" {
  61803. import { Nullable } from "babylonjs/types";
  61804. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  61805. import { Observable } from "babylonjs/Misc/observable";
  61806. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61807. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61808. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  61809. import { Scene, IDisposable } from "babylonjs/scene";
  61810. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  61811. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61812. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  61813. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  61814. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  61815. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  61816. /**
  61817. * This represents a GPU particle system in Babylon
  61818. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  61819. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  61820. */
  61821. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  61822. /**
  61823. * The layer mask we are rendering the particles through.
  61824. */
  61825. layerMask: number;
  61826. private _capacity;
  61827. private _activeCount;
  61828. private _currentActiveCount;
  61829. private _accumulatedCount;
  61830. private _renderEffect;
  61831. private _updateEffect;
  61832. private _buffer0;
  61833. private _buffer1;
  61834. private _spriteBuffer;
  61835. private _updateVAO;
  61836. private _renderVAO;
  61837. private _targetIndex;
  61838. private _sourceBuffer;
  61839. private _targetBuffer;
  61840. private _engine;
  61841. private _currentRenderId;
  61842. private _started;
  61843. private _stopped;
  61844. private _timeDelta;
  61845. private _randomTexture;
  61846. private _randomTexture2;
  61847. private _attributesStrideSize;
  61848. private _updateEffectOptions;
  61849. private _randomTextureSize;
  61850. private _actualFrame;
  61851. private readonly _rawTextureWidth;
  61852. /**
  61853. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  61854. */
  61855. static readonly IsSupported: boolean;
  61856. /**
  61857. * An event triggered when the system is disposed.
  61858. */
  61859. onDisposeObservable: Observable<GPUParticleSystem>;
  61860. /**
  61861. * Gets the maximum number of particles active at the same time.
  61862. * @returns The max number of active particles.
  61863. */
  61864. getCapacity(): number;
  61865. /**
  61866. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  61867. * to override the particles.
  61868. */
  61869. forceDepthWrite: boolean;
  61870. /**
  61871. * Gets or set the number of active particles
  61872. */
  61873. activeParticleCount: number;
  61874. private _preWarmDone;
  61875. /**
  61876. * Is this system ready to be used/rendered
  61877. * @return true if the system is ready
  61878. */
  61879. isReady(): boolean;
  61880. /**
  61881. * Gets if the system has been started. (Note: this will still be true after stop is called)
  61882. * @returns True if it has been started, otherwise false.
  61883. */
  61884. isStarted(): boolean;
  61885. /**
  61886. * Starts the particle system and begins to emit
  61887. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  61888. */
  61889. start(delay?: number): void;
  61890. /**
  61891. * Stops the particle system.
  61892. */
  61893. stop(): void;
  61894. /**
  61895. * Remove all active particles
  61896. */
  61897. reset(): void;
  61898. /**
  61899. * Returns the string "GPUParticleSystem"
  61900. * @returns a string containing the class name
  61901. */
  61902. getClassName(): string;
  61903. private _colorGradientsTexture;
  61904. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  61905. /**
  61906. * Adds a new color gradient
  61907. * @param gradient defines the gradient to use (between 0 and 1)
  61908. * @param color1 defines the color to affect to the specified gradient
  61909. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  61910. * @returns the current particle system
  61911. */
  61912. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  61913. /**
  61914. * Remove a specific color gradient
  61915. * @param gradient defines the gradient to remove
  61916. * @returns the current particle system
  61917. */
  61918. removeColorGradient(gradient: number): GPUParticleSystem;
  61919. private _angularSpeedGradientsTexture;
  61920. private _sizeGradientsTexture;
  61921. private _velocityGradientsTexture;
  61922. private _limitVelocityGradientsTexture;
  61923. private _dragGradientsTexture;
  61924. private _addFactorGradient;
  61925. /**
  61926. * Adds a new size gradient
  61927. * @param gradient defines the gradient to use (between 0 and 1)
  61928. * @param factor defines the size factor to affect to the specified gradient
  61929. * @returns the current particle system
  61930. */
  61931. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  61932. /**
  61933. * Remove a specific size gradient
  61934. * @param gradient defines the gradient to remove
  61935. * @returns the current particle system
  61936. */
  61937. removeSizeGradient(gradient: number): GPUParticleSystem;
  61938. /**
  61939. * Adds a new angular speed gradient
  61940. * @param gradient defines the gradient to use (between 0 and 1)
  61941. * @param factor defines the angular speed to affect to the specified gradient
  61942. * @returns the current particle system
  61943. */
  61944. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  61945. /**
  61946. * Remove a specific angular speed gradient
  61947. * @param gradient defines the gradient to remove
  61948. * @returns the current particle system
  61949. */
  61950. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  61951. /**
  61952. * Adds a new velocity gradient
  61953. * @param gradient defines the gradient to use (between 0 and 1)
  61954. * @param factor defines the velocity to affect to the specified gradient
  61955. * @returns the current particle system
  61956. */
  61957. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61958. /**
  61959. * Remove a specific velocity gradient
  61960. * @param gradient defines the gradient to remove
  61961. * @returns the current particle system
  61962. */
  61963. removeVelocityGradient(gradient: number): GPUParticleSystem;
  61964. /**
  61965. * Adds a new limit velocity gradient
  61966. * @param gradient defines the gradient to use (between 0 and 1)
  61967. * @param factor defines the limit velocity value to affect to the specified gradient
  61968. * @returns the current particle system
  61969. */
  61970. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61971. /**
  61972. * Remove a specific limit velocity gradient
  61973. * @param gradient defines the gradient to remove
  61974. * @returns the current particle system
  61975. */
  61976. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  61977. /**
  61978. * Adds a new drag gradient
  61979. * @param gradient defines the gradient to use (between 0 and 1)
  61980. * @param factor defines the drag value to affect to the specified gradient
  61981. * @returns the current particle system
  61982. */
  61983. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  61984. /**
  61985. * Remove a specific drag gradient
  61986. * @param gradient defines the gradient to remove
  61987. * @returns the current particle system
  61988. */
  61989. removeDragGradient(gradient: number): GPUParticleSystem;
  61990. /**
  61991. * Not supported by GPUParticleSystem
  61992. * @param gradient defines the gradient to use (between 0 and 1)
  61993. * @param factor defines the emit rate value to affect to the specified gradient
  61994. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61995. * @returns the current particle system
  61996. */
  61997. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61998. /**
  61999. * Not supported by GPUParticleSystem
  62000. * @param gradient defines the gradient to remove
  62001. * @returns the current particle system
  62002. */
  62003. removeEmitRateGradient(gradient: number): IParticleSystem;
  62004. /**
  62005. * Not supported by GPUParticleSystem
  62006. * @param gradient defines the gradient to use (between 0 and 1)
  62007. * @param factor defines the start size value to affect to the specified gradient
  62008. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62009. * @returns the current particle system
  62010. */
  62011. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62012. /**
  62013. * Not supported by GPUParticleSystem
  62014. * @param gradient defines the gradient to remove
  62015. * @returns the current particle system
  62016. */
  62017. removeStartSizeGradient(gradient: number): IParticleSystem;
  62018. /**
  62019. * Not supported by GPUParticleSystem
  62020. * @param gradient defines the gradient to use (between 0 and 1)
  62021. * @param min defines the color remap minimal range
  62022. * @param max defines the color remap maximal range
  62023. * @returns the current particle system
  62024. */
  62025. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62026. /**
  62027. * Not supported by GPUParticleSystem
  62028. * @param gradient defines the gradient to remove
  62029. * @returns the current particle system
  62030. */
  62031. removeColorRemapGradient(): IParticleSystem;
  62032. /**
  62033. * Not supported by GPUParticleSystem
  62034. * @param gradient defines the gradient to use (between 0 and 1)
  62035. * @param min defines the alpha remap minimal range
  62036. * @param max defines the alpha remap maximal range
  62037. * @returns the current particle system
  62038. */
  62039. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62040. /**
  62041. * Not supported by GPUParticleSystem
  62042. * @param gradient defines the gradient to remove
  62043. * @returns the current particle system
  62044. */
  62045. removeAlphaRemapGradient(): IParticleSystem;
  62046. /**
  62047. * Not supported by GPUParticleSystem
  62048. * @param gradient defines the gradient to use (between 0 and 1)
  62049. * @param color defines the color to affect to the specified gradient
  62050. * @returns the current particle system
  62051. */
  62052. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62053. /**
  62054. * Not supported by GPUParticleSystem
  62055. * @param gradient defines the gradient to remove
  62056. * @returns the current particle system
  62057. */
  62058. removeRampGradient(): IParticleSystem;
  62059. /**
  62060. * Not supported by GPUParticleSystem
  62061. * @returns the list of ramp gradients
  62062. */
  62063. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62064. /**
  62065. * Not supported by GPUParticleSystem
  62066. * Gets or sets a boolean indicating that ramp gradients must be used
  62067. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62068. */
  62069. useRampGradients: boolean;
  62070. /**
  62071. * Not supported by GPUParticleSystem
  62072. * @param gradient defines the gradient to use (between 0 and 1)
  62073. * @param factor defines the life time factor to affect to the specified gradient
  62074. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62075. * @returns the current particle system
  62076. */
  62077. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62078. /**
  62079. * Not supported by GPUParticleSystem
  62080. * @param gradient defines the gradient to remove
  62081. * @returns the current particle system
  62082. */
  62083. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62084. /**
  62085. * Instantiates a GPU particle system.
  62086. * 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.
  62087. * @param name The name of the particle system
  62088. * @param options The options used to create the system
  62089. * @param scene The scene the particle system belongs to
  62090. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62091. */
  62092. constructor(name: string, options: Partial<{
  62093. capacity: number;
  62094. randomTextureSize: number;
  62095. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62096. protected _reset(): void;
  62097. private _createUpdateVAO;
  62098. private _createRenderVAO;
  62099. private _initialize;
  62100. /** @hidden */
  62101. _recreateUpdateEffect(): void;
  62102. /** @hidden */
  62103. _recreateRenderEffect(): void;
  62104. /**
  62105. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62106. * @param preWarm defines if we are in the pre-warmimg phase
  62107. */
  62108. animate(preWarm?: boolean): void;
  62109. private _createFactorGradientTexture;
  62110. private _createSizeGradientTexture;
  62111. private _createAngularSpeedGradientTexture;
  62112. private _createVelocityGradientTexture;
  62113. private _createLimitVelocityGradientTexture;
  62114. private _createDragGradientTexture;
  62115. private _createColorGradientTexture;
  62116. /**
  62117. * Renders the particle system in its current state
  62118. * @param preWarm defines if the system should only update the particles but not render them
  62119. * @returns the current number of particles
  62120. */
  62121. render(preWarm?: boolean): number;
  62122. /**
  62123. * Rebuilds the particle system
  62124. */
  62125. rebuild(): void;
  62126. private _releaseBuffers;
  62127. private _releaseVAOs;
  62128. /**
  62129. * Disposes the particle system and free the associated resources
  62130. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62131. */
  62132. dispose(disposeTexture?: boolean): void;
  62133. /**
  62134. * Clones the particle system.
  62135. * @param name The name of the cloned object
  62136. * @param newEmitter The new emitter to use
  62137. * @returns the cloned particle system
  62138. */
  62139. clone(name: string, newEmitter: any): GPUParticleSystem;
  62140. /**
  62141. * Serializes the particle system to a JSON object.
  62142. * @returns the JSON object
  62143. */
  62144. serialize(): any;
  62145. /**
  62146. * Parses a JSON object to create a GPU particle system.
  62147. * @param parsedParticleSystem The JSON object to parse
  62148. * @param scene The scene to create the particle system in
  62149. * @param rootUrl The root url to use to load external dependencies like texture
  62150. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62151. * @returns the parsed GPU particle system
  62152. */
  62153. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62154. }
  62155. }
  62156. declare module "babylonjs/Particles/particleSystemSet" {
  62157. import { Nullable } from "babylonjs/types";
  62158. import { Color3 } from "babylonjs/Maths/math.color";
  62159. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62161. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62162. import { Scene, IDisposable } from "babylonjs/scene";
  62163. /**
  62164. * Represents a set of particle systems working together to create a specific effect
  62165. */
  62166. export class ParticleSystemSet implements IDisposable {
  62167. /**
  62168. * Gets or sets base Assets URL
  62169. */
  62170. static BaseAssetsUrl: string;
  62171. private _emitterCreationOptions;
  62172. private _emitterNode;
  62173. /**
  62174. * Gets the particle system list
  62175. */
  62176. systems: IParticleSystem[];
  62177. /**
  62178. * Gets the emitter node used with this set
  62179. */
  62180. readonly emitterNode: Nullable<TransformNode>;
  62181. /**
  62182. * Creates a new emitter mesh as a sphere
  62183. * @param options defines the options used to create the sphere
  62184. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62185. * @param scene defines the hosting scene
  62186. */
  62187. setEmitterAsSphere(options: {
  62188. diameter: number;
  62189. segments: number;
  62190. color: Color3;
  62191. }, renderingGroupId: number, scene: Scene): void;
  62192. /**
  62193. * Starts all particle systems of the set
  62194. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62195. */
  62196. start(emitter?: AbstractMesh): void;
  62197. /**
  62198. * Release all associated resources
  62199. */
  62200. dispose(): void;
  62201. /**
  62202. * Serialize the set into a JSON compatible object
  62203. * @returns a JSON compatible representation of the set
  62204. */
  62205. serialize(): any;
  62206. /**
  62207. * Parse a new ParticleSystemSet from a serialized source
  62208. * @param data defines a JSON compatible representation of the set
  62209. * @param scene defines the hosting scene
  62210. * @param gpu defines if we want GPU particles or CPU particles
  62211. * @returns a new ParticleSystemSet
  62212. */
  62213. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62214. }
  62215. }
  62216. declare module "babylonjs/Particles/particleHelper" {
  62217. import { Nullable } from "babylonjs/types";
  62218. import { Scene } from "babylonjs/scene";
  62219. import { Vector3 } from "babylonjs/Maths/math.vector";
  62220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62221. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62222. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  62223. /**
  62224. * This class is made for on one-liner static method to help creating particle system set.
  62225. */
  62226. export class ParticleHelper {
  62227. /**
  62228. * Gets or sets base Assets URL
  62229. */
  62230. static BaseAssetsUrl: string;
  62231. /**
  62232. * Create a default particle system that you can tweak
  62233. * @param emitter defines the emitter to use
  62234. * @param capacity defines the system capacity (default is 500 particles)
  62235. * @param scene defines the hosting scene
  62236. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62237. * @returns the new Particle system
  62238. */
  62239. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62240. /**
  62241. * This is the main static method (one-liner) of this helper to create different particle systems
  62242. * @param type This string represents the type to the particle system to create
  62243. * @param scene The scene where the particle system should live
  62244. * @param gpu If the system will use gpu
  62245. * @returns the ParticleSystemSet created
  62246. */
  62247. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62248. /**
  62249. * Static function used to export a particle system to a ParticleSystemSet variable.
  62250. * Please note that the emitter shape is not exported
  62251. * @param systems defines the particle systems to export
  62252. * @returns the created particle system set
  62253. */
  62254. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62255. }
  62256. }
  62257. declare module "babylonjs/Particles/particleSystemComponent" {
  62258. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62259. import { Effect } from "babylonjs/Materials/effect";
  62260. import "babylonjs/Shaders/particles.vertex";
  62261. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  62262. module "babylonjs/Engines/engine" {
  62263. interface Engine {
  62264. /**
  62265. * Create an effect to use with particle systems.
  62266. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62267. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62268. * @param uniformsNames defines a list of attribute names
  62269. * @param samplers defines an array of string used to represent textures
  62270. * @param defines defines the string containing the defines to use to compile the shaders
  62271. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62272. * @param onCompiled defines a function to call when the effect creation is successful
  62273. * @param onError defines a function to call when the effect creation has failed
  62274. * @returns the new Effect
  62275. */
  62276. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62277. }
  62278. }
  62279. module "babylonjs/Meshes/mesh" {
  62280. interface Mesh {
  62281. /**
  62282. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62283. * @returns an array of IParticleSystem
  62284. */
  62285. getEmittedParticleSystems(): IParticleSystem[];
  62286. /**
  62287. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62288. * @returns an array of IParticleSystem
  62289. */
  62290. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62291. }
  62292. }
  62293. /**
  62294. * @hidden
  62295. */
  62296. export var _IDoNeedToBeInTheBuild: number;
  62297. }
  62298. declare module "babylonjs/Particles/pointsCloudSystem" {
  62299. import { Color4 } from "babylonjs/Maths/math";
  62300. import { Mesh } from "babylonjs/Meshes/mesh";
  62301. import { Scene, IDisposable } from "babylonjs/scene";
  62302. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  62303. /** Defines the 4 color options */
  62304. export enum PointColor {
  62305. /** color value */
  62306. Color = 2,
  62307. /** uv value */
  62308. UV = 1,
  62309. /** random value */
  62310. Random = 0,
  62311. /** stated value */
  62312. Stated = 3
  62313. }
  62314. /**
  62315. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62316. * 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.
  62317. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62318. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62319. *
  62320. * Full documentation here : TO BE ENTERED
  62321. */
  62322. export class PointsCloudSystem implements IDisposable {
  62323. /**
  62324. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62325. * Example : var p = SPS.particles[i];
  62326. */
  62327. particles: CloudPoint[];
  62328. /**
  62329. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62330. */
  62331. nbParticles: number;
  62332. /**
  62333. * This a counter for your own usage. It's not set by any SPS functions.
  62334. */
  62335. counter: number;
  62336. /**
  62337. * The PCS name. This name is also given to the underlying mesh.
  62338. */
  62339. name: string;
  62340. /**
  62341. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62342. */
  62343. mesh: Mesh;
  62344. /**
  62345. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62346. * Please read :
  62347. */
  62348. vars: any;
  62349. /**
  62350. * @hidden
  62351. */
  62352. _size: number;
  62353. private _scene;
  62354. private _promises;
  62355. private _positions;
  62356. private _indices;
  62357. private _normals;
  62358. private _colors;
  62359. private _uvs;
  62360. private _indices32;
  62361. private _positions32;
  62362. private _colors32;
  62363. private _uvs32;
  62364. private _updatable;
  62365. private _isVisibilityBoxLocked;
  62366. private _alwaysVisible;
  62367. private _groups;
  62368. private _groupCounter;
  62369. private _computeParticleColor;
  62370. private _computeParticleTexture;
  62371. private _computeParticleRotation;
  62372. private _computeBoundingBox;
  62373. private _isReady;
  62374. /**
  62375. * Creates a PCS (Points Cloud System) object
  62376. * @param name (String) is the PCS name, this will be the underlying mesh name
  62377. * @param pointSize (number) is the size for each point
  62378. * @param scene (Scene) is the scene in which the PCS is added
  62379. * @param options defines the options of the PCS e.g.
  62380. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62381. */
  62382. constructor(name: string, pointSize: number, scene: Scene, options?: {
  62383. updatable?: boolean;
  62384. });
  62385. /**
  62386. * Builds the PCS underlying mesh. Returns a standard Mesh.
  62387. * If no points were added to the PCS, the returned mesh is just a single point.
  62388. * @returns a promise for the created mesh
  62389. */
  62390. buildMeshAsync(): Promise<Mesh>;
  62391. /**
  62392. * @hidden
  62393. */
  62394. private _buildMesh;
  62395. private _addParticle;
  62396. private _randomUnitVector;
  62397. private _getColorIndicesForCoord;
  62398. private _setPointsColorOrUV;
  62399. private _colorFromTexture;
  62400. private _calculateDensity;
  62401. /**
  62402. * Adds points to the PCS in random positions within a unit sphere
  62403. * @param nb (positive integer) the number of particles to be created from this model
  62404. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  62405. * @returns the number of groups in the system
  62406. */
  62407. addPoints(nb: number, pointFunction?: any): number;
  62408. /**
  62409. * Adds points to the PCS from the surface of the model shape
  62410. * @param mesh is any Mesh object that will be used as a surface model for the points
  62411. * @param nb (positive integer) the number of particles to be created from this model
  62412. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62413. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62414. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62415. * @returns the number of groups in the system
  62416. */
  62417. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62418. /**
  62419. * Adds points to the PCS inside the model shape
  62420. * @param mesh is any Mesh object that will be used as a surface model for the points
  62421. * @param nb (positive integer) the number of particles to be created from this model
  62422. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62423. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62424. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62425. * @returns the number of groups in the system
  62426. */
  62427. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62428. /**
  62429. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  62430. * This method calls `updateParticle()` for each particle of the SPS.
  62431. * For an animated SPS, it is usually called within the render loop.
  62432. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  62433. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  62434. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  62435. * @returns the PCS.
  62436. */
  62437. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  62438. /**
  62439. * Disposes the PCS.
  62440. */
  62441. dispose(): void;
  62442. /**
  62443. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  62444. * doc :
  62445. * @returns the PCS.
  62446. */
  62447. refreshVisibleSize(): PointsCloudSystem;
  62448. /**
  62449. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  62450. * @param size the size (float) of the visibility box
  62451. * note : this doesn't lock the PCS mesh bounding box.
  62452. * doc :
  62453. */
  62454. setVisibilityBox(size: number): void;
  62455. /**
  62456. * Gets whether the PCS is always visible or not
  62457. * doc :
  62458. */
  62459. /**
  62460. * Sets the PCS as always visible or not
  62461. * doc :
  62462. */
  62463. isAlwaysVisible: boolean;
  62464. /**
  62465. * Tells to `setParticles()` to compute the particle rotations or not
  62466. * Default value : false. The PCS is faster when it's set to false
  62467. * Note : particle rotations are only applied to parent particles
  62468. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  62469. */
  62470. computeParticleRotation: boolean;
  62471. /**
  62472. * Tells to `setParticles()` to compute the particle colors or not.
  62473. * Default value : true. The PCS is faster when it's set to false.
  62474. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62475. */
  62476. /**
  62477. * Gets if `setParticles()` computes the particle colors or not.
  62478. * Default value : false. The PCS is faster when it's set to false.
  62479. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62480. */
  62481. computeParticleColor: boolean;
  62482. /**
  62483. * Gets if `setParticles()` computes the particle textures or not.
  62484. * Default value : false. The PCS is faster when it's set to false.
  62485. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  62486. */
  62487. computeParticleTexture: boolean;
  62488. /**
  62489. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  62490. */
  62491. /**
  62492. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  62493. */
  62494. computeBoundingBox: boolean;
  62495. /**
  62496. * This function does nothing. It may be overwritten to set all the particle first values.
  62497. * The PCS doesn't call this function, you may have to call it by your own.
  62498. * doc :
  62499. */
  62500. initParticles(): void;
  62501. /**
  62502. * This function does nothing. It may be overwritten to recycle a particle
  62503. * The PCS doesn't call this function, you can to call it
  62504. * doc :
  62505. * @param particle The particle to recycle
  62506. * @returns the recycled particle
  62507. */
  62508. recycleParticle(particle: CloudPoint): CloudPoint;
  62509. /**
  62510. * Updates a particle : this function should be overwritten by the user.
  62511. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  62512. * doc :
  62513. * @example : just set a particle position or velocity and recycle conditions
  62514. * @param particle The particle to update
  62515. * @returns the updated particle
  62516. */
  62517. updateParticle(particle: CloudPoint): CloudPoint;
  62518. /**
  62519. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  62520. * This does nothing and may be overwritten by the user.
  62521. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62522. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62523. * @param update the boolean update value actually passed to setParticles()
  62524. */
  62525. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62526. /**
  62527. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  62528. * This will be passed three parameters.
  62529. * This does nothing and may be overwritten by the user.
  62530. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62531. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62532. * @param update the boolean update value actually passed to setParticles()
  62533. */
  62534. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62535. }
  62536. }
  62537. declare module "babylonjs/Particles/cloudPoint" {
  62538. import { Nullable } from "babylonjs/types";
  62539. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  62540. import { Mesh } from "babylonjs/Meshes/mesh";
  62541. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62542. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  62543. /**
  62544. * Represents one particle of a points cloud system.
  62545. */
  62546. export class CloudPoint {
  62547. /**
  62548. * particle global index
  62549. */
  62550. idx: number;
  62551. /**
  62552. * The color of the particle
  62553. */
  62554. color: Nullable<Color4>;
  62555. /**
  62556. * The world space position of the particle.
  62557. */
  62558. position: Vector3;
  62559. /**
  62560. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  62561. */
  62562. rotation: Vector3;
  62563. /**
  62564. * The world space rotation quaternion of the particle.
  62565. */
  62566. rotationQuaternion: Nullable<Quaternion>;
  62567. /**
  62568. * The uv of the particle.
  62569. */
  62570. uv: Nullable<Vector2>;
  62571. /**
  62572. * The current speed of the particle.
  62573. */
  62574. velocity: Vector3;
  62575. /**
  62576. * The pivot point in the particle local space.
  62577. */
  62578. pivot: Vector3;
  62579. /**
  62580. * Must the particle be translated from its pivot point in its local space ?
  62581. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  62582. * Default : false
  62583. */
  62584. translateFromPivot: boolean;
  62585. /**
  62586. * Index of this particle in the global "positions" array (Internal use)
  62587. * @hidden
  62588. */
  62589. _pos: number;
  62590. /**
  62591. * @hidden Index of this particle in the global "indices" array (Internal use)
  62592. */
  62593. _ind: number;
  62594. /**
  62595. * Group this particle belongs to
  62596. */
  62597. _group: PointsGroup;
  62598. /**
  62599. * Group id of this particle
  62600. */
  62601. groupId: number;
  62602. /**
  62603. * Index of the particle in its group id (Internal use)
  62604. */
  62605. idxInGroup: number;
  62606. /**
  62607. * @hidden Particle BoundingInfo object (Internal use)
  62608. */
  62609. _boundingInfo: BoundingInfo;
  62610. /**
  62611. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  62612. */
  62613. _pcs: PointsCloudSystem;
  62614. /**
  62615. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  62616. */
  62617. _stillInvisible: boolean;
  62618. /**
  62619. * @hidden Last computed particle rotation matrix
  62620. */
  62621. _rotationMatrix: number[];
  62622. /**
  62623. * Parent particle Id, if any.
  62624. * Default null.
  62625. */
  62626. parentId: Nullable<number>;
  62627. /**
  62628. * @hidden Internal global position in the PCS.
  62629. */
  62630. _globalPosition: Vector3;
  62631. /**
  62632. * Creates a Point Cloud object.
  62633. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  62634. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  62635. * @param group (PointsGroup) is the group the particle belongs to
  62636. * @param groupId (integer) is the group identifier in the PCS.
  62637. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  62638. * @param pcs defines the PCS it is associated to
  62639. */
  62640. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  62641. /**
  62642. * get point size
  62643. */
  62644. /**
  62645. * Set point size
  62646. */
  62647. size: Vector3;
  62648. /**
  62649. * Legacy support, changed quaternion to rotationQuaternion
  62650. */
  62651. /**
  62652. * Legacy support, changed quaternion to rotationQuaternion
  62653. */
  62654. quaternion: Nullable<Quaternion>;
  62655. /**
  62656. * Returns a boolean. True if the particle intersects a mesh, else false
  62657. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  62658. * @param target is the object (point or mesh) what the intersection is computed against
  62659. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  62660. * @returns true if it intersects
  62661. */
  62662. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  62663. /**
  62664. * get the rotation matrix of the particle
  62665. * @hidden
  62666. */
  62667. getRotationMatrix(m: Matrix): void;
  62668. }
  62669. /**
  62670. * Represents a group of points in a points cloud system
  62671. * * PCS internal tool, don't use it manually.
  62672. */
  62673. export class PointsGroup {
  62674. /**
  62675. * The group id
  62676. * @hidden
  62677. */
  62678. groupID: number;
  62679. /**
  62680. * image data for group (internal use)
  62681. * @hidden
  62682. */
  62683. _groupImageData: Nullable<ArrayBufferView>;
  62684. /**
  62685. * Image Width (internal use)
  62686. * @hidden
  62687. */
  62688. _groupImgWidth: number;
  62689. /**
  62690. * Image Height (internal use)
  62691. * @hidden
  62692. */
  62693. _groupImgHeight: number;
  62694. /**
  62695. * Custom position function (internal use)
  62696. * @hidden
  62697. */
  62698. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  62699. /**
  62700. * density per facet for surface points
  62701. * @hidden
  62702. */
  62703. _groupDensity: number[];
  62704. /**
  62705. * Only when points are colored by texture carries pointer to texture list array
  62706. * @hidden
  62707. */
  62708. _textureNb: number;
  62709. /**
  62710. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  62711. * PCS internal tool, don't use it manually.
  62712. * @hidden
  62713. */
  62714. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  62715. }
  62716. }
  62717. declare module "babylonjs/Particles/index" {
  62718. export * from "babylonjs/Particles/baseParticleSystem";
  62719. export * from "babylonjs/Particles/EmitterTypes/index";
  62720. export * from "babylonjs/Particles/gpuParticleSystem";
  62721. export * from "babylonjs/Particles/IParticleSystem";
  62722. export * from "babylonjs/Particles/particle";
  62723. export * from "babylonjs/Particles/particleHelper";
  62724. export * from "babylonjs/Particles/particleSystem";
  62725. export * from "babylonjs/Particles/particleSystemComponent";
  62726. export * from "babylonjs/Particles/particleSystemSet";
  62727. export * from "babylonjs/Particles/solidParticle";
  62728. export * from "babylonjs/Particles/solidParticleSystem";
  62729. export * from "babylonjs/Particles/cloudPoint";
  62730. export * from "babylonjs/Particles/pointsCloudSystem";
  62731. export * from "babylonjs/Particles/subEmitter";
  62732. }
  62733. declare module "babylonjs/Physics/physicsEngineComponent" {
  62734. import { Nullable } from "babylonjs/types";
  62735. import { Observable, Observer } from "babylonjs/Misc/observable";
  62736. import { Vector3 } from "babylonjs/Maths/math.vector";
  62737. import { Mesh } from "babylonjs/Meshes/mesh";
  62738. import { ISceneComponent } from "babylonjs/sceneComponent";
  62739. import { Scene } from "babylonjs/scene";
  62740. import { Node } from "babylonjs/node";
  62741. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62742. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62743. module "babylonjs/scene" {
  62744. interface Scene {
  62745. /** @hidden (Backing field) */
  62746. _physicsEngine: Nullable<IPhysicsEngine>;
  62747. /**
  62748. * Gets the current physics engine
  62749. * @returns a IPhysicsEngine or null if none attached
  62750. */
  62751. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  62752. /**
  62753. * Enables physics to the current scene
  62754. * @param gravity defines the scene's gravity for the physics engine
  62755. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  62756. * @return a boolean indicating if the physics engine was initialized
  62757. */
  62758. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  62759. /**
  62760. * Disables and disposes the physics engine associated with the scene
  62761. */
  62762. disablePhysicsEngine(): void;
  62763. /**
  62764. * Gets a boolean indicating if there is an active physics engine
  62765. * @returns a boolean indicating if there is an active physics engine
  62766. */
  62767. isPhysicsEnabled(): boolean;
  62768. /**
  62769. * Deletes a physics compound impostor
  62770. * @param compound defines the compound to delete
  62771. */
  62772. deleteCompoundImpostor(compound: any): void;
  62773. /**
  62774. * An event triggered when physic simulation is about to be run
  62775. */
  62776. onBeforePhysicsObservable: Observable<Scene>;
  62777. /**
  62778. * An event triggered when physic simulation has been done
  62779. */
  62780. onAfterPhysicsObservable: Observable<Scene>;
  62781. }
  62782. }
  62783. module "babylonjs/Meshes/abstractMesh" {
  62784. interface AbstractMesh {
  62785. /** @hidden */
  62786. _physicsImpostor: Nullable<PhysicsImpostor>;
  62787. /**
  62788. * Gets or sets impostor used for physic simulation
  62789. * @see http://doc.babylonjs.com/features/physics_engine
  62790. */
  62791. physicsImpostor: Nullable<PhysicsImpostor>;
  62792. /**
  62793. * Gets the current physics impostor
  62794. * @see http://doc.babylonjs.com/features/physics_engine
  62795. * @returns a physics impostor or null
  62796. */
  62797. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  62798. /** Apply a physic impulse to the mesh
  62799. * @param force defines the force to apply
  62800. * @param contactPoint defines where to apply the force
  62801. * @returns the current mesh
  62802. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  62803. */
  62804. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  62805. /**
  62806. * Creates a physic joint between two meshes
  62807. * @param otherMesh defines the other mesh to use
  62808. * @param pivot1 defines the pivot to use on this mesh
  62809. * @param pivot2 defines the pivot to use on the other mesh
  62810. * @param options defines additional options (can be plugin dependent)
  62811. * @returns the current mesh
  62812. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  62813. */
  62814. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  62815. /** @hidden */
  62816. _disposePhysicsObserver: Nullable<Observer<Node>>;
  62817. }
  62818. }
  62819. /**
  62820. * Defines the physics engine scene component responsible to manage a physics engine
  62821. */
  62822. export class PhysicsEngineSceneComponent implements ISceneComponent {
  62823. /**
  62824. * The component name helpful to identify the component in the list of scene components.
  62825. */
  62826. readonly name: string;
  62827. /**
  62828. * The scene the component belongs to.
  62829. */
  62830. scene: Scene;
  62831. /**
  62832. * Creates a new instance of the component for the given scene
  62833. * @param scene Defines the scene to register the component in
  62834. */
  62835. constructor(scene: Scene);
  62836. /**
  62837. * Registers the component in a given scene
  62838. */
  62839. register(): void;
  62840. /**
  62841. * Rebuilds the elements related to this component in case of
  62842. * context lost for instance.
  62843. */
  62844. rebuild(): void;
  62845. /**
  62846. * Disposes the component and the associated ressources
  62847. */
  62848. dispose(): void;
  62849. }
  62850. }
  62851. declare module "babylonjs/Physics/physicsHelper" {
  62852. import { Nullable } from "babylonjs/types";
  62853. import { Vector3 } from "babylonjs/Maths/math.vector";
  62854. import { Mesh } from "babylonjs/Meshes/mesh";
  62855. import { Scene } from "babylonjs/scene";
  62856. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62857. /**
  62858. * A helper for physics simulations
  62859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62860. */
  62861. export class PhysicsHelper {
  62862. private _scene;
  62863. private _physicsEngine;
  62864. /**
  62865. * Initializes the Physics helper
  62866. * @param scene Babylon.js scene
  62867. */
  62868. constructor(scene: Scene);
  62869. /**
  62870. * Applies a radial explosion impulse
  62871. * @param origin the origin of the explosion
  62872. * @param radiusOrEventOptions the radius or the options of radial explosion
  62873. * @param strength the explosion strength
  62874. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62875. * @returns A physics radial explosion event, or null
  62876. */
  62877. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62878. /**
  62879. * Applies a radial explosion force
  62880. * @param origin the origin of the explosion
  62881. * @param radiusOrEventOptions the radius or the options of radial explosion
  62882. * @param strength the explosion strength
  62883. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62884. * @returns A physics radial explosion event, or null
  62885. */
  62886. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62887. /**
  62888. * Creates a gravitational field
  62889. * @param origin the origin of the explosion
  62890. * @param radiusOrEventOptions the radius or the options of radial explosion
  62891. * @param strength the explosion strength
  62892. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62893. * @returns A physics gravitational field event, or null
  62894. */
  62895. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  62896. /**
  62897. * Creates a physics updraft event
  62898. * @param origin the origin of the updraft
  62899. * @param radiusOrEventOptions the radius or the options of the updraft
  62900. * @param strength the strength of the updraft
  62901. * @param height the height of the updraft
  62902. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  62903. * @returns A physics updraft event, or null
  62904. */
  62905. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  62906. /**
  62907. * Creates a physics vortex event
  62908. * @param origin the of the vortex
  62909. * @param radiusOrEventOptions the radius or the options of the vortex
  62910. * @param strength the strength of the vortex
  62911. * @param height the height of the vortex
  62912. * @returns a Physics vortex event, or null
  62913. * A physics vortex event or null
  62914. */
  62915. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  62916. }
  62917. /**
  62918. * Represents a physics radial explosion event
  62919. */
  62920. class PhysicsRadialExplosionEvent {
  62921. private _scene;
  62922. private _options;
  62923. private _sphere;
  62924. private _dataFetched;
  62925. /**
  62926. * Initializes a radial explosioin event
  62927. * @param _scene BabylonJS scene
  62928. * @param _options The options for the vortex event
  62929. */
  62930. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  62931. /**
  62932. * Returns the data related to the radial explosion event (sphere).
  62933. * @returns The radial explosion event data
  62934. */
  62935. getData(): PhysicsRadialExplosionEventData;
  62936. /**
  62937. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  62938. * @param impostor A physics imposter
  62939. * @param origin the origin of the explosion
  62940. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  62941. */
  62942. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  62943. /**
  62944. * Triggers affecterd impostors callbacks
  62945. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  62946. */
  62947. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  62948. /**
  62949. * Disposes the sphere.
  62950. * @param force Specifies if the sphere should be disposed by force
  62951. */
  62952. dispose(force?: boolean): void;
  62953. /*** Helpers ***/
  62954. private _prepareSphere;
  62955. private _intersectsWithSphere;
  62956. }
  62957. /**
  62958. * Represents a gravitational field event
  62959. */
  62960. class PhysicsGravitationalFieldEvent {
  62961. private _physicsHelper;
  62962. private _scene;
  62963. private _origin;
  62964. private _options;
  62965. private _tickCallback;
  62966. private _sphere;
  62967. private _dataFetched;
  62968. /**
  62969. * Initializes the physics gravitational field event
  62970. * @param _physicsHelper A physics helper
  62971. * @param _scene BabylonJS scene
  62972. * @param _origin The origin position of the gravitational field event
  62973. * @param _options The options for the vortex event
  62974. */
  62975. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  62976. /**
  62977. * Returns the data related to the gravitational field event (sphere).
  62978. * @returns A gravitational field event
  62979. */
  62980. getData(): PhysicsGravitationalFieldEventData;
  62981. /**
  62982. * Enables the gravitational field.
  62983. */
  62984. enable(): void;
  62985. /**
  62986. * Disables the gravitational field.
  62987. */
  62988. disable(): void;
  62989. /**
  62990. * Disposes the sphere.
  62991. * @param force The force to dispose from the gravitational field event
  62992. */
  62993. dispose(force?: boolean): void;
  62994. private _tick;
  62995. }
  62996. /**
  62997. * Represents a physics updraft event
  62998. */
  62999. class PhysicsUpdraftEvent {
  63000. private _scene;
  63001. private _origin;
  63002. private _options;
  63003. private _physicsEngine;
  63004. private _originTop;
  63005. private _originDirection;
  63006. private _tickCallback;
  63007. private _cylinder;
  63008. private _cylinderPosition;
  63009. private _dataFetched;
  63010. /**
  63011. * Initializes the physics updraft event
  63012. * @param _scene BabylonJS scene
  63013. * @param _origin The origin position of the updraft
  63014. * @param _options The options for the updraft event
  63015. */
  63016. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63017. /**
  63018. * Returns the data related to the updraft event (cylinder).
  63019. * @returns A physics updraft event
  63020. */
  63021. getData(): PhysicsUpdraftEventData;
  63022. /**
  63023. * Enables the updraft.
  63024. */
  63025. enable(): void;
  63026. /**
  63027. * Disables the updraft.
  63028. */
  63029. disable(): void;
  63030. /**
  63031. * Disposes the cylinder.
  63032. * @param force Specifies if the updraft should be disposed by force
  63033. */
  63034. dispose(force?: boolean): void;
  63035. private getImpostorHitData;
  63036. private _tick;
  63037. /*** Helpers ***/
  63038. private _prepareCylinder;
  63039. private _intersectsWithCylinder;
  63040. }
  63041. /**
  63042. * Represents a physics vortex event
  63043. */
  63044. class PhysicsVortexEvent {
  63045. private _scene;
  63046. private _origin;
  63047. private _options;
  63048. private _physicsEngine;
  63049. private _originTop;
  63050. private _tickCallback;
  63051. private _cylinder;
  63052. private _cylinderPosition;
  63053. private _dataFetched;
  63054. /**
  63055. * Initializes the physics vortex event
  63056. * @param _scene The BabylonJS scene
  63057. * @param _origin The origin position of the vortex
  63058. * @param _options The options for the vortex event
  63059. */
  63060. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63061. /**
  63062. * Returns the data related to the vortex event (cylinder).
  63063. * @returns The physics vortex event data
  63064. */
  63065. getData(): PhysicsVortexEventData;
  63066. /**
  63067. * Enables the vortex.
  63068. */
  63069. enable(): void;
  63070. /**
  63071. * Disables the cortex.
  63072. */
  63073. disable(): void;
  63074. /**
  63075. * Disposes the sphere.
  63076. * @param force
  63077. */
  63078. dispose(force?: boolean): void;
  63079. private getImpostorHitData;
  63080. private _tick;
  63081. /*** Helpers ***/
  63082. private _prepareCylinder;
  63083. private _intersectsWithCylinder;
  63084. }
  63085. /**
  63086. * Options fot the radial explosion event
  63087. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63088. */
  63089. export class PhysicsRadialExplosionEventOptions {
  63090. /**
  63091. * The radius of the sphere for the radial explosion.
  63092. */
  63093. radius: number;
  63094. /**
  63095. * The strenth of the explosion.
  63096. */
  63097. strength: number;
  63098. /**
  63099. * The strenght of the force in correspondence to the distance of the affected object
  63100. */
  63101. falloff: PhysicsRadialImpulseFalloff;
  63102. /**
  63103. * Sphere options for the radial explosion.
  63104. */
  63105. sphere: {
  63106. segments: number;
  63107. diameter: number;
  63108. };
  63109. /**
  63110. * Sphere options for the radial explosion.
  63111. */
  63112. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63113. }
  63114. /**
  63115. * Options fot the updraft event
  63116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63117. */
  63118. export class PhysicsUpdraftEventOptions {
  63119. /**
  63120. * The radius of the cylinder for the vortex
  63121. */
  63122. radius: number;
  63123. /**
  63124. * The strenth of the updraft.
  63125. */
  63126. strength: number;
  63127. /**
  63128. * The height of the cylinder for the updraft.
  63129. */
  63130. height: number;
  63131. /**
  63132. * The mode for the the updraft.
  63133. */
  63134. updraftMode: PhysicsUpdraftMode;
  63135. }
  63136. /**
  63137. * Options fot the vortex event
  63138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63139. */
  63140. export class PhysicsVortexEventOptions {
  63141. /**
  63142. * The radius of the cylinder for the vortex
  63143. */
  63144. radius: number;
  63145. /**
  63146. * The strenth of the vortex.
  63147. */
  63148. strength: number;
  63149. /**
  63150. * The height of the cylinder for the vortex.
  63151. */
  63152. height: number;
  63153. /**
  63154. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63155. */
  63156. centripetalForceThreshold: number;
  63157. /**
  63158. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63159. */
  63160. centripetalForceMultiplier: number;
  63161. /**
  63162. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63163. */
  63164. centrifugalForceMultiplier: number;
  63165. /**
  63166. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63167. */
  63168. updraftForceMultiplier: number;
  63169. }
  63170. /**
  63171. * The strenght of the force in correspondence to the distance of the affected object
  63172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63173. */
  63174. export enum PhysicsRadialImpulseFalloff {
  63175. /** Defines that impulse is constant in strength across it's whole radius */
  63176. Constant = 0,
  63177. /** Defines that impulse gets weaker if it's further from the origin */
  63178. Linear = 1
  63179. }
  63180. /**
  63181. * The strength of the force in correspondence to the distance of the affected object
  63182. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63183. */
  63184. export enum PhysicsUpdraftMode {
  63185. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63186. Center = 0,
  63187. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63188. Perpendicular = 1
  63189. }
  63190. /**
  63191. * Interface for a physics hit data
  63192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63193. */
  63194. export interface PhysicsHitData {
  63195. /**
  63196. * The force applied at the contact point
  63197. */
  63198. force: Vector3;
  63199. /**
  63200. * The contact point
  63201. */
  63202. contactPoint: Vector3;
  63203. /**
  63204. * The distance from the origin to the contact point
  63205. */
  63206. distanceFromOrigin: number;
  63207. }
  63208. /**
  63209. * Interface for radial explosion event data
  63210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63211. */
  63212. export interface PhysicsRadialExplosionEventData {
  63213. /**
  63214. * A sphere used for the radial explosion event
  63215. */
  63216. sphere: Mesh;
  63217. }
  63218. /**
  63219. * Interface for gravitational field event data
  63220. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63221. */
  63222. export interface PhysicsGravitationalFieldEventData {
  63223. /**
  63224. * A sphere mesh used for the gravitational field event
  63225. */
  63226. sphere: Mesh;
  63227. }
  63228. /**
  63229. * Interface for updraft event data
  63230. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63231. */
  63232. export interface PhysicsUpdraftEventData {
  63233. /**
  63234. * A cylinder used for the updraft event
  63235. */
  63236. cylinder: Mesh;
  63237. }
  63238. /**
  63239. * Interface for vortex event data
  63240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63241. */
  63242. export interface PhysicsVortexEventData {
  63243. /**
  63244. * A cylinder used for the vortex event
  63245. */
  63246. cylinder: Mesh;
  63247. }
  63248. /**
  63249. * Interface for an affected physics impostor
  63250. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63251. */
  63252. export interface PhysicsAffectedImpostorWithData {
  63253. /**
  63254. * The impostor affected by the effect
  63255. */
  63256. impostor: PhysicsImpostor;
  63257. /**
  63258. * The data about the hit/horce from the explosion
  63259. */
  63260. hitData: PhysicsHitData;
  63261. }
  63262. }
  63263. declare module "babylonjs/Physics/Plugins/index" {
  63264. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  63265. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  63266. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  63267. }
  63268. declare module "babylonjs/Physics/index" {
  63269. export * from "babylonjs/Physics/IPhysicsEngine";
  63270. export * from "babylonjs/Physics/physicsEngine";
  63271. export * from "babylonjs/Physics/physicsEngineComponent";
  63272. export * from "babylonjs/Physics/physicsHelper";
  63273. export * from "babylonjs/Physics/physicsImpostor";
  63274. export * from "babylonjs/Physics/physicsJoint";
  63275. export * from "babylonjs/Physics/Plugins/index";
  63276. }
  63277. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  63278. /** @hidden */
  63279. export var blackAndWhitePixelShader: {
  63280. name: string;
  63281. shader: string;
  63282. };
  63283. }
  63284. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  63285. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63286. import { Camera } from "babylonjs/Cameras/camera";
  63287. import { Engine } from "babylonjs/Engines/engine";
  63288. import "babylonjs/Shaders/blackAndWhite.fragment";
  63289. /**
  63290. * Post process used to render in black and white
  63291. */
  63292. export class BlackAndWhitePostProcess extends PostProcess {
  63293. /**
  63294. * Linear about to convert he result to black and white (default: 1)
  63295. */
  63296. degree: number;
  63297. /**
  63298. * Creates a black and white post process
  63299. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63300. * @param name The name of the effect.
  63301. * @param options The required width/height ratio to downsize to before computing the render pass.
  63302. * @param camera The camera to apply the render pass to.
  63303. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63304. * @param engine The engine which the post process will be applied. (default: current engine)
  63305. * @param reusable If the post process can be reused on the same frame. (default: false)
  63306. */
  63307. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63308. }
  63309. }
  63310. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  63311. import { Nullable } from "babylonjs/types";
  63312. import { Camera } from "babylonjs/Cameras/camera";
  63313. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63314. import { Engine } from "babylonjs/Engines/engine";
  63315. /**
  63316. * This represents a set of one or more post processes in Babylon.
  63317. * A post process can be used to apply a shader to a texture after it is rendered.
  63318. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63319. */
  63320. export class PostProcessRenderEffect {
  63321. private _postProcesses;
  63322. private _getPostProcesses;
  63323. private _singleInstance;
  63324. private _cameras;
  63325. private _indicesForCamera;
  63326. /**
  63327. * Name of the effect
  63328. * @hidden
  63329. */
  63330. _name: string;
  63331. /**
  63332. * Instantiates a post process render effect.
  63333. * A post process can be used to apply a shader to a texture after it is rendered.
  63334. * @param engine The engine the effect is tied to
  63335. * @param name The name of the effect
  63336. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63337. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63338. */
  63339. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63340. /**
  63341. * Checks if all the post processes in the effect are supported.
  63342. */
  63343. readonly isSupported: boolean;
  63344. /**
  63345. * Updates the current state of the effect
  63346. * @hidden
  63347. */
  63348. _update(): void;
  63349. /**
  63350. * Attaches the effect on cameras
  63351. * @param cameras The camera to attach to.
  63352. * @hidden
  63353. */
  63354. _attachCameras(cameras: Camera): void;
  63355. /**
  63356. * Attaches the effect on cameras
  63357. * @param cameras The camera to attach to.
  63358. * @hidden
  63359. */
  63360. _attachCameras(cameras: Camera[]): void;
  63361. /**
  63362. * Detaches the effect on cameras
  63363. * @param cameras The camera to detatch from.
  63364. * @hidden
  63365. */
  63366. _detachCameras(cameras: Camera): void;
  63367. /**
  63368. * Detatches the effect on cameras
  63369. * @param cameras The camera to detatch from.
  63370. * @hidden
  63371. */
  63372. _detachCameras(cameras: Camera[]): void;
  63373. /**
  63374. * Enables the effect on given cameras
  63375. * @param cameras The camera to enable.
  63376. * @hidden
  63377. */
  63378. _enable(cameras: Camera): void;
  63379. /**
  63380. * Enables the effect on given cameras
  63381. * @param cameras The camera to enable.
  63382. * @hidden
  63383. */
  63384. _enable(cameras: Nullable<Camera[]>): void;
  63385. /**
  63386. * Disables the effect on the given cameras
  63387. * @param cameras The camera to disable.
  63388. * @hidden
  63389. */
  63390. _disable(cameras: Camera): void;
  63391. /**
  63392. * Disables the effect on the given cameras
  63393. * @param cameras The camera to disable.
  63394. * @hidden
  63395. */
  63396. _disable(cameras: Nullable<Camera[]>): void;
  63397. /**
  63398. * Gets a list of the post processes contained in the effect.
  63399. * @param camera The camera to get the post processes on.
  63400. * @returns The list of the post processes in the effect.
  63401. */
  63402. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63403. }
  63404. }
  63405. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  63406. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63407. /** @hidden */
  63408. export var extractHighlightsPixelShader: {
  63409. name: string;
  63410. shader: string;
  63411. };
  63412. }
  63413. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  63414. import { Nullable } from "babylonjs/types";
  63415. import { Camera } from "babylonjs/Cameras/camera";
  63416. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63417. import { Engine } from "babylonjs/Engines/engine";
  63418. import "babylonjs/Shaders/extractHighlights.fragment";
  63419. /**
  63420. * 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.
  63421. */
  63422. export class ExtractHighlightsPostProcess extends PostProcess {
  63423. /**
  63424. * The luminance threshold, pixels below this value will be set to black.
  63425. */
  63426. threshold: number;
  63427. /** @hidden */
  63428. _exposure: number;
  63429. /**
  63430. * Post process which has the input texture to be used when performing highlight extraction
  63431. * @hidden
  63432. */
  63433. _inputPostProcess: Nullable<PostProcess>;
  63434. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63435. }
  63436. }
  63437. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  63438. /** @hidden */
  63439. export var bloomMergePixelShader: {
  63440. name: string;
  63441. shader: string;
  63442. };
  63443. }
  63444. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  63445. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63446. import { Nullable } from "babylonjs/types";
  63447. import { Engine } from "babylonjs/Engines/engine";
  63448. import { Camera } from "babylonjs/Cameras/camera";
  63449. import "babylonjs/Shaders/bloomMerge.fragment";
  63450. /**
  63451. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63452. */
  63453. export class BloomMergePostProcess extends PostProcess {
  63454. /** Weight of the bloom to be added to the original input. */
  63455. weight: number;
  63456. /**
  63457. * Creates a new instance of @see BloomMergePostProcess
  63458. * @param name The name of the effect.
  63459. * @param originalFromInput Post process which's input will be used for the merge.
  63460. * @param blurred Blurred highlights post process which's output will be used.
  63461. * @param weight Weight of the bloom to be added to the original input.
  63462. * @param options The required width/height ratio to downsize to before computing the render pass.
  63463. * @param camera The camera to apply the render pass to.
  63464. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63465. * @param engine The engine which the post process will be applied. (default: current engine)
  63466. * @param reusable If the post process can be reused on the same frame. (default: false)
  63467. * @param textureType Type of textures used when performing the post process. (default: 0)
  63468. * @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)
  63469. */
  63470. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  63471. /** Weight of the bloom to be added to the original input. */
  63472. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63473. }
  63474. }
  63475. declare module "babylonjs/PostProcesses/bloomEffect" {
  63476. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63477. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63478. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63479. import { Camera } from "babylonjs/Cameras/camera";
  63480. import { Scene } from "babylonjs/scene";
  63481. /**
  63482. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  63483. */
  63484. export class BloomEffect extends PostProcessRenderEffect {
  63485. private bloomScale;
  63486. /**
  63487. * @hidden Internal
  63488. */
  63489. _effects: Array<PostProcess>;
  63490. /**
  63491. * @hidden Internal
  63492. */
  63493. _downscale: ExtractHighlightsPostProcess;
  63494. private _blurX;
  63495. private _blurY;
  63496. private _merge;
  63497. /**
  63498. * The luminance threshold to find bright areas of the image to bloom.
  63499. */
  63500. threshold: number;
  63501. /**
  63502. * The strength of the bloom.
  63503. */
  63504. weight: number;
  63505. /**
  63506. * Specifies the size of the bloom blur kernel, relative to the final output size
  63507. */
  63508. kernel: number;
  63509. /**
  63510. * Creates a new instance of @see BloomEffect
  63511. * @param scene The scene the effect belongs to.
  63512. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  63513. * @param bloomKernel The size of the kernel to be used when applying the blur.
  63514. * @param bloomWeight The the strength of bloom.
  63515. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63516. * @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)
  63517. */
  63518. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  63519. /**
  63520. * Disposes each of the internal effects for a given camera.
  63521. * @param camera The camera to dispose the effect on.
  63522. */
  63523. disposeEffects(camera: Camera): void;
  63524. /**
  63525. * @hidden Internal
  63526. */
  63527. _updateEffects(): void;
  63528. /**
  63529. * Internal
  63530. * @returns if all the contained post processes are ready.
  63531. * @hidden
  63532. */
  63533. _isReady(): boolean;
  63534. }
  63535. }
  63536. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  63537. /** @hidden */
  63538. export var chromaticAberrationPixelShader: {
  63539. name: string;
  63540. shader: string;
  63541. };
  63542. }
  63543. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  63544. import { Vector2 } from "babylonjs/Maths/math.vector";
  63545. import { Nullable } from "babylonjs/types";
  63546. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63547. import { Camera } from "babylonjs/Cameras/camera";
  63548. import { Engine } from "babylonjs/Engines/engine";
  63549. import "babylonjs/Shaders/chromaticAberration.fragment";
  63550. /**
  63551. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  63552. */
  63553. export class ChromaticAberrationPostProcess extends PostProcess {
  63554. /**
  63555. * The amount of seperation of rgb channels (default: 30)
  63556. */
  63557. aberrationAmount: number;
  63558. /**
  63559. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  63560. */
  63561. radialIntensity: number;
  63562. /**
  63563. * 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))
  63564. */
  63565. direction: Vector2;
  63566. /**
  63567. * 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))
  63568. */
  63569. centerPosition: Vector2;
  63570. /**
  63571. * Creates a new instance ChromaticAberrationPostProcess
  63572. * @param name The name of the effect.
  63573. * @param screenWidth The width of the screen to apply the effect on.
  63574. * @param screenHeight The height of the screen to apply the effect on.
  63575. * @param options The required width/height ratio to downsize to before computing the render pass.
  63576. * @param camera The camera to apply the render pass to.
  63577. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63578. * @param engine The engine which the post process will be applied. (default: current engine)
  63579. * @param reusable If the post process can be reused on the same frame. (default: false)
  63580. * @param textureType Type of textures used when performing the post process. (default: 0)
  63581. * @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)
  63582. */
  63583. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63584. }
  63585. }
  63586. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  63587. /** @hidden */
  63588. export var circleOfConfusionPixelShader: {
  63589. name: string;
  63590. shader: string;
  63591. };
  63592. }
  63593. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  63594. import { Nullable } from "babylonjs/types";
  63595. import { Engine } from "babylonjs/Engines/engine";
  63596. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63597. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63598. import { Camera } from "babylonjs/Cameras/camera";
  63599. import "babylonjs/Shaders/circleOfConfusion.fragment";
  63600. /**
  63601. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  63602. */
  63603. export class CircleOfConfusionPostProcess extends PostProcess {
  63604. /**
  63605. * 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.
  63606. */
  63607. lensSize: number;
  63608. /**
  63609. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63610. */
  63611. fStop: number;
  63612. /**
  63613. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63614. */
  63615. focusDistance: number;
  63616. /**
  63617. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  63618. */
  63619. focalLength: number;
  63620. private _depthTexture;
  63621. /**
  63622. * Creates a new instance CircleOfConfusionPostProcess
  63623. * @param name The name of the effect.
  63624. * @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.
  63625. * @param options The required width/height ratio to downsize to before computing the render pass.
  63626. * @param camera The camera to apply the render pass to.
  63627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63628. * @param engine The engine which the post process will be applied. (default: current engine)
  63629. * @param reusable If the post process can be reused on the same frame. (default: false)
  63630. * @param textureType Type of textures used when performing the post process. (default: 0)
  63631. * @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)
  63632. */
  63633. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63634. /**
  63635. * 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.
  63636. */
  63637. depthTexture: RenderTargetTexture;
  63638. }
  63639. }
  63640. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  63641. /** @hidden */
  63642. export var colorCorrectionPixelShader: {
  63643. name: string;
  63644. shader: string;
  63645. };
  63646. }
  63647. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  63648. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63649. import { Engine } from "babylonjs/Engines/engine";
  63650. import { Camera } from "babylonjs/Cameras/camera";
  63651. import "babylonjs/Shaders/colorCorrection.fragment";
  63652. /**
  63653. *
  63654. * This post-process allows the modification of rendered colors by using
  63655. * a 'look-up table' (LUT). This effect is also called Color Grading.
  63656. *
  63657. * The object needs to be provided an url to a texture containing the color
  63658. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  63659. * Use an image editing software to tweak the LUT to match your needs.
  63660. *
  63661. * For an example of a color LUT, see here:
  63662. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  63663. * For explanations on color grading, see here:
  63664. * @see http://udn.epicgames.com/Three/ColorGrading.html
  63665. *
  63666. */
  63667. export class ColorCorrectionPostProcess extends PostProcess {
  63668. private _colorTableTexture;
  63669. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63670. }
  63671. }
  63672. declare module "babylonjs/Shaders/convolution.fragment" {
  63673. /** @hidden */
  63674. export var convolutionPixelShader: {
  63675. name: string;
  63676. shader: string;
  63677. };
  63678. }
  63679. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  63680. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63681. import { Nullable } from "babylonjs/types";
  63682. import { Camera } from "babylonjs/Cameras/camera";
  63683. import { Engine } from "babylonjs/Engines/engine";
  63684. import "babylonjs/Shaders/convolution.fragment";
  63685. /**
  63686. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  63687. * input texture to perform effects such as edge detection or sharpening
  63688. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63689. */
  63690. export class ConvolutionPostProcess extends PostProcess {
  63691. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63692. kernel: number[];
  63693. /**
  63694. * Creates a new instance ConvolutionPostProcess
  63695. * @param name The name of the effect.
  63696. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  63697. * @param options The required width/height ratio to downsize to before computing the render pass.
  63698. * @param camera The camera to apply the render pass to.
  63699. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63700. * @param engine The engine which the post process will be applied. (default: current engine)
  63701. * @param reusable If the post process can be reused on the same frame. (default: false)
  63702. * @param textureType Type of textures used when performing the post process. (default: 0)
  63703. */
  63704. constructor(name: string,
  63705. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63706. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63707. /**
  63708. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63709. */
  63710. static EdgeDetect0Kernel: number[];
  63711. /**
  63712. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63713. */
  63714. static EdgeDetect1Kernel: number[];
  63715. /**
  63716. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63717. */
  63718. static EdgeDetect2Kernel: number[];
  63719. /**
  63720. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63721. */
  63722. static SharpenKernel: number[];
  63723. /**
  63724. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63725. */
  63726. static EmbossKernel: number[];
  63727. /**
  63728. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63729. */
  63730. static GaussianKernel: number[];
  63731. }
  63732. }
  63733. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  63734. import { Nullable } from "babylonjs/types";
  63735. import { Vector2 } from "babylonjs/Maths/math.vector";
  63736. import { Camera } from "babylonjs/Cameras/camera";
  63737. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63738. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63739. import { Engine } from "babylonjs/Engines/engine";
  63740. import { Scene } from "babylonjs/scene";
  63741. /**
  63742. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  63743. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  63744. * based on samples that have a large difference in distance than the center pixel.
  63745. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  63746. */
  63747. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  63748. direction: Vector2;
  63749. /**
  63750. * Creates a new instance CircleOfConfusionPostProcess
  63751. * @param name The name of the effect.
  63752. * @param scene The scene the effect belongs to.
  63753. * @param direction The direction the blur should be applied.
  63754. * @param kernel The size of the kernel used to blur.
  63755. * @param options The required width/height ratio to downsize to before computing the render pass.
  63756. * @param camera The camera to apply the render pass to.
  63757. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  63758. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  63759. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63760. * @param engine The engine which the post process will be applied. (default: current engine)
  63761. * @param reusable If the post process can be reused on the same frame. (default: false)
  63762. * @param textureType Type of textures used when performing the post process. (default: 0)
  63763. * @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)
  63764. */
  63765. 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);
  63766. }
  63767. }
  63768. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  63769. /** @hidden */
  63770. export var depthOfFieldMergePixelShader: {
  63771. name: string;
  63772. shader: string;
  63773. };
  63774. }
  63775. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  63776. import { Nullable } from "babylonjs/types";
  63777. import { Camera } from "babylonjs/Cameras/camera";
  63778. import { Effect } from "babylonjs/Materials/effect";
  63779. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63780. import { Engine } from "babylonjs/Engines/engine";
  63781. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  63782. /**
  63783. * Options to be set when merging outputs from the default pipeline.
  63784. */
  63785. export class DepthOfFieldMergePostProcessOptions {
  63786. /**
  63787. * The original image to merge on top of
  63788. */
  63789. originalFromInput: PostProcess;
  63790. /**
  63791. * Parameters to perform the merge of the depth of field effect
  63792. */
  63793. depthOfField?: {
  63794. circleOfConfusion: PostProcess;
  63795. blurSteps: Array<PostProcess>;
  63796. };
  63797. /**
  63798. * Parameters to perform the merge of bloom effect
  63799. */
  63800. bloom?: {
  63801. blurred: PostProcess;
  63802. weight: number;
  63803. };
  63804. }
  63805. /**
  63806. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63807. */
  63808. export class DepthOfFieldMergePostProcess extends PostProcess {
  63809. private blurSteps;
  63810. /**
  63811. * Creates a new instance of DepthOfFieldMergePostProcess
  63812. * @param name The name of the effect.
  63813. * @param originalFromInput Post process which's input will be used for the merge.
  63814. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  63815. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  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. * @param textureType Type of textures used when performing the post process. (default: 0)
  63822. * @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)
  63823. */
  63824. 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);
  63825. /**
  63826. * Updates the effect with the current post process compile time values and recompiles the shader.
  63827. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  63828. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  63829. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  63830. * @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
  63831. * @param onCompiled Called when the shader has been compiled.
  63832. * @param onError Called if there is an error when compiling a shader.
  63833. */
  63834. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  63835. }
  63836. }
  63837. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  63838. import { Nullable } from "babylonjs/types";
  63839. import { Camera } from "babylonjs/Cameras/camera";
  63840. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63841. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63842. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63843. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63844. import { Scene } from "babylonjs/scene";
  63845. /**
  63846. * Specifies the level of max blur that should be applied when using the depth of field effect
  63847. */
  63848. export enum DepthOfFieldEffectBlurLevel {
  63849. /**
  63850. * Subtle blur
  63851. */
  63852. Low = 0,
  63853. /**
  63854. * Medium blur
  63855. */
  63856. Medium = 1,
  63857. /**
  63858. * Large blur
  63859. */
  63860. High = 2
  63861. }
  63862. /**
  63863. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  63864. */
  63865. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  63866. private _circleOfConfusion;
  63867. /**
  63868. * @hidden Internal, blurs from high to low
  63869. */
  63870. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  63871. private _depthOfFieldBlurY;
  63872. private _dofMerge;
  63873. /**
  63874. * @hidden Internal post processes in depth of field effect
  63875. */
  63876. _effects: Array<PostProcess>;
  63877. /**
  63878. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  63879. */
  63880. focalLength: number;
  63881. /**
  63882. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63883. */
  63884. fStop: number;
  63885. /**
  63886. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63887. */
  63888. focusDistance: number;
  63889. /**
  63890. * 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.
  63891. */
  63892. lensSize: number;
  63893. /**
  63894. * Creates a new instance DepthOfFieldEffect
  63895. * @param scene The scene the effect belongs to.
  63896. * @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.
  63897. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63898. * @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)
  63899. */
  63900. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  63901. /**
  63902. * Get the current class name of the current effet
  63903. * @returns "DepthOfFieldEffect"
  63904. */
  63905. getClassName(): string;
  63906. /**
  63907. * 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.
  63908. */
  63909. depthTexture: RenderTargetTexture;
  63910. /**
  63911. * Disposes each of the internal effects for a given camera.
  63912. * @param camera The camera to dispose the effect on.
  63913. */
  63914. disposeEffects(camera: Camera): void;
  63915. /**
  63916. * @hidden Internal
  63917. */
  63918. _updateEffects(): void;
  63919. /**
  63920. * Internal
  63921. * @returns if all the contained post processes are ready.
  63922. * @hidden
  63923. */
  63924. _isReady(): boolean;
  63925. }
  63926. }
  63927. declare module "babylonjs/Shaders/displayPass.fragment" {
  63928. /** @hidden */
  63929. export var displayPassPixelShader: {
  63930. name: string;
  63931. shader: string;
  63932. };
  63933. }
  63934. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  63935. import { Nullable } from "babylonjs/types";
  63936. import { Camera } from "babylonjs/Cameras/camera";
  63937. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63938. import { Engine } from "babylonjs/Engines/engine";
  63939. import "babylonjs/Shaders/displayPass.fragment";
  63940. /**
  63941. * DisplayPassPostProcess which produces an output the same as it's input
  63942. */
  63943. export class DisplayPassPostProcess extends PostProcess {
  63944. /**
  63945. * Creates the DisplayPassPostProcess
  63946. * @param name The name of the effect.
  63947. * @param options The required width/height ratio to downsize to before computing the render pass.
  63948. * @param camera The camera to apply the render pass to.
  63949. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63950. * @param engine The engine which the post process will be applied. (default: current engine)
  63951. * @param reusable If the post process can be reused on the same frame. (default: false)
  63952. */
  63953. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63954. }
  63955. }
  63956. declare module "babylonjs/Shaders/filter.fragment" {
  63957. /** @hidden */
  63958. export var filterPixelShader: {
  63959. name: string;
  63960. shader: string;
  63961. };
  63962. }
  63963. declare module "babylonjs/PostProcesses/filterPostProcess" {
  63964. import { Nullable } from "babylonjs/types";
  63965. import { Matrix } from "babylonjs/Maths/math.vector";
  63966. import { Camera } from "babylonjs/Cameras/camera";
  63967. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63968. import { Engine } from "babylonjs/Engines/engine";
  63969. import "babylonjs/Shaders/filter.fragment";
  63970. /**
  63971. * Applies a kernel filter to the image
  63972. */
  63973. export class FilterPostProcess extends PostProcess {
  63974. /** The matrix to be applied to the image */
  63975. kernelMatrix: Matrix;
  63976. /**
  63977. *
  63978. * @param name The name of the effect.
  63979. * @param kernelMatrix The matrix to be applied to the image
  63980. * @param options The required width/height ratio to downsize to before computing the render pass.
  63981. * @param camera The camera to apply the render pass to.
  63982. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63983. * @param engine The engine which the post process will be applied. (default: current engine)
  63984. * @param reusable If the post process can be reused on the same frame. (default: false)
  63985. */
  63986. constructor(name: string,
  63987. /** The matrix to be applied to the image */
  63988. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63989. }
  63990. }
  63991. declare module "babylonjs/Shaders/fxaa.fragment" {
  63992. /** @hidden */
  63993. export var fxaaPixelShader: {
  63994. name: string;
  63995. shader: string;
  63996. };
  63997. }
  63998. declare module "babylonjs/Shaders/fxaa.vertex" {
  63999. /** @hidden */
  64000. export var fxaaVertexShader: {
  64001. name: string;
  64002. shader: string;
  64003. };
  64004. }
  64005. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  64006. import { Nullable } from "babylonjs/types";
  64007. import { Camera } from "babylonjs/Cameras/camera";
  64008. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64009. import { Engine } from "babylonjs/Engines/engine";
  64010. import "babylonjs/Shaders/fxaa.fragment";
  64011. import "babylonjs/Shaders/fxaa.vertex";
  64012. /**
  64013. * Fxaa post process
  64014. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64015. */
  64016. export class FxaaPostProcess extends PostProcess {
  64017. /** @hidden */
  64018. texelWidth: number;
  64019. /** @hidden */
  64020. texelHeight: number;
  64021. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64022. private _getDefines;
  64023. }
  64024. }
  64025. declare module "babylonjs/Shaders/grain.fragment" {
  64026. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64027. /** @hidden */
  64028. export var grainPixelShader: {
  64029. name: string;
  64030. shader: string;
  64031. };
  64032. }
  64033. declare module "babylonjs/PostProcesses/grainPostProcess" {
  64034. import { Nullable } from "babylonjs/types";
  64035. import { Camera } from "babylonjs/Cameras/camera";
  64036. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64037. import { Engine } from "babylonjs/Engines/engine";
  64038. import "babylonjs/Shaders/grain.fragment";
  64039. /**
  64040. * The GrainPostProcess adds noise to the image at mid luminance levels
  64041. */
  64042. export class GrainPostProcess extends PostProcess {
  64043. /**
  64044. * The intensity of the grain added (default: 30)
  64045. */
  64046. intensity: number;
  64047. /**
  64048. * If the grain should be randomized on every frame
  64049. */
  64050. animated: boolean;
  64051. /**
  64052. * Creates a new instance of @see GrainPostProcess
  64053. * @param name The name of the effect.
  64054. * @param options The required width/height ratio to downsize to before computing the render pass.
  64055. * @param camera The camera to apply the render pass to.
  64056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64057. * @param engine The engine which the post process will be applied. (default: current engine)
  64058. * @param reusable If the post process can be reused on the same frame. (default: false)
  64059. * @param textureType Type of textures used when performing the post process. (default: 0)
  64060. * @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)
  64061. */
  64062. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64063. }
  64064. }
  64065. declare module "babylonjs/Shaders/highlights.fragment" {
  64066. /** @hidden */
  64067. export var highlightsPixelShader: {
  64068. name: string;
  64069. shader: string;
  64070. };
  64071. }
  64072. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  64073. import { Nullable } from "babylonjs/types";
  64074. import { Camera } from "babylonjs/Cameras/camera";
  64075. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64076. import { Engine } from "babylonjs/Engines/engine";
  64077. import "babylonjs/Shaders/highlights.fragment";
  64078. /**
  64079. * Extracts highlights from the image
  64080. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64081. */
  64082. export class HighlightsPostProcess extends PostProcess {
  64083. /**
  64084. * Extracts highlights from the image
  64085. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64086. * @param name The name of the effect.
  64087. * @param options The required width/height ratio to downsize to before computing the render pass.
  64088. * @param camera The camera to apply the render pass to.
  64089. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64090. * @param engine The engine which the post process will be applied. (default: current engine)
  64091. * @param reusable If the post process can be reused on the same frame. (default: false)
  64092. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64093. */
  64094. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64095. }
  64096. }
  64097. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  64098. /** @hidden */
  64099. export var mrtFragmentDeclaration: {
  64100. name: string;
  64101. shader: string;
  64102. };
  64103. }
  64104. declare module "babylonjs/Shaders/geometry.fragment" {
  64105. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  64106. /** @hidden */
  64107. export var geometryPixelShader: {
  64108. name: string;
  64109. shader: string;
  64110. };
  64111. }
  64112. declare module "babylonjs/Shaders/geometry.vertex" {
  64113. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64114. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64115. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64116. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64117. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64118. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64119. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64120. /** @hidden */
  64121. export var geometryVertexShader: {
  64122. name: string;
  64123. shader: string;
  64124. };
  64125. }
  64126. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  64127. import { Matrix } from "babylonjs/Maths/math.vector";
  64128. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64129. import { Mesh } from "babylonjs/Meshes/mesh";
  64130. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  64131. import { Effect } from "babylonjs/Materials/effect";
  64132. import { Scene } from "babylonjs/scene";
  64133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64134. import "babylonjs/Shaders/geometry.fragment";
  64135. import "babylonjs/Shaders/geometry.vertex";
  64136. /** @hidden */
  64137. interface ISavedTransformationMatrix {
  64138. world: Matrix;
  64139. viewProjection: Matrix;
  64140. }
  64141. /**
  64142. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64143. */
  64144. export class GeometryBufferRenderer {
  64145. /**
  64146. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64147. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64148. */
  64149. static readonly POSITION_TEXTURE_TYPE: number;
  64150. /**
  64151. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64152. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64153. */
  64154. static readonly VELOCITY_TEXTURE_TYPE: number;
  64155. /**
  64156. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64157. * in order to compute objects velocities when enableVelocity is set to "true"
  64158. * @hidden
  64159. */
  64160. _previousTransformationMatrices: {
  64161. [index: number]: ISavedTransformationMatrix;
  64162. };
  64163. /**
  64164. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64165. * in order to compute objects velocities when enableVelocity is set to "true"
  64166. * @hidden
  64167. */
  64168. _previousBonesTransformationMatrices: {
  64169. [index: number]: Float32Array;
  64170. };
  64171. /**
  64172. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64173. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64174. */
  64175. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64176. private _scene;
  64177. private _multiRenderTarget;
  64178. private _ratio;
  64179. private _enablePosition;
  64180. private _enableVelocity;
  64181. private _positionIndex;
  64182. private _velocityIndex;
  64183. protected _effect: Effect;
  64184. protected _cachedDefines: string;
  64185. /**
  64186. * Set the render list (meshes to be rendered) used in the G buffer.
  64187. */
  64188. renderList: Mesh[];
  64189. /**
  64190. * Gets wether or not G buffer are supported by the running hardware.
  64191. * This requires draw buffer supports
  64192. */
  64193. readonly isSupported: boolean;
  64194. /**
  64195. * Returns the index of the given texture type in the G-Buffer textures array
  64196. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64197. * @returns the index of the given texture type in the G-Buffer textures array
  64198. */
  64199. getTextureIndex(textureType: number): number;
  64200. /**
  64201. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64202. */
  64203. /**
  64204. * Sets whether or not objects positions are enabled for the G buffer.
  64205. */
  64206. enablePosition: boolean;
  64207. /**
  64208. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64209. */
  64210. /**
  64211. * Sets wether or not objects velocities are enabled for the G buffer.
  64212. */
  64213. enableVelocity: boolean;
  64214. /**
  64215. * Gets the scene associated with the buffer.
  64216. */
  64217. readonly scene: Scene;
  64218. /**
  64219. * Gets the ratio used by the buffer during its creation.
  64220. * How big is the buffer related to the main canvas.
  64221. */
  64222. readonly ratio: number;
  64223. /** @hidden */
  64224. static _SceneComponentInitialization: (scene: Scene) => void;
  64225. /**
  64226. * Creates a new G Buffer for the scene
  64227. * @param scene The scene the buffer belongs to
  64228. * @param ratio How big is the buffer related to the main canvas.
  64229. */
  64230. constructor(scene: Scene, ratio?: number);
  64231. /**
  64232. * Checks wether everything is ready to render a submesh to the G buffer.
  64233. * @param subMesh the submesh to check readiness for
  64234. * @param useInstances is the mesh drawn using instance or not
  64235. * @returns true if ready otherwise false
  64236. */
  64237. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64238. /**
  64239. * Gets the current underlying G Buffer.
  64240. * @returns the buffer
  64241. */
  64242. getGBuffer(): MultiRenderTarget;
  64243. /**
  64244. * Gets the number of samples used to render the buffer (anti aliasing).
  64245. */
  64246. /**
  64247. * Sets the number of samples used to render the buffer (anti aliasing).
  64248. */
  64249. samples: number;
  64250. /**
  64251. * Disposes the renderer and frees up associated resources.
  64252. */
  64253. dispose(): void;
  64254. protected _createRenderTargets(): void;
  64255. private _copyBonesTransformationMatrices;
  64256. }
  64257. }
  64258. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  64259. import { Nullable } from "babylonjs/types";
  64260. import { Scene } from "babylonjs/scene";
  64261. import { ISceneComponent } from "babylonjs/sceneComponent";
  64262. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  64263. module "babylonjs/scene" {
  64264. interface Scene {
  64265. /** @hidden (Backing field) */
  64266. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64267. /**
  64268. * Gets or Sets the current geometry buffer associated to the scene.
  64269. */
  64270. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64271. /**
  64272. * Enables a GeometryBufferRender and associates it with the scene
  64273. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64274. * @returns the GeometryBufferRenderer
  64275. */
  64276. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64277. /**
  64278. * Disables the GeometryBufferRender associated with the scene
  64279. */
  64280. disableGeometryBufferRenderer(): void;
  64281. }
  64282. }
  64283. /**
  64284. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64285. * in several rendering techniques.
  64286. */
  64287. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64288. /**
  64289. * The component name helpful to identify the component in the list of scene components.
  64290. */
  64291. readonly name: string;
  64292. /**
  64293. * The scene the component belongs to.
  64294. */
  64295. scene: Scene;
  64296. /**
  64297. * Creates a new instance of the component for the given scene
  64298. * @param scene Defines the scene to register the component in
  64299. */
  64300. constructor(scene: Scene);
  64301. /**
  64302. * Registers the component in a given scene
  64303. */
  64304. register(): void;
  64305. /**
  64306. * Rebuilds the elements related to this component in case of
  64307. * context lost for instance.
  64308. */
  64309. rebuild(): void;
  64310. /**
  64311. * Disposes the component and the associated ressources
  64312. */
  64313. dispose(): void;
  64314. private _gatherRenderTargets;
  64315. }
  64316. }
  64317. declare module "babylonjs/Shaders/motionBlur.fragment" {
  64318. /** @hidden */
  64319. export var motionBlurPixelShader: {
  64320. name: string;
  64321. shader: string;
  64322. };
  64323. }
  64324. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  64325. import { Nullable } from "babylonjs/types";
  64326. import { Camera } from "babylonjs/Cameras/camera";
  64327. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64328. import { Scene } from "babylonjs/scene";
  64329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64330. import "babylonjs/Animations/animatable";
  64331. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64332. import "babylonjs/Shaders/motionBlur.fragment";
  64333. import { Engine } from "babylonjs/Engines/engine";
  64334. /**
  64335. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64336. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64337. * As an example, all you have to do is to create the post-process:
  64338. * var mb = new BABYLON.MotionBlurPostProcess(
  64339. * 'mb', // The name of the effect.
  64340. * scene, // The scene containing the objects to blur according to their velocity.
  64341. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64342. * camera // The camera to apply the render pass to.
  64343. * );
  64344. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64345. */
  64346. export class MotionBlurPostProcess extends PostProcess {
  64347. /**
  64348. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64349. */
  64350. motionStrength: number;
  64351. /**
  64352. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64353. */
  64354. /**
  64355. * Sets the number of iterations to be used for motion blur quality
  64356. */
  64357. motionBlurSamples: number;
  64358. private _motionBlurSamples;
  64359. private _geometryBufferRenderer;
  64360. /**
  64361. * Creates a new instance MotionBlurPostProcess
  64362. * @param name The name of the effect.
  64363. * @param scene The scene containing the objects to blur according to their velocity.
  64364. * @param options The required width/height ratio to downsize to before computing the render pass.
  64365. * @param camera The camera to apply the render pass to.
  64366. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64367. * @param engine The engine which the post process will be applied. (default: current engine)
  64368. * @param reusable If the post process can be reused on the same frame. (default: false)
  64369. * @param textureType Type of textures used when performing the post process. (default: 0)
  64370. * @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)
  64371. */
  64372. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64373. /**
  64374. * Excludes the given skinned mesh from computing bones velocities.
  64375. * 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.
  64376. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64377. */
  64378. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64379. /**
  64380. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64381. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64382. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64383. */
  64384. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64385. /**
  64386. * Disposes the post process.
  64387. * @param camera The camera to dispose the post process on.
  64388. */
  64389. dispose(camera?: Camera): void;
  64390. }
  64391. }
  64392. declare module "babylonjs/Shaders/refraction.fragment" {
  64393. /** @hidden */
  64394. export var refractionPixelShader: {
  64395. name: string;
  64396. shader: string;
  64397. };
  64398. }
  64399. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  64400. import { Color3 } from "babylonjs/Maths/math.color";
  64401. import { Camera } from "babylonjs/Cameras/camera";
  64402. import { Texture } from "babylonjs/Materials/Textures/texture";
  64403. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64404. import { Engine } from "babylonjs/Engines/engine";
  64405. import "babylonjs/Shaders/refraction.fragment";
  64406. /**
  64407. * Post process which applies a refractin texture
  64408. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64409. */
  64410. export class RefractionPostProcess extends PostProcess {
  64411. /** the base color of the refraction (used to taint the rendering) */
  64412. color: Color3;
  64413. /** simulated refraction depth */
  64414. depth: number;
  64415. /** the coefficient of the base color (0 to remove base color tainting) */
  64416. colorLevel: number;
  64417. private _refTexture;
  64418. private _ownRefractionTexture;
  64419. /**
  64420. * Gets or sets the refraction texture
  64421. * Please note that you are responsible for disposing the texture if you set it manually
  64422. */
  64423. refractionTexture: Texture;
  64424. /**
  64425. * Initializes the RefractionPostProcess
  64426. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64427. * @param name The name of the effect.
  64428. * @param refractionTextureUrl Url of the refraction texture to use
  64429. * @param color the base color of the refraction (used to taint the rendering)
  64430. * @param depth simulated refraction depth
  64431. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64432. * @param camera The camera to apply the render pass to.
  64433. * @param options The required width/height ratio to downsize to before computing the render pass.
  64434. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64435. * @param engine The engine which the post process will be applied. (default: current engine)
  64436. * @param reusable If the post process can be reused on the same frame. (default: false)
  64437. */
  64438. constructor(name: string, refractionTextureUrl: string,
  64439. /** the base color of the refraction (used to taint the rendering) */
  64440. color: Color3,
  64441. /** simulated refraction depth */
  64442. depth: number,
  64443. /** the coefficient of the base color (0 to remove base color tainting) */
  64444. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64445. /**
  64446. * Disposes of the post process
  64447. * @param camera Camera to dispose post process on
  64448. */
  64449. dispose(camera: Camera): void;
  64450. }
  64451. }
  64452. declare module "babylonjs/Shaders/sharpen.fragment" {
  64453. /** @hidden */
  64454. export var sharpenPixelShader: {
  64455. name: string;
  64456. shader: string;
  64457. };
  64458. }
  64459. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  64460. import { Nullable } from "babylonjs/types";
  64461. import { Camera } from "babylonjs/Cameras/camera";
  64462. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64463. import "babylonjs/Shaders/sharpen.fragment";
  64464. import { Engine } from "babylonjs/Engines/engine";
  64465. /**
  64466. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64467. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64468. */
  64469. export class SharpenPostProcess extends PostProcess {
  64470. /**
  64471. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64472. */
  64473. colorAmount: number;
  64474. /**
  64475. * How much sharpness should be applied (default: 0.3)
  64476. */
  64477. edgeAmount: number;
  64478. /**
  64479. * Creates a new instance ConvolutionPostProcess
  64480. * @param name The name of the effect.
  64481. * @param options The required width/height ratio to downsize to before computing the render pass.
  64482. * @param camera The camera to apply the render pass to.
  64483. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64484. * @param engine The engine which the post process will be applied. (default: current engine)
  64485. * @param reusable If the post process can be reused on the same frame. (default: false)
  64486. * @param textureType Type of textures used when performing the post process. (default: 0)
  64487. * @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)
  64488. */
  64489. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64490. }
  64491. }
  64492. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  64493. import { Nullable } from "babylonjs/types";
  64494. import { Camera } from "babylonjs/Cameras/camera";
  64495. import { Engine } from "babylonjs/Engines/engine";
  64496. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64497. import { IInspectable } from "babylonjs/Misc/iInspectable";
  64498. /**
  64499. * PostProcessRenderPipeline
  64500. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64501. */
  64502. export class PostProcessRenderPipeline {
  64503. private engine;
  64504. private _renderEffects;
  64505. private _renderEffectsForIsolatedPass;
  64506. /**
  64507. * List of inspectable custom properties (used by the Inspector)
  64508. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64509. */
  64510. inspectableCustomProperties: IInspectable[];
  64511. /**
  64512. * @hidden
  64513. */
  64514. protected _cameras: Camera[];
  64515. /** @hidden */
  64516. _name: string;
  64517. /**
  64518. * Gets pipeline name
  64519. */
  64520. readonly name: string;
  64521. /** Gets the list of attached cameras */
  64522. readonly cameras: Camera[];
  64523. /**
  64524. * Initializes a PostProcessRenderPipeline
  64525. * @param engine engine to add the pipeline to
  64526. * @param name name of the pipeline
  64527. */
  64528. constructor(engine: Engine, name: string);
  64529. /**
  64530. * Gets the class name
  64531. * @returns "PostProcessRenderPipeline"
  64532. */
  64533. getClassName(): string;
  64534. /**
  64535. * If all the render effects in the pipeline are supported
  64536. */
  64537. readonly isSupported: boolean;
  64538. /**
  64539. * Adds an effect to the pipeline
  64540. * @param renderEffect the effect to add
  64541. */
  64542. addEffect(renderEffect: PostProcessRenderEffect): void;
  64543. /** @hidden */
  64544. _rebuild(): void;
  64545. /** @hidden */
  64546. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64547. /** @hidden */
  64548. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64549. /** @hidden */
  64550. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64551. /** @hidden */
  64552. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64553. /** @hidden */
  64554. _attachCameras(cameras: Camera, unique: boolean): void;
  64555. /** @hidden */
  64556. _attachCameras(cameras: Camera[], unique: boolean): void;
  64557. /** @hidden */
  64558. _detachCameras(cameras: Camera): void;
  64559. /** @hidden */
  64560. _detachCameras(cameras: Nullable<Camera[]>): void;
  64561. /** @hidden */
  64562. _update(): void;
  64563. /** @hidden */
  64564. _reset(): void;
  64565. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  64566. /**
  64567. * Disposes of the pipeline
  64568. */
  64569. dispose(): void;
  64570. }
  64571. }
  64572. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  64573. import { Camera } from "babylonjs/Cameras/camera";
  64574. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64575. /**
  64576. * PostProcessRenderPipelineManager class
  64577. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64578. */
  64579. export class PostProcessRenderPipelineManager {
  64580. private _renderPipelines;
  64581. /**
  64582. * Initializes a PostProcessRenderPipelineManager
  64583. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64584. */
  64585. constructor();
  64586. /**
  64587. * Gets the list of supported render pipelines
  64588. */
  64589. readonly supportedPipelines: PostProcessRenderPipeline[];
  64590. /**
  64591. * Adds a pipeline to the manager
  64592. * @param renderPipeline The pipeline to add
  64593. */
  64594. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  64595. /**
  64596. * Attaches a camera to the pipeline
  64597. * @param renderPipelineName The name of the pipeline to attach to
  64598. * @param cameras the camera to attach
  64599. * @param unique if the camera can be attached multiple times to the pipeline
  64600. */
  64601. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  64602. /**
  64603. * Detaches a camera from the pipeline
  64604. * @param renderPipelineName The name of the pipeline to detach from
  64605. * @param cameras the camera to detach
  64606. */
  64607. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  64608. /**
  64609. * Enables an effect by name on a pipeline
  64610. * @param renderPipelineName the name of the pipeline to enable the effect in
  64611. * @param renderEffectName the name of the effect to enable
  64612. * @param cameras the cameras that the effect should be enabled on
  64613. */
  64614. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64615. /**
  64616. * Disables an effect by name on a pipeline
  64617. * @param renderPipelineName the name of the pipeline to disable the effect in
  64618. * @param renderEffectName the name of the effect to disable
  64619. * @param cameras the cameras that the effect should be disabled on
  64620. */
  64621. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64622. /**
  64623. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  64624. */
  64625. update(): void;
  64626. /** @hidden */
  64627. _rebuild(): void;
  64628. /**
  64629. * Disposes of the manager and pipelines
  64630. */
  64631. dispose(): void;
  64632. }
  64633. }
  64634. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  64635. import { ISceneComponent } from "babylonjs/sceneComponent";
  64636. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64637. import { Scene } from "babylonjs/scene";
  64638. module "babylonjs/scene" {
  64639. interface Scene {
  64640. /** @hidden (Backing field) */
  64641. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64642. /**
  64643. * Gets the postprocess render pipeline manager
  64644. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64645. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64646. */
  64647. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64648. }
  64649. }
  64650. /**
  64651. * Defines the Render Pipeline scene component responsible to rendering pipelines
  64652. */
  64653. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  64654. /**
  64655. * The component name helpfull to identify the component in the list of scene components.
  64656. */
  64657. readonly name: string;
  64658. /**
  64659. * The scene the component belongs to.
  64660. */
  64661. scene: Scene;
  64662. /**
  64663. * Creates a new instance of the component for the given scene
  64664. * @param scene Defines the scene to register the component in
  64665. */
  64666. constructor(scene: Scene);
  64667. /**
  64668. * Registers the component in a given scene
  64669. */
  64670. register(): void;
  64671. /**
  64672. * Rebuilds the elements related to this component in case of
  64673. * context lost for instance.
  64674. */
  64675. rebuild(): void;
  64676. /**
  64677. * Disposes the component and the associated ressources
  64678. */
  64679. dispose(): void;
  64680. private _gatherRenderTargets;
  64681. }
  64682. }
  64683. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  64684. import { Nullable } from "babylonjs/types";
  64685. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64686. import { Camera } from "babylonjs/Cameras/camera";
  64687. import { IDisposable } from "babylonjs/scene";
  64688. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  64689. import { Scene } from "babylonjs/scene";
  64690. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  64691. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64692. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64693. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  64694. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64695. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64696. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  64697. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64698. import { Animation } from "babylonjs/Animations/animation";
  64699. /**
  64700. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  64701. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64702. */
  64703. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64704. private _scene;
  64705. private _camerasToBeAttached;
  64706. /**
  64707. * ID of the sharpen post process,
  64708. */
  64709. private readonly SharpenPostProcessId;
  64710. /**
  64711. * @ignore
  64712. * ID of the image processing post process;
  64713. */
  64714. readonly ImageProcessingPostProcessId: string;
  64715. /**
  64716. * @ignore
  64717. * ID of the Fast Approximate Anti-Aliasing post process;
  64718. */
  64719. readonly FxaaPostProcessId: string;
  64720. /**
  64721. * ID of the chromatic aberration post process,
  64722. */
  64723. private readonly ChromaticAberrationPostProcessId;
  64724. /**
  64725. * ID of the grain post process
  64726. */
  64727. private readonly GrainPostProcessId;
  64728. /**
  64729. * Sharpen post process which will apply a sharpen convolution to enhance edges
  64730. */
  64731. sharpen: SharpenPostProcess;
  64732. private _sharpenEffect;
  64733. private bloom;
  64734. /**
  64735. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  64736. */
  64737. depthOfField: DepthOfFieldEffect;
  64738. /**
  64739. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64740. */
  64741. fxaa: FxaaPostProcess;
  64742. /**
  64743. * Image post processing pass used to perform operations such as tone mapping or color grading.
  64744. */
  64745. imageProcessing: ImageProcessingPostProcess;
  64746. /**
  64747. * Chromatic aberration post process which will shift rgb colors in the image
  64748. */
  64749. chromaticAberration: ChromaticAberrationPostProcess;
  64750. private _chromaticAberrationEffect;
  64751. /**
  64752. * Grain post process which add noise to the image
  64753. */
  64754. grain: GrainPostProcess;
  64755. private _grainEffect;
  64756. /**
  64757. * Glow post process which adds a glow to emissive areas of the image
  64758. */
  64759. private _glowLayer;
  64760. /**
  64761. * Animations which can be used to tweak settings over a period of time
  64762. */
  64763. animations: Animation[];
  64764. private _imageProcessingConfigurationObserver;
  64765. private _sharpenEnabled;
  64766. private _bloomEnabled;
  64767. private _depthOfFieldEnabled;
  64768. private _depthOfFieldBlurLevel;
  64769. private _fxaaEnabled;
  64770. private _imageProcessingEnabled;
  64771. private _defaultPipelineTextureType;
  64772. private _bloomScale;
  64773. private _chromaticAberrationEnabled;
  64774. private _grainEnabled;
  64775. private _buildAllowed;
  64776. /**
  64777. * Gets active scene
  64778. */
  64779. readonly scene: Scene;
  64780. /**
  64781. * Enable or disable the sharpen process from the pipeline
  64782. */
  64783. sharpenEnabled: boolean;
  64784. private _resizeObserver;
  64785. private _hardwareScaleLevel;
  64786. private _bloomKernel;
  64787. /**
  64788. * Specifies the size of the bloom blur kernel, relative to the final output size
  64789. */
  64790. bloomKernel: number;
  64791. /**
  64792. * Specifies the weight of the bloom in the final rendering
  64793. */
  64794. private _bloomWeight;
  64795. /**
  64796. * Specifies the luma threshold for the area that will be blurred by the bloom
  64797. */
  64798. private _bloomThreshold;
  64799. private _hdr;
  64800. /**
  64801. * The strength of the bloom.
  64802. */
  64803. bloomWeight: number;
  64804. /**
  64805. * The strength of the bloom.
  64806. */
  64807. bloomThreshold: number;
  64808. /**
  64809. * The scale of the bloom, lower value will provide better performance.
  64810. */
  64811. bloomScale: number;
  64812. /**
  64813. * Enable or disable the bloom from the pipeline
  64814. */
  64815. bloomEnabled: boolean;
  64816. private _rebuildBloom;
  64817. /**
  64818. * If the depth of field is enabled.
  64819. */
  64820. depthOfFieldEnabled: boolean;
  64821. /**
  64822. * Blur level of the depth of field effect. (Higher blur will effect performance)
  64823. */
  64824. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  64825. /**
  64826. * If the anti aliasing is enabled.
  64827. */
  64828. fxaaEnabled: boolean;
  64829. private _samples;
  64830. /**
  64831. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64832. */
  64833. samples: number;
  64834. /**
  64835. * If image processing is enabled.
  64836. */
  64837. imageProcessingEnabled: boolean;
  64838. /**
  64839. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  64840. */
  64841. glowLayerEnabled: boolean;
  64842. /**
  64843. * Gets the glow layer (or null if not defined)
  64844. */
  64845. readonly glowLayer: Nullable<GlowLayer>;
  64846. /**
  64847. * Enable or disable the chromaticAberration process from the pipeline
  64848. */
  64849. chromaticAberrationEnabled: boolean;
  64850. /**
  64851. * Enable or disable the grain process from the pipeline
  64852. */
  64853. grainEnabled: boolean;
  64854. /**
  64855. * @constructor
  64856. * @param name - The rendering pipeline name (default: "")
  64857. * @param hdr - If high dynamic range textures should be used (default: true)
  64858. * @param scene - The scene linked to this pipeline (default: the last created scene)
  64859. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  64860. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  64861. */
  64862. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  64863. /**
  64864. * Get the class name
  64865. * @returns "DefaultRenderingPipeline"
  64866. */
  64867. getClassName(): string;
  64868. /**
  64869. * Force the compilation of the entire pipeline.
  64870. */
  64871. prepare(): void;
  64872. private _hasCleared;
  64873. private _prevPostProcess;
  64874. private _prevPrevPostProcess;
  64875. private _setAutoClearAndTextureSharing;
  64876. private _depthOfFieldSceneObserver;
  64877. private _buildPipeline;
  64878. private _disposePostProcesses;
  64879. /**
  64880. * Adds a camera to the pipeline
  64881. * @param camera the camera to be added
  64882. */
  64883. addCamera(camera: Camera): void;
  64884. /**
  64885. * Removes a camera from the pipeline
  64886. * @param camera the camera to remove
  64887. */
  64888. removeCamera(camera: Camera): void;
  64889. /**
  64890. * Dispose of the pipeline and stop all post processes
  64891. */
  64892. dispose(): void;
  64893. /**
  64894. * Serialize the rendering pipeline (Used when exporting)
  64895. * @returns the serialized object
  64896. */
  64897. serialize(): any;
  64898. /**
  64899. * Parse the serialized pipeline
  64900. * @param source Source pipeline.
  64901. * @param scene The scene to load the pipeline to.
  64902. * @param rootUrl The URL of the serialized pipeline.
  64903. * @returns An instantiated pipeline from the serialized object.
  64904. */
  64905. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  64906. }
  64907. }
  64908. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  64909. /** @hidden */
  64910. export var lensHighlightsPixelShader: {
  64911. name: string;
  64912. shader: string;
  64913. };
  64914. }
  64915. declare module "babylonjs/Shaders/depthOfField.fragment" {
  64916. /** @hidden */
  64917. export var depthOfFieldPixelShader: {
  64918. name: string;
  64919. shader: string;
  64920. };
  64921. }
  64922. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  64923. import { Camera } from "babylonjs/Cameras/camera";
  64924. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64925. import { Scene } from "babylonjs/scene";
  64926. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64927. import "babylonjs/Shaders/chromaticAberration.fragment";
  64928. import "babylonjs/Shaders/lensHighlights.fragment";
  64929. import "babylonjs/Shaders/depthOfField.fragment";
  64930. /**
  64931. * BABYLON.JS Chromatic Aberration GLSL Shader
  64932. * Author: Olivier Guyot
  64933. * Separates very slightly R, G and B colors on the edges of the screen
  64934. * Inspired by Francois Tarlier & Martins Upitis
  64935. */
  64936. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  64937. /**
  64938. * @ignore
  64939. * The chromatic aberration PostProcess id in the pipeline
  64940. */
  64941. LensChromaticAberrationEffect: string;
  64942. /**
  64943. * @ignore
  64944. * The highlights enhancing PostProcess id in the pipeline
  64945. */
  64946. HighlightsEnhancingEffect: string;
  64947. /**
  64948. * @ignore
  64949. * The depth-of-field PostProcess id in the pipeline
  64950. */
  64951. LensDepthOfFieldEffect: string;
  64952. private _scene;
  64953. private _depthTexture;
  64954. private _grainTexture;
  64955. private _chromaticAberrationPostProcess;
  64956. private _highlightsPostProcess;
  64957. private _depthOfFieldPostProcess;
  64958. private _edgeBlur;
  64959. private _grainAmount;
  64960. private _chromaticAberration;
  64961. private _distortion;
  64962. private _highlightsGain;
  64963. private _highlightsThreshold;
  64964. private _dofDistance;
  64965. private _dofAperture;
  64966. private _dofDarken;
  64967. private _dofPentagon;
  64968. private _blurNoise;
  64969. /**
  64970. * @constructor
  64971. *
  64972. * Effect parameters are as follow:
  64973. * {
  64974. * chromatic_aberration: number; // from 0 to x (1 for realism)
  64975. * edge_blur: number; // from 0 to x (1 for realism)
  64976. * distortion: number; // from 0 to x (1 for realism)
  64977. * grain_amount: number; // from 0 to 1
  64978. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  64979. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  64980. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  64981. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  64982. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  64983. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  64984. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  64985. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  64986. * }
  64987. * Note: if an effect parameter is unset, effect is disabled
  64988. *
  64989. * @param name The rendering pipeline name
  64990. * @param parameters - An object containing all parameters (see above)
  64991. * @param scene The scene linked to this pipeline
  64992. * @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)
  64993. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64994. */
  64995. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  64996. /**
  64997. * Get the class name
  64998. * @returns "LensRenderingPipeline"
  64999. */
  65000. getClassName(): string;
  65001. /**
  65002. * Gets associated scene
  65003. */
  65004. readonly scene: Scene;
  65005. /**
  65006. * Gets or sets the edge blur
  65007. */
  65008. edgeBlur: number;
  65009. /**
  65010. * Gets or sets the grain amount
  65011. */
  65012. grainAmount: number;
  65013. /**
  65014. * Gets or sets the chromatic aberration amount
  65015. */
  65016. chromaticAberration: number;
  65017. /**
  65018. * Gets or sets the depth of field aperture
  65019. */
  65020. dofAperture: number;
  65021. /**
  65022. * Gets or sets the edge distortion
  65023. */
  65024. edgeDistortion: number;
  65025. /**
  65026. * Gets or sets the depth of field distortion
  65027. */
  65028. dofDistortion: number;
  65029. /**
  65030. * Gets or sets the darken out of focus amount
  65031. */
  65032. darkenOutOfFocus: number;
  65033. /**
  65034. * Gets or sets a boolean indicating if blur noise is enabled
  65035. */
  65036. blurNoise: boolean;
  65037. /**
  65038. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65039. */
  65040. pentagonBokeh: boolean;
  65041. /**
  65042. * Gets or sets the highlight grain amount
  65043. */
  65044. highlightsGain: number;
  65045. /**
  65046. * Gets or sets the highlight threshold
  65047. */
  65048. highlightsThreshold: number;
  65049. /**
  65050. * Sets the amount of blur at the edges
  65051. * @param amount blur amount
  65052. */
  65053. setEdgeBlur(amount: number): void;
  65054. /**
  65055. * Sets edge blur to 0
  65056. */
  65057. disableEdgeBlur(): void;
  65058. /**
  65059. * Sets the amout of grain
  65060. * @param amount Amount of grain
  65061. */
  65062. setGrainAmount(amount: number): void;
  65063. /**
  65064. * Set grain amount to 0
  65065. */
  65066. disableGrain(): void;
  65067. /**
  65068. * Sets the chromatic aberration amount
  65069. * @param amount amount of chromatic aberration
  65070. */
  65071. setChromaticAberration(amount: number): void;
  65072. /**
  65073. * Sets chromatic aberration amount to 0
  65074. */
  65075. disableChromaticAberration(): void;
  65076. /**
  65077. * Sets the EdgeDistortion amount
  65078. * @param amount amount of EdgeDistortion
  65079. */
  65080. setEdgeDistortion(amount: number): void;
  65081. /**
  65082. * Sets edge distortion to 0
  65083. */
  65084. disableEdgeDistortion(): void;
  65085. /**
  65086. * Sets the FocusDistance amount
  65087. * @param amount amount of FocusDistance
  65088. */
  65089. setFocusDistance(amount: number): void;
  65090. /**
  65091. * Disables depth of field
  65092. */
  65093. disableDepthOfField(): void;
  65094. /**
  65095. * Sets the Aperture amount
  65096. * @param amount amount of Aperture
  65097. */
  65098. setAperture(amount: number): void;
  65099. /**
  65100. * Sets the DarkenOutOfFocus amount
  65101. * @param amount amount of DarkenOutOfFocus
  65102. */
  65103. setDarkenOutOfFocus(amount: number): void;
  65104. private _pentagonBokehIsEnabled;
  65105. /**
  65106. * Creates a pentagon bokeh effect
  65107. */
  65108. enablePentagonBokeh(): void;
  65109. /**
  65110. * Disables the pentagon bokeh effect
  65111. */
  65112. disablePentagonBokeh(): void;
  65113. /**
  65114. * Enables noise blur
  65115. */
  65116. enableNoiseBlur(): void;
  65117. /**
  65118. * Disables noise blur
  65119. */
  65120. disableNoiseBlur(): void;
  65121. /**
  65122. * Sets the HighlightsGain amount
  65123. * @param amount amount of HighlightsGain
  65124. */
  65125. setHighlightsGain(amount: number): void;
  65126. /**
  65127. * Sets the HighlightsThreshold amount
  65128. * @param amount amount of HighlightsThreshold
  65129. */
  65130. setHighlightsThreshold(amount: number): void;
  65131. /**
  65132. * Disables highlights
  65133. */
  65134. disableHighlights(): void;
  65135. /**
  65136. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65137. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65138. */
  65139. dispose(disableDepthRender?: boolean): void;
  65140. private _createChromaticAberrationPostProcess;
  65141. private _createHighlightsPostProcess;
  65142. private _createDepthOfFieldPostProcess;
  65143. private _createGrainTexture;
  65144. }
  65145. }
  65146. declare module "babylonjs/Shaders/ssao2.fragment" {
  65147. /** @hidden */
  65148. export var ssao2PixelShader: {
  65149. name: string;
  65150. shader: string;
  65151. };
  65152. }
  65153. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  65154. /** @hidden */
  65155. export var ssaoCombinePixelShader: {
  65156. name: string;
  65157. shader: string;
  65158. };
  65159. }
  65160. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  65161. import { Camera } from "babylonjs/Cameras/camera";
  65162. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65163. import { Scene } from "babylonjs/scene";
  65164. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65165. import "babylonjs/Shaders/ssao2.fragment";
  65166. import "babylonjs/Shaders/ssaoCombine.fragment";
  65167. /**
  65168. * Render pipeline to produce ssao effect
  65169. */
  65170. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65171. /**
  65172. * @ignore
  65173. * The PassPostProcess id in the pipeline that contains the original scene color
  65174. */
  65175. SSAOOriginalSceneColorEffect: string;
  65176. /**
  65177. * @ignore
  65178. * The SSAO PostProcess id in the pipeline
  65179. */
  65180. SSAORenderEffect: string;
  65181. /**
  65182. * @ignore
  65183. * The horizontal blur PostProcess id in the pipeline
  65184. */
  65185. SSAOBlurHRenderEffect: string;
  65186. /**
  65187. * @ignore
  65188. * The vertical blur PostProcess id in the pipeline
  65189. */
  65190. SSAOBlurVRenderEffect: string;
  65191. /**
  65192. * @ignore
  65193. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65194. */
  65195. SSAOCombineRenderEffect: string;
  65196. /**
  65197. * The output strength of the SSAO post-process. Default value is 1.0.
  65198. */
  65199. totalStrength: number;
  65200. /**
  65201. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65202. */
  65203. maxZ: number;
  65204. /**
  65205. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65206. */
  65207. minZAspect: number;
  65208. private _samples;
  65209. /**
  65210. * Number of samples used for the SSAO calculations. Default value is 8
  65211. */
  65212. samples: number;
  65213. private _textureSamples;
  65214. /**
  65215. * Number of samples to use for antialiasing
  65216. */
  65217. textureSamples: number;
  65218. /**
  65219. * Ratio object used for SSAO ratio and blur ratio
  65220. */
  65221. private _ratio;
  65222. /**
  65223. * Dynamically generated sphere sampler.
  65224. */
  65225. private _sampleSphere;
  65226. /**
  65227. * Blur filter offsets
  65228. */
  65229. private _samplerOffsets;
  65230. private _expensiveBlur;
  65231. /**
  65232. * If bilateral blur should be used
  65233. */
  65234. expensiveBlur: boolean;
  65235. /**
  65236. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65237. */
  65238. radius: number;
  65239. /**
  65240. * The base color of the SSAO post-process
  65241. * The final result is "base + ssao" between [0, 1]
  65242. */
  65243. base: number;
  65244. /**
  65245. * Support test.
  65246. */
  65247. static readonly IsSupported: boolean;
  65248. private _scene;
  65249. private _depthTexture;
  65250. private _normalTexture;
  65251. private _randomTexture;
  65252. private _originalColorPostProcess;
  65253. private _ssaoPostProcess;
  65254. private _blurHPostProcess;
  65255. private _blurVPostProcess;
  65256. private _ssaoCombinePostProcess;
  65257. /**
  65258. * Gets active scene
  65259. */
  65260. readonly scene: Scene;
  65261. /**
  65262. * @constructor
  65263. * @param name The rendering pipeline name
  65264. * @param scene The scene linked to this pipeline
  65265. * @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 }
  65266. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65267. */
  65268. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65269. /**
  65270. * Get the class name
  65271. * @returns "SSAO2RenderingPipeline"
  65272. */
  65273. getClassName(): string;
  65274. /**
  65275. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65276. */
  65277. dispose(disableGeometryBufferRenderer?: boolean): void;
  65278. private _createBlurPostProcess;
  65279. /** @hidden */
  65280. _rebuild(): void;
  65281. private _bits;
  65282. private _radicalInverse_VdC;
  65283. private _hammersley;
  65284. private _hemisphereSample_uniform;
  65285. private _generateHemisphere;
  65286. private _createSSAOPostProcess;
  65287. private _createSSAOCombinePostProcess;
  65288. private _createRandomTexture;
  65289. /**
  65290. * Serialize the rendering pipeline (Used when exporting)
  65291. * @returns the serialized object
  65292. */
  65293. serialize(): any;
  65294. /**
  65295. * Parse the serialized pipeline
  65296. * @param source Source pipeline.
  65297. * @param scene The scene to load the pipeline to.
  65298. * @param rootUrl The URL of the serialized pipeline.
  65299. * @returns An instantiated pipeline from the serialized object.
  65300. */
  65301. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65302. }
  65303. }
  65304. declare module "babylonjs/Shaders/ssao.fragment" {
  65305. /** @hidden */
  65306. export var ssaoPixelShader: {
  65307. name: string;
  65308. shader: string;
  65309. };
  65310. }
  65311. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  65312. import { Camera } from "babylonjs/Cameras/camera";
  65313. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65314. import { Scene } from "babylonjs/scene";
  65315. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65316. import "babylonjs/Shaders/ssao.fragment";
  65317. import "babylonjs/Shaders/ssaoCombine.fragment";
  65318. /**
  65319. * Render pipeline to produce ssao effect
  65320. */
  65321. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65322. /**
  65323. * @ignore
  65324. * The PassPostProcess id in the pipeline that contains the original scene color
  65325. */
  65326. SSAOOriginalSceneColorEffect: string;
  65327. /**
  65328. * @ignore
  65329. * The SSAO PostProcess id in the pipeline
  65330. */
  65331. SSAORenderEffect: string;
  65332. /**
  65333. * @ignore
  65334. * The horizontal blur PostProcess id in the pipeline
  65335. */
  65336. SSAOBlurHRenderEffect: string;
  65337. /**
  65338. * @ignore
  65339. * The vertical blur PostProcess id in the pipeline
  65340. */
  65341. SSAOBlurVRenderEffect: string;
  65342. /**
  65343. * @ignore
  65344. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65345. */
  65346. SSAOCombineRenderEffect: string;
  65347. /**
  65348. * The output strength of the SSAO post-process. Default value is 1.0.
  65349. */
  65350. totalStrength: number;
  65351. /**
  65352. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65353. */
  65354. radius: number;
  65355. /**
  65356. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65357. * Must not be equal to fallOff and superior to fallOff.
  65358. * Default value is 0.0075
  65359. */
  65360. area: number;
  65361. /**
  65362. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65363. * Must not be equal to area and inferior to area.
  65364. * Default value is 0.000001
  65365. */
  65366. fallOff: number;
  65367. /**
  65368. * The base color of the SSAO post-process
  65369. * The final result is "base + ssao" between [0, 1]
  65370. */
  65371. base: number;
  65372. private _scene;
  65373. private _depthTexture;
  65374. private _randomTexture;
  65375. private _originalColorPostProcess;
  65376. private _ssaoPostProcess;
  65377. private _blurHPostProcess;
  65378. private _blurVPostProcess;
  65379. private _ssaoCombinePostProcess;
  65380. private _firstUpdate;
  65381. /**
  65382. * Gets active scene
  65383. */
  65384. readonly scene: Scene;
  65385. /**
  65386. * @constructor
  65387. * @param name - The rendering pipeline name
  65388. * @param scene - The scene linked to this pipeline
  65389. * @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 }
  65390. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65391. */
  65392. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65393. /**
  65394. * Get the class name
  65395. * @returns "SSAORenderingPipeline"
  65396. */
  65397. getClassName(): string;
  65398. /**
  65399. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65400. */
  65401. dispose(disableDepthRender?: boolean): void;
  65402. private _createBlurPostProcess;
  65403. /** @hidden */
  65404. _rebuild(): void;
  65405. private _createSSAOPostProcess;
  65406. private _createSSAOCombinePostProcess;
  65407. private _createRandomTexture;
  65408. }
  65409. }
  65410. declare module "babylonjs/Shaders/standard.fragment" {
  65411. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65412. /** @hidden */
  65413. export var standardPixelShader: {
  65414. name: string;
  65415. shader: string;
  65416. };
  65417. }
  65418. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  65419. import { Nullable } from "babylonjs/types";
  65420. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65421. import { Camera } from "babylonjs/Cameras/camera";
  65422. import { Texture } from "babylonjs/Materials/Textures/texture";
  65423. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65424. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65425. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65426. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65427. import { IDisposable } from "babylonjs/scene";
  65428. import { SpotLight } from "babylonjs/Lights/spotLight";
  65429. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  65430. import { Scene } from "babylonjs/scene";
  65431. import { Animation } from "babylonjs/Animations/animation";
  65432. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65433. import "babylonjs/Shaders/standard.fragment";
  65434. /**
  65435. * Standard rendering pipeline
  65436. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65437. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65438. */
  65439. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65440. /**
  65441. * Public members
  65442. */
  65443. /**
  65444. * Post-process which contains the original scene color before the pipeline applies all the effects
  65445. */
  65446. originalPostProcess: Nullable<PostProcess>;
  65447. /**
  65448. * Post-process used to down scale an image x4
  65449. */
  65450. downSampleX4PostProcess: Nullable<PostProcess>;
  65451. /**
  65452. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65453. */
  65454. brightPassPostProcess: Nullable<PostProcess>;
  65455. /**
  65456. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65457. */
  65458. blurHPostProcesses: PostProcess[];
  65459. /**
  65460. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65461. */
  65462. blurVPostProcesses: PostProcess[];
  65463. /**
  65464. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65465. */
  65466. textureAdderPostProcess: Nullable<PostProcess>;
  65467. /**
  65468. * Post-process used to create volumetric lighting effect
  65469. */
  65470. volumetricLightPostProcess: Nullable<PostProcess>;
  65471. /**
  65472. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65473. */
  65474. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65475. /**
  65476. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65477. */
  65478. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65479. /**
  65480. * Post-process used to merge the volumetric light effect and the real scene color
  65481. */
  65482. volumetricLightMergePostProces: Nullable<PostProcess>;
  65483. /**
  65484. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65485. */
  65486. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65487. /**
  65488. * Base post-process used to calculate the average luminance of the final image for HDR
  65489. */
  65490. luminancePostProcess: Nullable<PostProcess>;
  65491. /**
  65492. * Post-processes used to create down sample post-processes in order to get
  65493. * the average luminance of the final image for HDR
  65494. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  65495. */
  65496. luminanceDownSamplePostProcesses: PostProcess[];
  65497. /**
  65498. * Post-process used to create a HDR effect (light adaptation)
  65499. */
  65500. hdrPostProcess: Nullable<PostProcess>;
  65501. /**
  65502. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  65503. */
  65504. textureAdderFinalPostProcess: Nullable<PostProcess>;
  65505. /**
  65506. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  65507. */
  65508. lensFlareFinalPostProcess: Nullable<PostProcess>;
  65509. /**
  65510. * Post-process used to merge the final HDR post-process and the real scene color
  65511. */
  65512. hdrFinalPostProcess: Nullable<PostProcess>;
  65513. /**
  65514. * Post-process used to create a lens flare effect
  65515. */
  65516. lensFlarePostProcess: Nullable<PostProcess>;
  65517. /**
  65518. * Post-process that merges the result of the lens flare post-process and the real scene color
  65519. */
  65520. lensFlareComposePostProcess: Nullable<PostProcess>;
  65521. /**
  65522. * Post-process used to create a motion blur effect
  65523. */
  65524. motionBlurPostProcess: Nullable<PostProcess>;
  65525. /**
  65526. * Post-process used to create a depth of field effect
  65527. */
  65528. depthOfFieldPostProcess: Nullable<PostProcess>;
  65529. /**
  65530. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65531. */
  65532. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65533. /**
  65534. * Represents the brightness threshold in order to configure the illuminated surfaces
  65535. */
  65536. brightThreshold: number;
  65537. /**
  65538. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  65539. */
  65540. blurWidth: number;
  65541. /**
  65542. * Sets if the blur for highlighted surfaces must be only horizontal
  65543. */
  65544. horizontalBlur: boolean;
  65545. /**
  65546. * Gets the overall exposure used by the pipeline
  65547. */
  65548. /**
  65549. * Sets the overall exposure used by the pipeline
  65550. */
  65551. exposure: number;
  65552. /**
  65553. * Texture used typically to simulate "dirty" on camera lens
  65554. */
  65555. lensTexture: Nullable<Texture>;
  65556. /**
  65557. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  65558. */
  65559. volumetricLightCoefficient: number;
  65560. /**
  65561. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  65562. */
  65563. volumetricLightPower: number;
  65564. /**
  65565. * Used the set the blur intensity to smooth the volumetric lights
  65566. */
  65567. volumetricLightBlurScale: number;
  65568. /**
  65569. * Light (spot or directional) used to generate the volumetric lights rays
  65570. * The source light must have a shadow generate so the pipeline can get its
  65571. * depth map
  65572. */
  65573. sourceLight: Nullable<SpotLight | DirectionalLight>;
  65574. /**
  65575. * For eye adaptation, represents the minimum luminance the eye can see
  65576. */
  65577. hdrMinimumLuminance: number;
  65578. /**
  65579. * For eye adaptation, represents the decrease luminance speed
  65580. */
  65581. hdrDecreaseRate: number;
  65582. /**
  65583. * For eye adaptation, represents the increase luminance speed
  65584. */
  65585. hdrIncreaseRate: number;
  65586. /**
  65587. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65588. */
  65589. /**
  65590. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65591. */
  65592. hdrAutoExposure: boolean;
  65593. /**
  65594. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  65595. */
  65596. lensColorTexture: Nullable<Texture>;
  65597. /**
  65598. * The overall strengh for the lens flare effect
  65599. */
  65600. lensFlareStrength: number;
  65601. /**
  65602. * Dispersion coefficient for lens flare ghosts
  65603. */
  65604. lensFlareGhostDispersal: number;
  65605. /**
  65606. * Main lens flare halo width
  65607. */
  65608. lensFlareHaloWidth: number;
  65609. /**
  65610. * Based on the lens distortion effect, defines how much the lens flare result
  65611. * is distorted
  65612. */
  65613. lensFlareDistortionStrength: number;
  65614. /**
  65615. * Configures the blur intensity used for for lens flare (halo)
  65616. */
  65617. lensFlareBlurWidth: number;
  65618. /**
  65619. * Lens star texture must be used to simulate rays on the flares and is available
  65620. * in the documentation
  65621. */
  65622. lensStarTexture: Nullable<Texture>;
  65623. /**
  65624. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  65625. * flare effect by taking account of the dirt texture
  65626. */
  65627. lensFlareDirtTexture: Nullable<Texture>;
  65628. /**
  65629. * Represents the focal length for the depth of field effect
  65630. */
  65631. depthOfFieldDistance: number;
  65632. /**
  65633. * Represents the blur intensity for the blurred part of the depth of field effect
  65634. */
  65635. depthOfFieldBlurWidth: number;
  65636. /**
  65637. * Gets how much the image is blurred by the movement while using the motion blur post-process
  65638. */
  65639. /**
  65640. * Sets how much the image is blurred by the movement while using the motion blur post-process
  65641. */
  65642. motionStrength: number;
  65643. /**
  65644. * Gets wether or not the motion blur post-process is object based or screen based.
  65645. */
  65646. /**
  65647. * Sets wether or not the motion blur post-process should be object based or screen based
  65648. */
  65649. objectBasedMotionBlur: boolean;
  65650. /**
  65651. * List of animations for the pipeline (IAnimatable implementation)
  65652. */
  65653. animations: Animation[];
  65654. /**
  65655. * Private members
  65656. */
  65657. private _scene;
  65658. private _currentDepthOfFieldSource;
  65659. private _basePostProcess;
  65660. private _fixedExposure;
  65661. private _currentExposure;
  65662. private _hdrAutoExposure;
  65663. private _hdrCurrentLuminance;
  65664. private _motionStrength;
  65665. private _isObjectBasedMotionBlur;
  65666. private _floatTextureType;
  65667. private _camerasToBeAttached;
  65668. private _ratio;
  65669. private _bloomEnabled;
  65670. private _depthOfFieldEnabled;
  65671. private _vlsEnabled;
  65672. private _lensFlareEnabled;
  65673. private _hdrEnabled;
  65674. private _motionBlurEnabled;
  65675. private _fxaaEnabled;
  65676. private _motionBlurSamples;
  65677. private _volumetricLightStepsCount;
  65678. private _samples;
  65679. /**
  65680. * @ignore
  65681. * Specifies if the bloom pipeline is enabled
  65682. */
  65683. BloomEnabled: boolean;
  65684. /**
  65685. * @ignore
  65686. * Specifies if the depth of field pipeline is enabed
  65687. */
  65688. DepthOfFieldEnabled: boolean;
  65689. /**
  65690. * @ignore
  65691. * Specifies if the lens flare pipeline is enabed
  65692. */
  65693. LensFlareEnabled: boolean;
  65694. /**
  65695. * @ignore
  65696. * Specifies if the HDR pipeline is enabled
  65697. */
  65698. HDREnabled: boolean;
  65699. /**
  65700. * @ignore
  65701. * Specifies if the volumetric lights scattering effect is enabled
  65702. */
  65703. VLSEnabled: boolean;
  65704. /**
  65705. * @ignore
  65706. * Specifies if the motion blur effect is enabled
  65707. */
  65708. MotionBlurEnabled: boolean;
  65709. /**
  65710. * Specifies if anti-aliasing is enabled
  65711. */
  65712. fxaaEnabled: boolean;
  65713. /**
  65714. * Specifies the number of steps used to calculate the volumetric lights
  65715. * Typically in interval [50, 200]
  65716. */
  65717. volumetricLightStepsCount: number;
  65718. /**
  65719. * Specifies the number of samples used for the motion blur effect
  65720. * Typically in interval [16, 64]
  65721. */
  65722. motionBlurSamples: number;
  65723. /**
  65724. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65725. */
  65726. samples: number;
  65727. /**
  65728. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65729. * @constructor
  65730. * @param name The rendering pipeline name
  65731. * @param scene The scene linked to this pipeline
  65732. * @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)
  65733. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  65734. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65735. */
  65736. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  65737. private _buildPipeline;
  65738. private _createDownSampleX4PostProcess;
  65739. private _createBrightPassPostProcess;
  65740. private _createBlurPostProcesses;
  65741. private _createTextureAdderPostProcess;
  65742. private _createVolumetricLightPostProcess;
  65743. private _createLuminancePostProcesses;
  65744. private _createHdrPostProcess;
  65745. private _createLensFlarePostProcess;
  65746. private _createDepthOfFieldPostProcess;
  65747. private _createMotionBlurPostProcess;
  65748. private _getDepthTexture;
  65749. private _disposePostProcesses;
  65750. /**
  65751. * Dispose of the pipeline and stop all post processes
  65752. */
  65753. dispose(): void;
  65754. /**
  65755. * Serialize the rendering pipeline (Used when exporting)
  65756. * @returns the serialized object
  65757. */
  65758. serialize(): any;
  65759. /**
  65760. * Parse the serialized pipeline
  65761. * @param source Source pipeline.
  65762. * @param scene The scene to load the pipeline to.
  65763. * @param rootUrl The URL of the serialized pipeline.
  65764. * @returns An instantiated pipeline from the serialized object.
  65765. */
  65766. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  65767. /**
  65768. * Luminance steps
  65769. */
  65770. static LuminanceSteps: number;
  65771. }
  65772. }
  65773. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  65774. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  65775. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  65776. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  65777. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  65778. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  65779. }
  65780. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  65781. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  65782. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65783. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65784. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65785. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65786. }
  65787. declare module "babylonjs/Shaders/tonemap.fragment" {
  65788. /** @hidden */
  65789. export var tonemapPixelShader: {
  65790. name: string;
  65791. shader: string;
  65792. };
  65793. }
  65794. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  65795. import { Camera } from "babylonjs/Cameras/camera";
  65796. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65797. import "babylonjs/Shaders/tonemap.fragment";
  65798. import { Engine } from "babylonjs/Engines/engine";
  65799. /** Defines operator used for tonemapping */
  65800. export enum TonemappingOperator {
  65801. /** Hable */
  65802. Hable = 0,
  65803. /** Reinhard */
  65804. Reinhard = 1,
  65805. /** HejiDawson */
  65806. HejiDawson = 2,
  65807. /** Photographic */
  65808. Photographic = 3
  65809. }
  65810. /**
  65811. * Defines a post process to apply tone mapping
  65812. */
  65813. export class TonemapPostProcess extends PostProcess {
  65814. private _operator;
  65815. /** Defines the required exposure adjustement */
  65816. exposureAdjustment: number;
  65817. /**
  65818. * Creates a new TonemapPostProcess
  65819. * @param name defines the name of the postprocess
  65820. * @param _operator defines the operator to use
  65821. * @param exposureAdjustment defines the required exposure adjustement
  65822. * @param camera defines the camera to use (can be null)
  65823. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  65824. * @param engine defines the hosting engine (can be ignore if camera is set)
  65825. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65826. */
  65827. constructor(name: string, _operator: TonemappingOperator,
  65828. /** Defines the required exposure adjustement */
  65829. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  65830. }
  65831. }
  65832. declare module "babylonjs/Shaders/depth.vertex" {
  65833. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65834. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65835. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65836. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65837. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65838. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65839. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65840. /** @hidden */
  65841. export var depthVertexShader: {
  65842. name: string;
  65843. shader: string;
  65844. };
  65845. }
  65846. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  65847. /** @hidden */
  65848. export var volumetricLightScatteringPixelShader: {
  65849. name: string;
  65850. shader: string;
  65851. };
  65852. }
  65853. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  65854. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65855. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65856. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65857. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65858. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65859. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65860. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65861. /** @hidden */
  65862. export var volumetricLightScatteringPassVertexShader: {
  65863. name: string;
  65864. shader: string;
  65865. };
  65866. }
  65867. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  65868. /** @hidden */
  65869. export var volumetricLightScatteringPassPixelShader: {
  65870. name: string;
  65871. shader: string;
  65872. };
  65873. }
  65874. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  65875. import { Vector3 } from "babylonjs/Maths/math.vector";
  65876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65877. import { Mesh } from "babylonjs/Meshes/mesh";
  65878. import { Camera } from "babylonjs/Cameras/camera";
  65879. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65880. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65881. import { Scene } from "babylonjs/scene";
  65882. import "babylonjs/Meshes/Builders/planeBuilder";
  65883. import "babylonjs/Shaders/depth.vertex";
  65884. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  65885. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  65886. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  65887. import { Engine } from "babylonjs/Engines/engine";
  65888. /**
  65889. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  65890. */
  65891. export class VolumetricLightScatteringPostProcess extends PostProcess {
  65892. private _volumetricLightScatteringPass;
  65893. private _volumetricLightScatteringRTT;
  65894. private _viewPort;
  65895. private _screenCoordinates;
  65896. private _cachedDefines;
  65897. /**
  65898. * If not undefined, the mesh position is computed from the attached node position
  65899. */
  65900. attachedNode: {
  65901. position: Vector3;
  65902. };
  65903. /**
  65904. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  65905. */
  65906. customMeshPosition: Vector3;
  65907. /**
  65908. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  65909. */
  65910. useCustomMeshPosition: boolean;
  65911. /**
  65912. * If the post-process should inverse the light scattering direction
  65913. */
  65914. invert: boolean;
  65915. /**
  65916. * The internal mesh used by the post-process
  65917. */
  65918. mesh: Mesh;
  65919. /**
  65920. * @hidden
  65921. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  65922. */
  65923. useDiffuseColor: boolean;
  65924. /**
  65925. * Array containing the excluded meshes not rendered in the internal pass
  65926. */
  65927. excludedMeshes: AbstractMesh[];
  65928. /**
  65929. * Controls the overall intensity of the post-process
  65930. */
  65931. exposure: number;
  65932. /**
  65933. * Dissipates each sample's contribution in range [0, 1]
  65934. */
  65935. decay: number;
  65936. /**
  65937. * Controls the overall intensity of each sample
  65938. */
  65939. weight: number;
  65940. /**
  65941. * Controls the density of each sample
  65942. */
  65943. density: number;
  65944. /**
  65945. * @constructor
  65946. * @param name The post-process name
  65947. * @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)
  65948. * @param camera The camera that the post-process will be attached to
  65949. * @param mesh The mesh used to create the light scattering
  65950. * @param samples The post-process quality, default 100
  65951. * @param samplingModeThe post-process filtering mode
  65952. * @param engine The babylon engine
  65953. * @param reusable If the post-process is reusable
  65954. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  65955. */
  65956. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  65957. /**
  65958. * Returns the string "VolumetricLightScatteringPostProcess"
  65959. * @returns "VolumetricLightScatteringPostProcess"
  65960. */
  65961. getClassName(): string;
  65962. private _isReady;
  65963. /**
  65964. * Sets the new light position for light scattering effect
  65965. * @param position The new custom light position
  65966. */
  65967. setCustomMeshPosition(position: Vector3): void;
  65968. /**
  65969. * Returns the light position for light scattering effect
  65970. * @return Vector3 The custom light position
  65971. */
  65972. getCustomMeshPosition(): Vector3;
  65973. /**
  65974. * Disposes the internal assets and detaches the post-process from the camera
  65975. */
  65976. dispose(camera: Camera): void;
  65977. /**
  65978. * Returns the render target texture used by the post-process
  65979. * @return the render target texture used by the post-process
  65980. */
  65981. getPass(): RenderTargetTexture;
  65982. private _meshExcluded;
  65983. private _createPass;
  65984. private _updateMeshScreenCoordinates;
  65985. /**
  65986. * Creates a default mesh for the Volumeric Light Scattering post-process
  65987. * @param name The mesh name
  65988. * @param scene The scene where to create the mesh
  65989. * @return the default mesh
  65990. */
  65991. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  65992. }
  65993. }
  65994. declare module "babylonjs/PostProcesses/index" {
  65995. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  65996. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  65997. export * from "babylonjs/PostProcesses/bloomEffect";
  65998. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  65999. export * from "babylonjs/PostProcesses/blurPostProcess";
  66000. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  66001. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  66002. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  66003. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  66004. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  66005. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  66006. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  66007. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  66008. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  66009. export * from "babylonjs/PostProcesses/filterPostProcess";
  66010. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  66011. export * from "babylonjs/PostProcesses/grainPostProcess";
  66012. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  66013. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  66014. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  66015. export * from "babylonjs/PostProcesses/passPostProcess";
  66016. export * from "babylonjs/PostProcesses/postProcess";
  66017. export * from "babylonjs/PostProcesses/postProcessManager";
  66018. export * from "babylonjs/PostProcesses/refractionPostProcess";
  66019. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  66020. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  66021. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  66022. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  66023. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  66024. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  66025. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  66026. }
  66027. declare module "babylonjs/Probes/index" {
  66028. export * from "babylonjs/Probes/reflectionProbe";
  66029. }
  66030. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  66031. import { Scene } from "babylonjs/scene";
  66032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66033. import { SmartArray } from "babylonjs/Misc/smartArray";
  66034. import { ISceneComponent } from "babylonjs/sceneComponent";
  66035. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  66036. import "babylonjs/Meshes/Builders/boxBuilder";
  66037. import "babylonjs/Shaders/color.fragment";
  66038. import "babylonjs/Shaders/color.vertex";
  66039. import { Color3 } from "babylonjs/Maths/math.color";
  66040. module "babylonjs/scene" {
  66041. interface Scene {
  66042. /** @hidden (Backing field) */
  66043. _boundingBoxRenderer: BoundingBoxRenderer;
  66044. /** @hidden (Backing field) */
  66045. _forceShowBoundingBoxes: boolean;
  66046. /**
  66047. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66048. */
  66049. forceShowBoundingBoxes: boolean;
  66050. /**
  66051. * Gets the bounding box renderer associated with the scene
  66052. * @returns a BoundingBoxRenderer
  66053. */
  66054. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66055. }
  66056. }
  66057. module "babylonjs/Meshes/abstractMesh" {
  66058. interface AbstractMesh {
  66059. /** @hidden (Backing field) */
  66060. _showBoundingBox: boolean;
  66061. /**
  66062. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66063. */
  66064. showBoundingBox: boolean;
  66065. }
  66066. }
  66067. /**
  66068. * Component responsible of rendering the bounding box of the meshes in a scene.
  66069. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66070. */
  66071. export class BoundingBoxRenderer implements ISceneComponent {
  66072. /**
  66073. * The component name helpfull to identify the component in the list of scene components.
  66074. */
  66075. readonly name: string;
  66076. /**
  66077. * The scene the component belongs to.
  66078. */
  66079. scene: Scene;
  66080. /**
  66081. * Color of the bounding box lines placed in front of an object
  66082. */
  66083. frontColor: Color3;
  66084. /**
  66085. * Color of the bounding box lines placed behind an object
  66086. */
  66087. backColor: Color3;
  66088. /**
  66089. * Defines if the renderer should show the back lines or not
  66090. */
  66091. showBackLines: boolean;
  66092. /**
  66093. * @hidden
  66094. */
  66095. renderList: SmartArray<BoundingBox>;
  66096. private _colorShader;
  66097. private _vertexBuffers;
  66098. private _indexBuffer;
  66099. private _fillIndexBuffer;
  66100. private _fillIndexData;
  66101. /**
  66102. * Instantiates a new bounding box renderer in a scene.
  66103. * @param scene the scene the renderer renders in
  66104. */
  66105. constructor(scene: Scene);
  66106. /**
  66107. * Registers the component in a given scene
  66108. */
  66109. register(): void;
  66110. private _evaluateSubMesh;
  66111. private _activeMesh;
  66112. private _prepareRessources;
  66113. private _createIndexBuffer;
  66114. /**
  66115. * Rebuilds the elements related to this component in case of
  66116. * context lost for instance.
  66117. */
  66118. rebuild(): void;
  66119. /**
  66120. * @hidden
  66121. */
  66122. reset(): void;
  66123. /**
  66124. * Render the bounding boxes of a specific rendering group
  66125. * @param renderingGroupId defines the rendering group to render
  66126. */
  66127. render(renderingGroupId: number): void;
  66128. /**
  66129. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66130. * @param mesh Define the mesh to render the occlusion bounding box for
  66131. */
  66132. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66133. /**
  66134. * Dispose and release the resources attached to this renderer.
  66135. */
  66136. dispose(): void;
  66137. }
  66138. }
  66139. declare module "babylonjs/Shaders/depth.fragment" {
  66140. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66141. /** @hidden */
  66142. export var depthPixelShader: {
  66143. name: string;
  66144. shader: string;
  66145. };
  66146. }
  66147. declare module "babylonjs/Rendering/depthRenderer" {
  66148. import { Nullable } from "babylonjs/types";
  66149. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66150. import { Scene } from "babylonjs/scene";
  66151. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66152. import { Camera } from "babylonjs/Cameras/camera";
  66153. import "babylonjs/Shaders/depth.fragment";
  66154. import "babylonjs/Shaders/depth.vertex";
  66155. /**
  66156. * This represents a depth renderer in Babylon.
  66157. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  66158. */
  66159. export class DepthRenderer {
  66160. private _scene;
  66161. private _depthMap;
  66162. private _effect;
  66163. private readonly _storeNonLinearDepth;
  66164. private readonly _clearColor;
  66165. /** Get if the depth renderer is using packed depth or not */
  66166. readonly isPacked: boolean;
  66167. private _cachedDefines;
  66168. private _camera;
  66169. /**
  66170. * Specifiess that the depth renderer will only be used within
  66171. * the camera it is created for.
  66172. * This can help forcing its rendering during the camera processing.
  66173. */
  66174. useOnlyInActiveCamera: boolean;
  66175. /** @hidden */
  66176. static _SceneComponentInitialization: (scene: Scene) => void;
  66177. /**
  66178. * Instantiates a depth renderer
  66179. * @param scene The scene the renderer belongs to
  66180. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  66181. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  66182. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66183. */
  66184. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  66185. /**
  66186. * Creates the depth rendering effect and checks if the effect is ready.
  66187. * @param subMesh The submesh to be used to render the depth map of
  66188. * @param useInstances If multiple world instances should be used
  66189. * @returns if the depth renderer is ready to render the depth map
  66190. */
  66191. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66192. /**
  66193. * Gets the texture which the depth map will be written to.
  66194. * @returns The depth map texture
  66195. */
  66196. getDepthMap(): RenderTargetTexture;
  66197. /**
  66198. * Disposes of the depth renderer.
  66199. */
  66200. dispose(): void;
  66201. }
  66202. }
  66203. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  66204. import { Nullable } from "babylonjs/types";
  66205. import { Scene } from "babylonjs/scene";
  66206. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  66207. import { Camera } from "babylonjs/Cameras/camera";
  66208. import { ISceneComponent } from "babylonjs/sceneComponent";
  66209. module "babylonjs/scene" {
  66210. interface Scene {
  66211. /** @hidden (Backing field) */
  66212. _depthRenderer: {
  66213. [id: string]: DepthRenderer;
  66214. };
  66215. /**
  66216. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66217. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66218. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66219. * @returns the created depth renderer
  66220. */
  66221. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66222. /**
  66223. * Disables a depth renderer for a given camera
  66224. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66225. */
  66226. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66227. }
  66228. }
  66229. /**
  66230. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66231. * in several rendering techniques.
  66232. */
  66233. export class DepthRendererSceneComponent implements ISceneComponent {
  66234. /**
  66235. * The component name helpfull to identify the component in the list of scene components.
  66236. */
  66237. readonly name: string;
  66238. /**
  66239. * The scene the component belongs to.
  66240. */
  66241. scene: Scene;
  66242. /**
  66243. * Creates a new instance of the component for the given scene
  66244. * @param scene Defines the scene to register the component in
  66245. */
  66246. constructor(scene: Scene);
  66247. /**
  66248. * Registers the component in a given scene
  66249. */
  66250. register(): void;
  66251. /**
  66252. * Rebuilds the elements related to this component in case of
  66253. * context lost for instance.
  66254. */
  66255. rebuild(): void;
  66256. /**
  66257. * Disposes the component and the associated ressources
  66258. */
  66259. dispose(): void;
  66260. private _gatherRenderTargets;
  66261. private _gatherActiveCameraRenderTargets;
  66262. }
  66263. }
  66264. declare module "babylonjs/Shaders/outline.fragment" {
  66265. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66266. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  66267. /** @hidden */
  66268. export var outlinePixelShader: {
  66269. name: string;
  66270. shader: string;
  66271. };
  66272. }
  66273. declare module "babylonjs/Shaders/outline.vertex" {
  66274. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66275. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66276. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66277. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66278. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66279. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66280. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66281. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66282. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  66283. /** @hidden */
  66284. export var outlineVertexShader: {
  66285. name: string;
  66286. shader: string;
  66287. };
  66288. }
  66289. declare module "babylonjs/Rendering/outlineRenderer" {
  66290. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66291. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  66292. import { Scene } from "babylonjs/scene";
  66293. import { ISceneComponent } from "babylonjs/sceneComponent";
  66294. import "babylonjs/Shaders/outline.fragment";
  66295. import "babylonjs/Shaders/outline.vertex";
  66296. module "babylonjs/scene" {
  66297. interface Scene {
  66298. /** @hidden */
  66299. _outlineRenderer: OutlineRenderer;
  66300. /**
  66301. * Gets the outline renderer associated with the scene
  66302. * @returns a OutlineRenderer
  66303. */
  66304. getOutlineRenderer(): OutlineRenderer;
  66305. }
  66306. }
  66307. module "babylonjs/Meshes/abstractMesh" {
  66308. interface AbstractMesh {
  66309. /** @hidden (Backing field) */
  66310. _renderOutline: boolean;
  66311. /**
  66312. * Gets or sets a boolean indicating if the outline must be rendered as well
  66313. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66314. */
  66315. renderOutline: boolean;
  66316. /** @hidden (Backing field) */
  66317. _renderOverlay: boolean;
  66318. /**
  66319. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66320. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66321. */
  66322. renderOverlay: boolean;
  66323. }
  66324. }
  66325. /**
  66326. * This class is responsible to draw bothe outline/overlay of meshes.
  66327. * It should not be used directly but through the available method on mesh.
  66328. */
  66329. export class OutlineRenderer implements ISceneComponent {
  66330. /**
  66331. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66332. */
  66333. private static _StencilReference;
  66334. /**
  66335. * The name of the component. Each component must have a unique name.
  66336. */
  66337. name: string;
  66338. /**
  66339. * The scene the component belongs to.
  66340. */
  66341. scene: Scene;
  66342. /**
  66343. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66344. */
  66345. zOffset: number;
  66346. private _engine;
  66347. private _effect;
  66348. private _cachedDefines;
  66349. private _savedDepthWrite;
  66350. /**
  66351. * Instantiates a new outline renderer. (There could be only one per scene).
  66352. * @param scene Defines the scene it belongs to
  66353. */
  66354. constructor(scene: Scene);
  66355. /**
  66356. * Register the component to one instance of a scene.
  66357. */
  66358. register(): void;
  66359. /**
  66360. * Rebuilds the elements related to this component in case of
  66361. * context lost for instance.
  66362. */
  66363. rebuild(): void;
  66364. /**
  66365. * Disposes the component and the associated ressources.
  66366. */
  66367. dispose(): void;
  66368. /**
  66369. * Renders the outline in the canvas.
  66370. * @param subMesh Defines the sumesh to render
  66371. * @param batch Defines the batch of meshes in case of instances
  66372. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66373. */
  66374. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66375. /**
  66376. * Returns whether or not the outline renderer is ready for a given submesh.
  66377. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66378. * @param subMesh Defines the submesh to check readyness for
  66379. * @param useInstances Defines wheter wee are trying to render instances or not
  66380. * @returns true if ready otherwise false
  66381. */
  66382. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66383. private _beforeRenderingMesh;
  66384. private _afterRenderingMesh;
  66385. }
  66386. }
  66387. declare module "babylonjs/Rendering/index" {
  66388. export * from "babylonjs/Rendering/boundingBoxRenderer";
  66389. export * from "babylonjs/Rendering/depthRenderer";
  66390. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  66391. export * from "babylonjs/Rendering/edgesRenderer";
  66392. export * from "babylonjs/Rendering/geometryBufferRenderer";
  66393. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  66394. export * from "babylonjs/Rendering/outlineRenderer";
  66395. export * from "babylonjs/Rendering/renderingGroup";
  66396. export * from "babylonjs/Rendering/renderingManager";
  66397. export * from "babylonjs/Rendering/utilityLayerRenderer";
  66398. }
  66399. declare module "babylonjs/Sprites/spritePackedManager" {
  66400. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  66401. import { Scene } from "babylonjs/scene";
  66402. /**
  66403. * Class used to manage multiple sprites of different sizes on the same spritesheet
  66404. * @see http://doc.babylonjs.com/babylon101/sprites
  66405. */
  66406. export class SpritePackedManager extends SpriteManager {
  66407. /** defines the packed manager's name */
  66408. name: string;
  66409. /**
  66410. * Creates a new sprite manager from a packed sprite sheet
  66411. * @param name defines the manager's name
  66412. * @param imgUrl defines the sprite sheet url
  66413. * @param capacity defines the maximum allowed number of sprites
  66414. * @param scene defines the hosting scene
  66415. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66416. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66417. * @param samplingMode defines the smapling mode to use with spritesheet
  66418. * @param fromPacked set to true; do not alter
  66419. */
  66420. constructor(
  66421. /** defines the packed manager's name */
  66422. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66423. }
  66424. }
  66425. declare module "babylonjs/Sprites/index" {
  66426. export * from "babylonjs/Sprites/sprite";
  66427. export * from "babylonjs/Sprites/spriteManager";
  66428. export * from "babylonjs/Sprites/spritePackedManager";
  66429. export * from "babylonjs/Sprites/spriteSceneComponent";
  66430. }
  66431. declare module "babylonjs/States/index" {
  66432. export * from "babylonjs/States/alphaCullingState";
  66433. export * from "babylonjs/States/depthCullingState";
  66434. export * from "babylonjs/States/stencilState";
  66435. }
  66436. declare module "babylonjs/Misc/assetsManager" {
  66437. import { Scene } from "babylonjs/scene";
  66438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66439. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66440. import { Skeleton } from "babylonjs/Bones/skeleton";
  66441. import { Observable } from "babylonjs/Misc/observable";
  66442. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66443. import { Texture } from "babylonjs/Materials/Textures/texture";
  66444. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66445. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  66446. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66447. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  66448. /**
  66449. * Defines the list of states available for a task inside a AssetsManager
  66450. */
  66451. export enum AssetTaskState {
  66452. /**
  66453. * Initialization
  66454. */
  66455. INIT = 0,
  66456. /**
  66457. * Running
  66458. */
  66459. RUNNING = 1,
  66460. /**
  66461. * Done
  66462. */
  66463. DONE = 2,
  66464. /**
  66465. * Error
  66466. */
  66467. ERROR = 3
  66468. }
  66469. /**
  66470. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  66471. */
  66472. export abstract class AbstractAssetTask {
  66473. /**
  66474. * Task name
  66475. */ name: string;
  66476. /**
  66477. * Callback called when the task is successful
  66478. */
  66479. onSuccess: (task: any) => void;
  66480. /**
  66481. * Callback called when the task is not successful
  66482. */
  66483. onError: (task: any, message?: string, exception?: any) => void;
  66484. /**
  66485. * Creates a new AssetsManager
  66486. * @param name defines the name of the task
  66487. */
  66488. constructor(
  66489. /**
  66490. * Task name
  66491. */ name: string);
  66492. private _isCompleted;
  66493. private _taskState;
  66494. private _errorObject;
  66495. /**
  66496. * Get if the task is completed
  66497. */
  66498. readonly isCompleted: boolean;
  66499. /**
  66500. * Gets the current state of the task
  66501. */
  66502. readonly taskState: AssetTaskState;
  66503. /**
  66504. * Gets the current error object (if task is in error)
  66505. */
  66506. readonly errorObject: {
  66507. message?: string;
  66508. exception?: any;
  66509. };
  66510. /**
  66511. * Internal only
  66512. * @hidden
  66513. */
  66514. _setErrorObject(message?: string, exception?: any): void;
  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. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66522. /**
  66523. * Execute the current task
  66524. * @param scene defines the scene where you want your assets to be loaded
  66525. * @param onSuccess is a callback called when the task is successfully executed
  66526. * @param onError is a callback called if an error occurs
  66527. */
  66528. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66529. /**
  66530. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  66531. * This can be used with failed tasks that have the reason for failure fixed.
  66532. */
  66533. reset(): void;
  66534. private onErrorCallback;
  66535. private onDoneCallback;
  66536. }
  66537. /**
  66538. * Define the interface used by progress events raised during assets loading
  66539. */
  66540. export interface IAssetsProgressEvent {
  66541. /**
  66542. * Defines the number of remaining tasks to process
  66543. */
  66544. remainingCount: number;
  66545. /**
  66546. * Defines the total number of tasks
  66547. */
  66548. totalCount: number;
  66549. /**
  66550. * Defines the task that was just processed
  66551. */
  66552. task: AbstractAssetTask;
  66553. }
  66554. /**
  66555. * Class used to share progress information about assets loading
  66556. */
  66557. export class AssetsProgressEvent implements IAssetsProgressEvent {
  66558. /**
  66559. * Defines the number of remaining tasks to process
  66560. */
  66561. remainingCount: number;
  66562. /**
  66563. * Defines the total number of tasks
  66564. */
  66565. totalCount: number;
  66566. /**
  66567. * Defines the task that was just processed
  66568. */
  66569. task: AbstractAssetTask;
  66570. /**
  66571. * Creates a AssetsProgressEvent
  66572. * @param remainingCount defines the number of remaining tasks to process
  66573. * @param totalCount defines the total number of tasks
  66574. * @param task defines the task that was just processed
  66575. */
  66576. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  66577. }
  66578. /**
  66579. * Define a task used by AssetsManager to load meshes
  66580. */
  66581. export class MeshAssetTask extends AbstractAssetTask {
  66582. /**
  66583. * Defines the name of the task
  66584. */
  66585. name: string;
  66586. /**
  66587. * Defines the list of mesh's names you want to load
  66588. */
  66589. meshesNames: any;
  66590. /**
  66591. * Defines the root url to use as a base to load your meshes and associated resources
  66592. */
  66593. rootUrl: string;
  66594. /**
  66595. * Defines the filename of the scene to load from
  66596. */
  66597. sceneFilename: string;
  66598. /**
  66599. * Gets the list of loaded meshes
  66600. */
  66601. loadedMeshes: Array<AbstractMesh>;
  66602. /**
  66603. * Gets the list of loaded particle systems
  66604. */
  66605. loadedParticleSystems: Array<IParticleSystem>;
  66606. /**
  66607. * Gets the list of loaded skeletons
  66608. */
  66609. loadedSkeletons: Array<Skeleton>;
  66610. /**
  66611. * Gets the list of loaded animation groups
  66612. */
  66613. loadedAnimationGroups: Array<AnimationGroup>;
  66614. /**
  66615. * Callback called when the task is successful
  66616. */
  66617. onSuccess: (task: MeshAssetTask) => void;
  66618. /**
  66619. * Callback called when the task is successful
  66620. */
  66621. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  66622. /**
  66623. * Creates a new MeshAssetTask
  66624. * @param name defines the name of the task
  66625. * @param meshesNames defines the list of mesh's names you want to load
  66626. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  66627. * @param sceneFilename defines the filename of the scene to load from
  66628. */
  66629. constructor(
  66630. /**
  66631. * Defines the name of the task
  66632. */
  66633. name: string,
  66634. /**
  66635. * Defines the list of mesh's names you want to load
  66636. */
  66637. meshesNames: any,
  66638. /**
  66639. * Defines the root url to use as a base to load your meshes and associated resources
  66640. */
  66641. rootUrl: string,
  66642. /**
  66643. * Defines the filename of the scene to load from
  66644. */
  66645. sceneFilename: string);
  66646. /**
  66647. * Execute the current task
  66648. * @param scene defines the scene where you want your assets to be loaded
  66649. * @param onSuccess is a callback called when the task is successfully executed
  66650. * @param onError is a callback called if an error occurs
  66651. */
  66652. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66653. }
  66654. /**
  66655. * Define a task used by AssetsManager to load text content
  66656. */
  66657. export class TextFileAssetTask extends AbstractAssetTask {
  66658. /**
  66659. * Defines the name of the task
  66660. */
  66661. name: string;
  66662. /**
  66663. * Defines the location of the file to load
  66664. */
  66665. url: string;
  66666. /**
  66667. * Gets the loaded text string
  66668. */
  66669. text: string;
  66670. /**
  66671. * Callback called when the task is successful
  66672. */
  66673. onSuccess: (task: TextFileAssetTask) => void;
  66674. /**
  66675. * Callback called when the task is successful
  66676. */
  66677. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  66678. /**
  66679. * Creates a new TextFileAssetTask object
  66680. * @param name defines the name of the task
  66681. * @param url defines the location of the file to load
  66682. */
  66683. constructor(
  66684. /**
  66685. * Defines the name of the task
  66686. */
  66687. name: string,
  66688. /**
  66689. * Defines the location of the file to load
  66690. */
  66691. url: string);
  66692. /**
  66693. * Execute the current task
  66694. * @param scene defines the scene where you want your assets to be loaded
  66695. * @param onSuccess is a callback called when the task is successfully executed
  66696. * @param onError is a callback called if an error occurs
  66697. */
  66698. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66699. }
  66700. /**
  66701. * Define a task used by AssetsManager to load binary data
  66702. */
  66703. export class BinaryFileAssetTask extends AbstractAssetTask {
  66704. /**
  66705. * Defines the name of the task
  66706. */
  66707. name: string;
  66708. /**
  66709. * Defines the location of the file to load
  66710. */
  66711. url: string;
  66712. /**
  66713. * Gets the lodaded data (as an array buffer)
  66714. */
  66715. data: ArrayBuffer;
  66716. /**
  66717. * Callback called when the task is successful
  66718. */
  66719. onSuccess: (task: BinaryFileAssetTask) => void;
  66720. /**
  66721. * Callback called when the task is successful
  66722. */
  66723. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  66724. /**
  66725. * Creates a new BinaryFileAssetTask object
  66726. * @param name defines the name of the new task
  66727. * @param url defines the location of the file to load
  66728. */
  66729. constructor(
  66730. /**
  66731. * Defines the name of the task
  66732. */
  66733. name: string,
  66734. /**
  66735. * Defines the location of the file to load
  66736. */
  66737. url: string);
  66738. /**
  66739. * Execute the current task
  66740. * @param scene defines the scene where you want your assets to be loaded
  66741. * @param onSuccess is a callback called when the task is successfully executed
  66742. * @param onError is a callback called if an error occurs
  66743. */
  66744. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66745. }
  66746. /**
  66747. * Define a task used by AssetsManager to load images
  66748. */
  66749. export class ImageAssetTask extends AbstractAssetTask {
  66750. /**
  66751. * Defines the name of the task
  66752. */
  66753. name: string;
  66754. /**
  66755. * Defines the location of the image to load
  66756. */
  66757. url: string;
  66758. /**
  66759. * Gets the loaded images
  66760. */
  66761. image: HTMLImageElement;
  66762. /**
  66763. * Callback called when the task is successful
  66764. */
  66765. onSuccess: (task: ImageAssetTask) => void;
  66766. /**
  66767. * Callback called when the task is successful
  66768. */
  66769. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  66770. /**
  66771. * Creates a new ImageAssetTask
  66772. * @param name defines the name of the task
  66773. * @param url defines the location of the image to load
  66774. */
  66775. constructor(
  66776. /**
  66777. * Defines the name of the task
  66778. */
  66779. name: string,
  66780. /**
  66781. * Defines the location of the image to load
  66782. */
  66783. url: string);
  66784. /**
  66785. * Execute the current task
  66786. * @param scene defines the scene where you want your assets to be loaded
  66787. * @param onSuccess is a callback called when the task is successfully executed
  66788. * @param onError is a callback called if an error occurs
  66789. */
  66790. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66791. }
  66792. /**
  66793. * Defines the interface used by texture loading tasks
  66794. */
  66795. export interface ITextureAssetTask<TEX extends BaseTexture> {
  66796. /**
  66797. * Gets the loaded texture
  66798. */
  66799. texture: TEX;
  66800. }
  66801. /**
  66802. * Define a task used by AssetsManager to load 2D textures
  66803. */
  66804. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  66805. /**
  66806. * Defines the name of the task
  66807. */
  66808. name: string;
  66809. /**
  66810. * Defines the location of the file to load
  66811. */
  66812. url: string;
  66813. /**
  66814. * Defines if mipmap should not be generated (default is false)
  66815. */
  66816. noMipmap?: boolean | undefined;
  66817. /**
  66818. * Defines if texture must be inverted on Y axis (default is false)
  66819. */
  66820. invertY?: boolean | undefined;
  66821. /**
  66822. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66823. */
  66824. samplingMode: number;
  66825. /**
  66826. * Gets the loaded texture
  66827. */
  66828. texture: Texture;
  66829. /**
  66830. * Callback called when the task is successful
  66831. */
  66832. onSuccess: (task: TextureAssetTask) => void;
  66833. /**
  66834. * Callback called when the task is successful
  66835. */
  66836. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  66837. /**
  66838. * Creates a new TextureAssetTask object
  66839. * @param name defines the name of the task
  66840. * @param url defines the location of the file to load
  66841. * @param noMipmap defines if mipmap should not be generated (default is false)
  66842. * @param invertY defines if texture must be inverted on Y axis (default is false)
  66843. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66844. */
  66845. constructor(
  66846. /**
  66847. * Defines the name of the task
  66848. */
  66849. name: string,
  66850. /**
  66851. * Defines the location of the file to load
  66852. */
  66853. url: string,
  66854. /**
  66855. * Defines if mipmap should not be generated (default is false)
  66856. */
  66857. noMipmap?: boolean | undefined,
  66858. /**
  66859. * Defines if texture must be inverted on Y axis (default is false)
  66860. */
  66861. invertY?: boolean | undefined,
  66862. /**
  66863. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66864. */
  66865. samplingMode?: number);
  66866. /**
  66867. * Execute the current task
  66868. * @param scene defines the scene where you want your assets to be loaded
  66869. * @param onSuccess is a callback called when the task is successfully executed
  66870. * @param onError is a callback called if an error occurs
  66871. */
  66872. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66873. }
  66874. /**
  66875. * Define a task used by AssetsManager to load cube textures
  66876. */
  66877. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  66878. /**
  66879. * Defines the name of the task
  66880. */
  66881. name: string;
  66882. /**
  66883. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66884. */
  66885. url: string;
  66886. /**
  66887. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66888. */
  66889. extensions?: string[] | undefined;
  66890. /**
  66891. * Defines if mipmaps should not be generated (default is false)
  66892. */
  66893. noMipmap?: boolean | undefined;
  66894. /**
  66895. * Defines the explicit list of files (undefined by default)
  66896. */
  66897. files?: string[] | undefined;
  66898. /**
  66899. * Gets the loaded texture
  66900. */
  66901. texture: CubeTexture;
  66902. /**
  66903. * Callback called when the task is successful
  66904. */
  66905. onSuccess: (task: CubeTextureAssetTask) => void;
  66906. /**
  66907. * Callback called when the task is successful
  66908. */
  66909. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  66910. /**
  66911. * Creates a new CubeTextureAssetTask
  66912. * @param name defines the name of the task
  66913. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66914. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66915. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66916. * @param files defines the explicit list of files (undefined by default)
  66917. */
  66918. constructor(
  66919. /**
  66920. * Defines the name of the task
  66921. */
  66922. name: string,
  66923. /**
  66924. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66925. */
  66926. url: string,
  66927. /**
  66928. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66929. */
  66930. extensions?: string[] | undefined,
  66931. /**
  66932. * Defines if mipmaps should not be generated (default is false)
  66933. */
  66934. noMipmap?: boolean | undefined,
  66935. /**
  66936. * Defines the explicit list of files (undefined by default)
  66937. */
  66938. files?: string[] | undefined);
  66939. /**
  66940. * Execute the current task
  66941. * @param scene defines the scene where you want your assets to be loaded
  66942. * @param onSuccess is a callback called when the task is successfully executed
  66943. * @param onError is a callback called if an error occurs
  66944. */
  66945. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66946. }
  66947. /**
  66948. * Define a task used by AssetsManager to load HDR cube textures
  66949. */
  66950. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  66951. /**
  66952. * Defines the name of the task
  66953. */
  66954. name: string;
  66955. /**
  66956. * Defines the location of the file to load
  66957. */
  66958. url: string;
  66959. /**
  66960. * Defines the desired size (the more it increases the longer the generation will be)
  66961. */
  66962. size: number;
  66963. /**
  66964. * Defines if mipmaps should not be generated (default is false)
  66965. */
  66966. noMipmap: boolean;
  66967. /**
  66968. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66969. */
  66970. generateHarmonics: boolean;
  66971. /**
  66972. * 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)
  66973. */
  66974. gammaSpace: boolean;
  66975. /**
  66976. * Internal Use Only
  66977. */
  66978. reserved: boolean;
  66979. /**
  66980. * Gets the loaded texture
  66981. */
  66982. texture: HDRCubeTexture;
  66983. /**
  66984. * Callback called when the task is successful
  66985. */
  66986. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  66987. /**
  66988. * Callback called when the task is successful
  66989. */
  66990. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  66991. /**
  66992. * Creates a new HDRCubeTextureAssetTask object
  66993. * @param name defines the name of the task
  66994. * @param url defines the location of the file to load
  66995. * @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.
  66996. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66997. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66998. * @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)
  66999. * @param reserved Internal use only
  67000. */
  67001. constructor(
  67002. /**
  67003. * Defines the name of the task
  67004. */
  67005. name: string,
  67006. /**
  67007. * Defines the location of the file to load
  67008. */
  67009. url: string,
  67010. /**
  67011. * Defines the desired size (the more it increases the longer the generation will be)
  67012. */
  67013. size: number,
  67014. /**
  67015. * Defines if mipmaps should not be generated (default is false)
  67016. */
  67017. noMipmap?: boolean,
  67018. /**
  67019. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67020. */
  67021. generateHarmonics?: boolean,
  67022. /**
  67023. * 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)
  67024. */
  67025. gammaSpace?: boolean,
  67026. /**
  67027. * Internal Use Only
  67028. */
  67029. reserved?: boolean);
  67030. /**
  67031. * Execute the current task
  67032. * @param scene defines the scene where you want your assets to be loaded
  67033. * @param onSuccess is a callback called when the task is successfully executed
  67034. * @param onError is a callback called if an error occurs
  67035. */
  67036. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67037. }
  67038. /**
  67039. * Define a task used by AssetsManager to load Equirectangular cube textures
  67040. */
  67041. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67042. /**
  67043. * Defines the name of the task
  67044. */
  67045. name: string;
  67046. /**
  67047. * Defines the location of the file to load
  67048. */
  67049. url: string;
  67050. /**
  67051. * Defines the desired size (the more it increases the longer the generation will be)
  67052. */
  67053. size: number;
  67054. /**
  67055. * Defines if mipmaps should not be generated (default is false)
  67056. */
  67057. noMipmap: boolean;
  67058. /**
  67059. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67060. * but the standard material would require them in Gamma space) (default is true)
  67061. */
  67062. gammaSpace: boolean;
  67063. /**
  67064. * Gets the loaded texture
  67065. */
  67066. texture: EquiRectangularCubeTexture;
  67067. /**
  67068. * Callback called when the task is successful
  67069. */
  67070. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67071. /**
  67072. * Callback called when the task is successful
  67073. */
  67074. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67075. /**
  67076. * Creates a new EquiRectangularCubeTextureAssetTask object
  67077. * @param name defines the name of the task
  67078. * @param url defines the location of the file to load
  67079. * @param size defines the desired size (the more it increases the longer the generation will be)
  67080. * If the size is omitted this implies you are using a preprocessed cubemap.
  67081. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67082. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67083. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67084. * (default is true)
  67085. */
  67086. constructor(
  67087. /**
  67088. * Defines the name of the task
  67089. */
  67090. name: string,
  67091. /**
  67092. * Defines the location of the file to load
  67093. */
  67094. url: string,
  67095. /**
  67096. * Defines the desired size (the more it increases the longer the generation will be)
  67097. */
  67098. size: number,
  67099. /**
  67100. * Defines if mipmaps should not be generated (default is false)
  67101. */
  67102. noMipmap?: boolean,
  67103. /**
  67104. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67105. * but the standard material would require them in Gamma space) (default is true)
  67106. */
  67107. gammaSpace?: boolean);
  67108. /**
  67109. * Execute the current task
  67110. * @param scene defines the scene where you want your assets to be loaded
  67111. * @param onSuccess is a callback called when the task is successfully executed
  67112. * @param onError is a callback called if an error occurs
  67113. */
  67114. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67115. }
  67116. /**
  67117. * This class can be used to easily import assets into a scene
  67118. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67119. */
  67120. export class AssetsManager {
  67121. private _scene;
  67122. private _isLoading;
  67123. protected _tasks: AbstractAssetTask[];
  67124. protected _waitingTasksCount: number;
  67125. protected _totalTasksCount: number;
  67126. /**
  67127. * Callback called when all tasks are processed
  67128. */
  67129. onFinish: (tasks: AbstractAssetTask[]) => void;
  67130. /**
  67131. * Callback called when a task is successful
  67132. */
  67133. onTaskSuccess: (task: AbstractAssetTask) => void;
  67134. /**
  67135. * Callback called when a task had an error
  67136. */
  67137. onTaskError: (task: AbstractAssetTask) => void;
  67138. /**
  67139. * Callback called when a task is done (whatever the result is)
  67140. */
  67141. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67142. /**
  67143. * Observable called when all tasks are processed
  67144. */
  67145. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67146. /**
  67147. * Observable called when a task had an error
  67148. */
  67149. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67150. /**
  67151. * Observable called when all tasks were executed
  67152. */
  67153. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67154. /**
  67155. * Observable called when a task is done (whatever the result is)
  67156. */
  67157. onProgressObservable: Observable<IAssetsProgressEvent>;
  67158. /**
  67159. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67160. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67161. */
  67162. useDefaultLoadingScreen: boolean;
  67163. /**
  67164. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67165. * when all assets have been downloaded.
  67166. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67167. */
  67168. autoHideLoadingUI: boolean;
  67169. /**
  67170. * Creates a new AssetsManager
  67171. * @param scene defines the scene to work on
  67172. */
  67173. constructor(scene: Scene);
  67174. /**
  67175. * Add a MeshAssetTask to the list of active tasks
  67176. * @param taskName defines the name of the new task
  67177. * @param meshesNames defines the name of meshes to load
  67178. * @param rootUrl defines the root url to use to locate files
  67179. * @param sceneFilename defines the filename of the scene file
  67180. * @returns a new MeshAssetTask object
  67181. */
  67182. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67183. /**
  67184. * Add a TextFileAssetTask to the list of active tasks
  67185. * @param taskName defines the name of the new task
  67186. * @param url defines the url of the file to load
  67187. * @returns a new TextFileAssetTask object
  67188. */
  67189. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67190. /**
  67191. * Add a BinaryFileAssetTask to the list of active tasks
  67192. * @param taskName defines the name of the new task
  67193. * @param url defines the url of the file to load
  67194. * @returns a new BinaryFileAssetTask object
  67195. */
  67196. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67197. /**
  67198. * Add a ImageAssetTask to the list of active tasks
  67199. * @param taskName defines the name of the new task
  67200. * @param url defines the url of the file to load
  67201. * @returns a new ImageAssetTask object
  67202. */
  67203. addImageTask(taskName: string, url: string): ImageAssetTask;
  67204. /**
  67205. * Add a TextureAssetTask to the list of active tasks
  67206. * @param taskName defines the name of the new task
  67207. * @param url defines the url of the file to load
  67208. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67209. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67210. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67211. * @returns a new TextureAssetTask object
  67212. */
  67213. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67214. /**
  67215. * Add a CubeTextureAssetTask to the list of active tasks
  67216. * @param taskName defines the name of the new task
  67217. * @param url defines the url of the file to load
  67218. * @param extensions defines the extension to use to load the cube map (can be null)
  67219. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67220. * @param files defines the list of files to load (can be null)
  67221. * @returns a new CubeTextureAssetTask object
  67222. */
  67223. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67224. /**
  67225. *
  67226. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67227. * @param taskName defines the name of the new task
  67228. * @param url defines the url of the file to load
  67229. * @param size defines the size you want for the cubemap (can be null)
  67230. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67231. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67232. * @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)
  67233. * @param reserved Internal use only
  67234. * @returns a new HDRCubeTextureAssetTask object
  67235. */
  67236. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67237. /**
  67238. *
  67239. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67240. * @param taskName defines the name of the new task
  67241. * @param url defines the url of the file to load
  67242. * @param size defines the size you want for the cubemap (can be null)
  67243. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67244. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67245. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67246. * @returns a new EquiRectangularCubeTextureAssetTask object
  67247. */
  67248. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67249. /**
  67250. * Remove a task from the assets manager.
  67251. * @param task the task to remove
  67252. */
  67253. removeTask(task: AbstractAssetTask): void;
  67254. private _decreaseWaitingTasksCount;
  67255. private _runTask;
  67256. /**
  67257. * Reset the AssetsManager and remove all tasks
  67258. * @return the current instance of the AssetsManager
  67259. */
  67260. reset(): AssetsManager;
  67261. /**
  67262. * Start the loading process
  67263. * @return the current instance of the AssetsManager
  67264. */
  67265. load(): AssetsManager;
  67266. /**
  67267. * Start the loading process as an async operation
  67268. * @return a promise returning the list of failed tasks
  67269. */
  67270. loadAsync(): Promise<void>;
  67271. }
  67272. }
  67273. declare module "babylonjs/Misc/deferred" {
  67274. /**
  67275. * Wrapper class for promise with external resolve and reject.
  67276. */
  67277. export class Deferred<T> {
  67278. /**
  67279. * The promise associated with this deferred object.
  67280. */
  67281. readonly promise: Promise<T>;
  67282. private _resolve;
  67283. private _reject;
  67284. /**
  67285. * The resolve method of the promise associated with this deferred object.
  67286. */
  67287. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  67288. /**
  67289. * The reject method of the promise associated with this deferred object.
  67290. */
  67291. readonly reject: (reason?: any) => void;
  67292. /**
  67293. * Constructor for this deferred object.
  67294. */
  67295. constructor();
  67296. }
  67297. }
  67298. declare module "babylonjs/Misc/meshExploder" {
  67299. import { Mesh } from "babylonjs/Meshes/mesh";
  67300. /**
  67301. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67302. */
  67303. export class MeshExploder {
  67304. private _centerMesh;
  67305. private _meshes;
  67306. private _meshesOrigins;
  67307. private _toCenterVectors;
  67308. private _scaledDirection;
  67309. private _newPosition;
  67310. private _centerPosition;
  67311. /**
  67312. * Explodes meshes from a center mesh.
  67313. * @param meshes The meshes to explode.
  67314. * @param centerMesh The mesh to be center of explosion.
  67315. */
  67316. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67317. private _setCenterMesh;
  67318. /**
  67319. * Get class name
  67320. * @returns "MeshExploder"
  67321. */
  67322. getClassName(): string;
  67323. /**
  67324. * "Exploded meshes"
  67325. * @returns Array of meshes with the centerMesh at index 0.
  67326. */
  67327. getMeshes(): Array<Mesh>;
  67328. /**
  67329. * Explodes meshes giving a specific direction
  67330. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67331. */
  67332. explode(direction?: number): void;
  67333. }
  67334. }
  67335. declare module "babylonjs/Misc/filesInput" {
  67336. import { Engine } from "babylonjs/Engines/engine";
  67337. import { Scene } from "babylonjs/scene";
  67338. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  67339. /**
  67340. * Class used to help managing file picking and drag'n'drop
  67341. */
  67342. export class FilesInput {
  67343. /**
  67344. * List of files ready to be loaded
  67345. */
  67346. static readonly FilesToLoad: {
  67347. [key: string]: File;
  67348. };
  67349. /**
  67350. * Callback called when a file is processed
  67351. */
  67352. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67353. private _engine;
  67354. private _currentScene;
  67355. private _sceneLoadedCallback;
  67356. private _progressCallback;
  67357. private _additionalRenderLoopLogicCallback;
  67358. private _textureLoadingCallback;
  67359. private _startingProcessingFilesCallback;
  67360. private _onReloadCallback;
  67361. private _errorCallback;
  67362. private _elementToMonitor;
  67363. private _sceneFileToLoad;
  67364. private _filesToLoad;
  67365. /**
  67366. * Creates a new FilesInput
  67367. * @param engine defines the rendering engine
  67368. * @param scene defines the hosting scene
  67369. * @param sceneLoadedCallback callback called when scene is loaded
  67370. * @param progressCallback callback called to track progress
  67371. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67372. * @param textureLoadingCallback callback called when a texture is loading
  67373. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67374. * @param onReloadCallback callback called when a reload is requested
  67375. * @param errorCallback callback call if an error occurs
  67376. */
  67377. 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);
  67378. private _dragEnterHandler;
  67379. private _dragOverHandler;
  67380. private _dropHandler;
  67381. /**
  67382. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67383. * @param elementToMonitor defines the DOM element to track
  67384. */
  67385. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67386. /**
  67387. * Release all associated resources
  67388. */
  67389. dispose(): void;
  67390. private renderFunction;
  67391. private drag;
  67392. private drop;
  67393. private _traverseFolder;
  67394. private _processFiles;
  67395. /**
  67396. * Load files from a drop event
  67397. * @param event defines the drop event to use as source
  67398. */
  67399. loadFiles(event: any): void;
  67400. private _processReload;
  67401. /**
  67402. * Reload the current scene from the loaded files
  67403. */
  67404. reload(): void;
  67405. }
  67406. }
  67407. declare module "babylonjs/Misc/HighDynamicRange/index" {
  67408. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  67409. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  67410. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  67411. }
  67412. declare module "babylonjs/Misc/sceneOptimizer" {
  67413. import { Scene, IDisposable } from "babylonjs/scene";
  67414. import { Observable } from "babylonjs/Misc/observable";
  67415. /**
  67416. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67417. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67418. */
  67419. export class SceneOptimization {
  67420. /**
  67421. * Defines the priority of this optimization (0 by default which means first in the list)
  67422. */
  67423. priority: number;
  67424. /**
  67425. * Gets a string describing the action executed by the current optimization
  67426. * @returns description string
  67427. */
  67428. getDescription(): string;
  67429. /**
  67430. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67431. * @param scene defines the current scene where to apply this optimization
  67432. * @param optimizer defines the current optimizer
  67433. * @returns true if everything that can be done was applied
  67434. */
  67435. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67436. /**
  67437. * Creates the SceneOptimization object
  67438. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67439. * @param desc defines the description associated with the optimization
  67440. */
  67441. constructor(
  67442. /**
  67443. * Defines the priority of this optimization (0 by default which means first in the list)
  67444. */
  67445. priority?: number);
  67446. }
  67447. /**
  67448. * Defines an optimization used to reduce the size of render target textures
  67449. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67450. */
  67451. export class TextureOptimization extends SceneOptimization {
  67452. /**
  67453. * Defines the priority of this optimization (0 by default which means first in the list)
  67454. */
  67455. priority: number;
  67456. /**
  67457. * 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
  67458. */
  67459. maximumSize: number;
  67460. /**
  67461. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67462. */
  67463. step: number;
  67464. /**
  67465. * Gets a string describing the action executed by the current optimization
  67466. * @returns description string
  67467. */
  67468. getDescription(): string;
  67469. /**
  67470. * Creates the TextureOptimization object
  67471. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67472. * @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
  67473. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67474. */
  67475. constructor(
  67476. /**
  67477. * Defines the priority of this optimization (0 by default which means first in the list)
  67478. */
  67479. priority?: number,
  67480. /**
  67481. * 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
  67482. */
  67483. maximumSize?: number,
  67484. /**
  67485. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67486. */
  67487. step?: number);
  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 increase or decrease the rendering resolution
  67498. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67499. */
  67500. export class HardwareScalingOptimization extends SceneOptimization {
  67501. /**
  67502. * Defines the priority of this optimization (0 by default which means first in the list)
  67503. */
  67504. priority: number;
  67505. /**
  67506. * Defines the maximum scale to use (2 by default)
  67507. */
  67508. maximumScale: number;
  67509. /**
  67510. * Defines the step to use between two passes (0.5 by default)
  67511. */
  67512. step: number;
  67513. private _currentScale;
  67514. private _directionOffset;
  67515. /**
  67516. * Gets a string describing the action executed by the current optimization
  67517. * @return description string
  67518. */
  67519. getDescription(): string;
  67520. /**
  67521. * Creates the HardwareScalingOptimization object
  67522. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67523. * @param maximumScale defines the maximum scale to use (2 by default)
  67524. * @param step defines the step to use between two passes (0.5 by default)
  67525. */
  67526. constructor(
  67527. /**
  67528. * Defines the priority of this optimization (0 by default which means first in the list)
  67529. */
  67530. priority?: number,
  67531. /**
  67532. * Defines the maximum scale to use (2 by default)
  67533. */
  67534. maximumScale?: number,
  67535. /**
  67536. * Defines the step to use between two passes (0.5 by default)
  67537. */
  67538. step?: number);
  67539. /**
  67540. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67541. * @param scene defines the current scene where to apply this optimization
  67542. * @param optimizer defines the current optimizer
  67543. * @returns true if everything that can be done was applied
  67544. */
  67545. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67546. }
  67547. /**
  67548. * Defines an optimization used to remove shadows
  67549. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67550. */
  67551. export class ShadowsOptimization extends SceneOptimization {
  67552. /**
  67553. * Gets a string describing the action executed by the current optimization
  67554. * @return description string
  67555. */
  67556. getDescription(): string;
  67557. /**
  67558. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67559. * @param scene defines the current scene where to apply this optimization
  67560. * @param optimizer defines the current optimizer
  67561. * @returns true if everything that can be done was applied
  67562. */
  67563. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67564. }
  67565. /**
  67566. * Defines an optimization used to turn post-processes off
  67567. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67568. */
  67569. export class PostProcessesOptimization extends SceneOptimization {
  67570. /**
  67571. * Gets a string describing the action executed by the current optimization
  67572. * @return description string
  67573. */
  67574. getDescription(): string;
  67575. /**
  67576. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67577. * @param scene defines the current scene where to apply this optimization
  67578. * @param optimizer defines the current optimizer
  67579. * @returns true if everything that can be done was applied
  67580. */
  67581. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67582. }
  67583. /**
  67584. * Defines an optimization used to turn lens flares off
  67585. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67586. */
  67587. export class LensFlaresOptimization extends SceneOptimization {
  67588. /**
  67589. * Gets a string describing the action executed by the current optimization
  67590. * @return description string
  67591. */
  67592. getDescription(): string;
  67593. /**
  67594. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67595. * @param scene defines the current scene where to apply this optimization
  67596. * @param optimizer defines the current optimizer
  67597. * @returns true if everything that can be done was applied
  67598. */
  67599. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67600. }
  67601. /**
  67602. * Defines an optimization based on user defined callback.
  67603. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67604. */
  67605. export class CustomOptimization extends SceneOptimization {
  67606. /**
  67607. * Callback called to apply the custom optimization.
  67608. */
  67609. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  67610. /**
  67611. * Callback called to get custom description
  67612. */
  67613. onGetDescription: () => string;
  67614. /**
  67615. * Gets a string describing the action executed by the current optimization
  67616. * @returns description string
  67617. */
  67618. getDescription(): string;
  67619. /**
  67620. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67621. * @param scene defines the current scene where to apply this optimization
  67622. * @param optimizer defines the current optimizer
  67623. * @returns true if everything that can be done was applied
  67624. */
  67625. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67626. }
  67627. /**
  67628. * Defines an optimization used to turn particles off
  67629. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67630. */
  67631. export class ParticlesOptimization extends SceneOptimization {
  67632. /**
  67633. * Gets a string describing the action executed by the current optimization
  67634. * @return description string
  67635. */
  67636. getDescription(): string;
  67637. /**
  67638. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67639. * @param scene defines the current scene where to apply this optimization
  67640. * @param optimizer defines the current optimizer
  67641. * @returns true if everything that can be done was applied
  67642. */
  67643. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67644. }
  67645. /**
  67646. * Defines an optimization used to turn render targets off
  67647. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67648. */
  67649. export class RenderTargetsOptimization extends SceneOptimization {
  67650. /**
  67651. * Gets a string describing the action executed by the current optimization
  67652. * @return description string
  67653. */
  67654. getDescription(): string;
  67655. /**
  67656. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67657. * @param scene defines the current scene where to apply this optimization
  67658. * @param optimizer defines the current optimizer
  67659. * @returns true if everything that can be done was applied
  67660. */
  67661. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67662. }
  67663. /**
  67664. * Defines an optimization used to merge meshes with compatible materials
  67665. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67666. */
  67667. export class MergeMeshesOptimization extends SceneOptimization {
  67668. private static _UpdateSelectionTree;
  67669. /**
  67670. * Gets or sets a boolean which defines if optimization octree has to be updated
  67671. */
  67672. /**
  67673. * Gets or sets a boolean which defines if optimization octree has to be updated
  67674. */
  67675. static UpdateSelectionTree: boolean;
  67676. /**
  67677. * Gets a string describing the action executed by the current optimization
  67678. * @return description string
  67679. */
  67680. getDescription(): string;
  67681. private _canBeMerged;
  67682. /**
  67683. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67684. * @param scene defines the current scene where to apply this optimization
  67685. * @param optimizer defines the current optimizer
  67686. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  67687. * @returns true if everything that can be done was applied
  67688. */
  67689. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  67690. }
  67691. /**
  67692. * Defines a list of options used by SceneOptimizer
  67693. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67694. */
  67695. export class SceneOptimizerOptions {
  67696. /**
  67697. * Defines the target frame rate to reach (60 by default)
  67698. */
  67699. targetFrameRate: number;
  67700. /**
  67701. * Defines the interval between two checkes (2000ms by default)
  67702. */
  67703. trackerDuration: number;
  67704. /**
  67705. * Gets the list of optimizations to apply
  67706. */
  67707. optimizations: SceneOptimization[];
  67708. /**
  67709. * Creates a new list of options used by SceneOptimizer
  67710. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  67711. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  67712. */
  67713. constructor(
  67714. /**
  67715. * Defines the target frame rate to reach (60 by default)
  67716. */
  67717. targetFrameRate?: number,
  67718. /**
  67719. * Defines the interval between two checkes (2000ms by default)
  67720. */
  67721. trackerDuration?: number);
  67722. /**
  67723. * Add a new optimization
  67724. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  67725. * @returns the current SceneOptimizerOptions
  67726. */
  67727. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  67728. /**
  67729. * Add a new custom optimization
  67730. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  67731. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  67732. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67733. * @returns the current SceneOptimizerOptions
  67734. */
  67735. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  67736. /**
  67737. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  67738. * @param targetFrameRate defines the target frame rate (60 by default)
  67739. * @returns a SceneOptimizerOptions object
  67740. */
  67741. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67742. /**
  67743. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  67744. * @param targetFrameRate defines the target frame rate (60 by default)
  67745. * @returns a SceneOptimizerOptions object
  67746. */
  67747. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67748. /**
  67749. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  67750. * @param targetFrameRate defines the target frame rate (60 by default)
  67751. * @returns a SceneOptimizerOptions object
  67752. */
  67753. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67754. }
  67755. /**
  67756. * Class used to run optimizations in order to reach a target frame rate
  67757. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67758. */
  67759. export class SceneOptimizer implements IDisposable {
  67760. private _isRunning;
  67761. private _options;
  67762. private _scene;
  67763. private _currentPriorityLevel;
  67764. private _targetFrameRate;
  67765. private _trackerDuration;
  67766. private _currentFrameRate;
  67767. private _sceneDisposeObserver;
  67768. private _improvementMode;
  67769. /**
  67770. * Defines an observable called when the optimizer reaches the target frame rate
  67771. */
  67772. onSuccessObservable: Observable<SceneOptimizer>;
  67773. /**
  67774. * Defines an observable called when the optimizer enables an optimization
  67775. */
  67776. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  67777. /**
  67778. * Defines an observable called when the optimizer is not able to reach the target frame rate
  67779. */
  67780. onFailureObservable: Observable<SceneOptimizer>;
  67781. /**
  67782. * Gets a boolean indicating if the optimizer is in improvement mode
  67783. */
  67784. readonly isInImprovementMode: boolean;
  67785. /**
  67786. * Gets the current priority level (0 at start)
  67787. */
  67788. readonly currentPriorityLevel: number;
  67789. /**
  67790. * Gets the current frame rate checked by the SceneOptimizer
  67791. */
  67792. readonly currentFrameRate: number;
  67793. /**
  67794. * Gets or sets the current target frame rate (60 by default)
  67795. */
  67796. /**
  67797. * Gets or sets the current target frame rate (60 by default)
  67798. */
  67799. targetFrameRate: number;
  67800. /**
  67801. * Gets or sets the current interval between two checks (every 2000ms by default)
  67802. */
  67803. /**
  67804. * Gets or sets the current interval between two checks (every 2000ms by default)
  67805. */
  67806. trackerDuration: number;
  67807. /**
  67808. * Gets the list of active optimizations
  67809. */
  67810. readonly optimizations: SceneOptimization[];
  67811. /**
  67812. * Creates a new SceneOptimizer
  67813. * @param scene defines the scene to work on
  67814. * @param options defines the options to use with the SceneOptimizer
  67815. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  67816. * @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)
  67817. */
  67818. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  67819. /**
  67820. * Stops the current optimizer
  67821. */
  67822. stop(): void;
  67823. /**
  67824. * Reset the optimizer to initial step (current priority level = 0)
  67825. */
  67826. reset(): void;
  67827. /**
  67828. * Start the optimizer. By default it will try to reach a specific framerate
  67829. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  67830. */
  67831. start(): void;
  67832. private _checkCurrentState;
  67833. /**
  67834. * Release all resources
  67835. */
  67836. dispose(): void;
  67837. /**
  67838. * Helper function to create a SceneOptimizer with one single line of code
  67839. * @param scene defines the scene to work on
  67840. * @param options defines the options to use with the SceneOptimizer
  67841. * @param onSuccess defines a callback to call on success
  67842. * @param onFailure defines a callback to call on failure
  67843. * @returns the new SceneOptimizer object
  67844. */
  67845. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  67846. }
  67847. }
  67848. declare module "babylonjs/Misc/sceneSerializer" {
  67849. import { Scene } from "babylonjs/scene";
  67850. /**
  67851. * Class used to serialize a scene into a string
  67852. */
  67853. export class SceneSerializer {
  67854. /**
  67855. * Clear cache used by a previous serialization
  67856. */
  67857. static ClearCache(): void;
  67858. /**
  67859. * Serialize a scene into a JSON compatible object
  67860. * @param scene defines the scene to serialize
  67861. * @returns a JSON compatible object
  67862. */
  67863. static Serialize(scene: Scene): any;
  67864. /**
  67865. * Serialize a mesh into a JSON compatible object
  67866. * @param toSerialize defines the mesh to serialize
  67867. * @param withParents defines if parents must be serialized as well
  67868. * @param withChildren defines if children must be serialized as well
  67869. * @returns a JSON compatible object
  67870. */
  67871. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  67872. }
  67873. }
  67874. declare module "babylonjs/Misc/textureTools" {
  67875. import { Texture } from "babylonjs/Materials/Textures/texture";
  67876. /**
  67877. * Class used to host texture specific utilities
  67878. */
  67879. export class TextureTools {
  67880. /**
  67881. * Uses the GPU to create a copy texture rescaled at a given size
  67882. * @param texture Texture to copy from
  67883. * @param width defines the desired width
  67884. * @param height defines the desired height
  67885. * @param useBilinearMode defines if bilinear mode has to be used
  67886. * @return the generated texture
  67887. */
  67888. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  67889. }
  67890. }
  67891. declare module "babylonjs/Misc/videoRecorder" {
  67892. import { Nullable } from "babylonjs/types";
  67893. import { Engine } from "babylonjs/Engines/engine";
  67894. /**
  67895. * This represents the different options available for the video capture.
  67896. */
  67897. export interface VideoRecorderOptions {
  67898. /** Defines the mime type of the video. */
  67899. mimeType: string;
  67900. /** Defines the FPS the video should be recorded at. */
  67901. fps: number;
  67902. /** Defines the chunk size for the recording data. */
  67903. recordChunckSize: number;
  67904. /** The audio tracks to attach to the recording. */
  67905. audioTracks?: MediaStreamTrack[];
  67906. }
  67907. /**
  67908. * This can help with recording videos from BabylonJS.
  67909. * This is based on the available WebRTC functionalities of the browser.
  67910. *
  67911. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  67912. */
  67913. export class VideoRecorder {
  67914. private static readonly _defaultOptions;
  67915. /**
  67916. * Returns whether or not the VideoRecorder is available in your browser.
  67917. * @param engine Defines the Babylon Engine.
  67918. * @returns true if supported otherwise false.
  67919. */
  67920. static IsSupported(engine: Engine): boolean;
  67921. private readonly _options;
  67922. private _canvas;
  67923. private _mediaRecorder;
  67924. private _recordedChunks;
  67925. private _fileName;
  67926. private _resolve;
  67927. private _reject;
  67928. /**
  67929. * True when a recording is already in progress.
  67930. */
  67931. readonly isRecording: boolean;
  67932. /**
  67933. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  67934. * @param engine Defines the BabylonJS Engine you wish to record.
  67935. * @param options Defines options that can be used to customize the capture.
  67936. */
  67937. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  67938. /**
  67939. * Stops the current recording before the default capture timeout passed in the startRecording function.
  67940. */
  67941. stopRecording(): void;
  67942. /**
  67943. * Starts recording the canvas for a max duration specified in parameters.
  67944. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  67945. * If null no automatic download will start and you can rely on the promise to get the data back.
  67946. * @param maxDuration Defines the maximum recording time in seconds.
  67947. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  67948. * @return A promise callback at the end of the recording with the video data in Blob.
  67949. */
  67950. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  67951. /**
  67952. * Releases internal resources used during the recording.
  67953. */
  67954. dispose(): void;
  67955. private _handleDataAvailable;
  67956. private _handleError;
  67957. private _handleStop;
  67958. }
  67959. }
  67960. declare module "babylonjs/Misc/screenshotTools" {
  67961. import { Camera } from "babylonjs/Cameras/camera";
  67962. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  67963. import { Engine } from "babylonjs/Engines/engine";
  67964. /**
  67965. * Class containing a set of static utilities functions for screenshots
  67966. */
  67967. export class ScreenshotTools {
  67968. /**
  67969. * Captures a screenshot of the current rendering
  67970. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67971. * @param engine defines the rendering engine
  67972. * @param camera defines the source camera
  67973. * @param size This parameter can be set to a single number or to an object with the
  67974. * following (optional) properties: precision, width, height. If a single number is passed,
  67975. * it will be used for both width and height. If an object is passed, the screenshot size
  67976. * will be derived from the parameters. The precision property is a multiplier allowing
  67977. * rendering at a higher or lower resolution
  67978. * @param successCallback defines the callback receives a single parameter which contains the
  67979. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67980. * src parameter of an <img> to display it
  67981. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67982. * Check your browser for supported MIME types
  67983. */
  67984. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  67985. /**
  67986. * Captures a screenshot of the current rendering
  67987. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67988. * @param engine defines the rendering engine
  67989. * @param camera defines the source camera
  67990. * @param size This parameter can be set to a single number or to an object with the
  67991. * following (optional) properties: precision, width, height. If a single number is passed,
  67992. * it will be used for both width and height. If an object is passed, the screenshot size
  67993. * will be derived from the parameters. The precision property is a multiplier allowing
  67994. * rendering at a higher or lower resolution
  67995. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67996. * Check your browser for supported MIME types
  67997. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67998. * to the src parameter of an <img> to display it
  67999. */
  68000. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68001. /**
  68002. * Generates an image screenshot from the specified camera.
  68003. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68004. * @param engine The engine to use for rendering
  68005. * @param camera The camera to use for rendering
  68006. * @param size This parameter can be set to a single number or to an object with the
  68007. * following (optional) properties: precision, width, height. If a single number is passed,
  68008. * it will be used for both width and height. If an object is passed, the screenshot size
  68009. * will be derived from the parameters. The precision property is a multiplier allowing
  68010. * rendering at a higher or lower resolution
  68011. * @param successCallback The callback receives a single parameter which contains the
  68012. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68013. * src parameter of an <img> to display it
  68014. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68015. * Check your browser for supported MIME types
  68016. * @param samples Texture samples (default: 1)
  68017. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68018. * @param fileName A name for for the downloaded file.
  68019. */
  68020. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  68021. /**
  68022. * Generates an image screenshot from the specified camera.
  68023. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68024. * @param engine The engine to use for rendering
  68025. * @param camera The camera to use for rendering
  68026. * @param size This parameter can be set to a single number or to an object with the
  68027. * following (optional) properties: precision, width, height. If a single number is passed,
  68028. * it will be used for both width and height. If an object is passed, the screenshot size
  68029. * will be derived from the parameters. The precision property is a multiplier allowing
  68030. * rendering at a higher or lower resolution
  68031. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68032. * Check your browser for supported MIME types
  68033. * @param samples Texture samples (default: 1)
  68034. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68035. * @param fileName A name for for the downloaded file.
  68036. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68037. * to the src parameter of an <img> to display it
  68038. */
  68039. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  68040. /**
  68041. * Gets height and width for screenshot size
  68042. * @private
  68043. */
  68044. private static _getScreenshotSize;
  68045. }
  68046. }
  68047. declare module "babylonjs/Misc/dataReader" {
  68048. /**
  68049. * Interface for a data buffer
  68050. */
  68051. export interface IDataBuffer {
  68052. /**
  68053. * Reads bytes from the data buffer.
  68054. * @param byteOffset The byte offset to read
  68055. * @param byteLength The byte length to read
  68056. * @returns A promise that resolves when the bytes are read
  68057. */
  68058. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68059. /**
  68060. * The byte length of the buffer.
  68061. */
  68062. readonly byteLength: number;
  68063. }
  68064. /**
  68065. * Utility class for reading from a data buffer
  68066. */
  68067. export class DataReader {
  68068. /**
  68069. * The data buffer associated with this data reader.
  68070. */
  68071. readonly buffer: IDataBuffer;
  68072. /**
  68073. * The current byte offset from the beginning of the data buffer.
  68074. */
  68075. byteOffset: number;
  68076. private _dataView;
  68077. private _dataByteOffset;
  68078. /**
  68079. * Constructor
  68080. * @param buffer The buffer to read
  68081. */
  68082. constructor(buffer: IDataBuffer);
  68083. /**
  68084. * Loads the given byte length.
  68085. * @param byteLength The byte length to load
  68086. * @returns A promise that resolves when the load is complete
  68087. */
  68088. loadAsync(byteLength: number): Promise<void>;
  68089. /**
  68090. * Read a unsigned 32-bit integer from the currently loaded data range.
  68091. * @returns The 32-bit integer read
  68092. */
  68093. readUint32(): number;
  68094. /**
  68095. * Read a byte array from the currently loaded data range.
  68096. * @param byteLength The byte length to read
  68097. * @returns The byte array read
  68098. */
  68099. readUint8Array(byteLength: number): Uint8Array;
  68100. /**
  68101. * Read a string from the currently loaded data range.
  68102. * @param byteLength The byte length to read
  68103. * @returns The string read
  68104. */
  68105. readString(byteLength: number): string;
  68106. /**
  68107. * Skips the given byte length the currently loaded data range.
  68108. * @param byteLength The byte length to skip
  68109. */
  68110. skipBytes(byteLength: number): void;
  68111. }
  68112. }
  68113. declare module "babylonjs/Misc/index" {
  68114. export * from "babylonjs/Misc/andOrNotEvaluator";
  68115. export * from "babylonjs/Misc/assetsManager";
  68116. export * from "babylonjs/Misc/dds";
  68117. export * from "babylonjs/Misc/decorators";
  68118. export * from "babylonjs/Misc/deferred";
  68119. export * from "babylonjs/Misc/environmentTextureTools";
  68120. export * from "babylonjs/Misc/meshExploder";
  68121. export * from "babylonjs/Misc/filesInput";
  68122. export * from "babylonjs/Misc/HighDynamicRange/index";
  68123. export * from "babylonjs/Misc/khronosTextureContainer";
  68124. export * from "babylonjs/Misc/observable";
  68125. export * from "babylonjs/Misc/performanceMonitor";
  68126. export * from "babylonjs/Misc/promise";
  68127. export * from "babylonjs/Misc/sceneOptimizer";
  68128. export * from "babylonjs/Misc/sceneSerializer";
  68129. export * from "babylonjs/Misc/smartArray";
  68130. export * from "babylonjs/Misc/stringDictionary";
  68131. export * from "babylonjs/Misc/tags";
  68132. export * from "babylonjs/Misc/textureTools";
  68133. export * from "babylonjs/Misc/tga";
  68134. export * from "babylonjs/Misc/tools";
  68135. export * from "babylonjs/Misc/videoRecorder";
  68136. export * from "babylonjs/Misc/virtualJoystick";
  68137. export * from "babylonjs/Misc/workerPool";
  68138. export * from "babylonjs/Misc/logger";
  68139. export * from "babylonjs/Misc/typeStore";
  68140. export * from "babylonjs/Misc/filesInputStore";
  68141. export * from "babylonjs/Misc/deepCopier";
  68142. export * from "babylonjs/Misc/pivotTools";
  68143. export * from "babylonjs/Misc/precisionDate";
  68144. export * from "babylonjs/Misc/screenshotTools";
  68145. export * from "babylonjs/Misc/typeStore";
  68146. export * from "babylonjs/Misc/webRequest";
  68147. export * from "babylonjs/Misc/iInspectable";
  68148. export * from "babylonjs/Misc/brdfTextureTools";
  68149. export * from "babylonjs/Misc/rgbdTextureTools";
  68150. export * from "babylonjs/Misc/gradients";
  68151. export * from "babylonjs/Misc/perfCounter";
  68152. export * from "babylonjs/Misc/fileRequest";
  68153. export * from "babylonjs/Misc/customAnimationFrameRequester";
  68154. export * from "babylonjs/Misc/retryStrategy";
  68155. export * from "babylonjs/Misc/interfaces/screenshotSize";
  68156. export * from "babylonjs/Misc/canvasGenerator";
  68157. export * from "babylonjs/Misc/fileTools";
  68158. export * from "babylonjs/Misc/stringTools";
  68159. export * from "babylonjs/Misc/dataReader";
  68160. }
  68161. declare module "babylonjs/index" {
  68162. export * from "babylonjs/abstractScene";
  68163. export * from "babylonjs/Actions/index";
  68164. export * from "babylonjs/Animations/index";
  68165. export * from "babylonjs/assetContainer";
  68166. export * from "babylonjs/Audio/index";
  68167. export * from "babylonjs/Behaviors/index";
  68168. export * from "babylonjs/Bones/index";
  68169. export * from "babylonjs/Cameras/index";
  68170. export * from "babylonjs/Collisions/index";
  68171. export * from "babylonjs/Culling/index";
  68172. export * from "babylonjs/Debug/index";
  68173. export * from "babylonjs/Engines/index";
  68174. export * from "babylonjs/Events/index";
  68175. export * from "babylonjs/Gamepads/index";
  68176. export * from "babylonjs/Gizmos/index";
  68177. export * from "babylonjs/Helpers/index";
  68178. export * from "babylonjs/Instrumentation/index";
  68179. export * from "babylonjs/Layers/index";
  68180. export * from "babylonjs/LensFlares/index";
  68181. export * from "babylonjs/Lights/index";
  68182. export * from "babylonjs/Loading/index";
  68183. export * from "babylonjs/Materials/index";
  68184. export * from "babylonjs/Maths/index";
  68185. export * from "babylonjs/Meshes/index";
  68186. export * from "babylonjs/Morph/index";
  68187. export * from "babylonjs/Navigation/index";
  68188. export * from "babylonjs/node";
  68189. export * from "babylonjs/Offline/index";
  68190. export * from "babylonjs/Particles/index";
  68191. export * from "babylonjs/Physics/index";
  68192. export * from "babylonjs/PostProcesses/index";
  68193. export * from "babylonjs/Probes/index";
  68194. export * from "babylonjs/Rendering/index";
  68195. export * from "babylonjs/scene";
  68196. export * from "babylonjs/sceneComponent";
  68197. export * from "babylonjs/Sprites/index";
  68198. export * from "babylonjs/States/index";
  68199. export * from "babylonjs/Misc/index";
  68200. export * from "babylonjs/types";
  68201. }
  68202. declare module "babylonjs/Animations/pathCursor" {
  68203. import { Vector3 } from "babylonjs/Maths/math.vector";
  68204. import { Path2 } from "babylonjs/Maths/math.path";
  68205. /**
  68206. * A cursor which tracks a point on a path
  68207. */
  68208. export class PathCursor {
  68209. private path;
  68210. /**
  68211. * Stores path cursor callbacks for when an onchange event is triggered
  68212. */
  68213. private _onchange;
  68214. /**
  68215. * The value of the path cursor
  68216. */
  68217. value: number;
  68218. /**
  68219. * The animation array of the path cursor
  68220. */
  68221. animations: Animation[];
  68222. /**
  68223. * Initializes the path cursor
  68224. * @param path The path to track
  68225. */
  68226. constructor(path: Path2);
  68227. /**
  68228. * Gets the cursor point on the path
  68229. * @returns A point on the path cursor at the cursor location
  68230. */
  68231. getPoint(): Vector3;
  68232. /**
  68233. * Moves the cursor ahead by the step amount
  68234. * @param step The amount to move the cursor forward
  68235. * @returns This path cursor
  68236. */
  68237. moveAhead(step?: number): PathCursor;
  68238. /**
  68239. * Moves the cursor behind by the step amount
  68240. * @param step The amount to move the cursor back
  68241. * @returns This path cursor
  68242. */
  68243. moveBack(step?: number): PathCursor;
  68244. /**
  68245. * Moves the cursor by the step amount
  68246. * If the step amount is greater than one, an exception is thrown
  68247. * @param step The amount to move the cursor
  68248. * @returns This path cursor
  68249. */
  68250. move(step: number): PathCursor;
  68251. /**
  68252. * Ensures that the value is limited between zero and one
  68253. * @returns This path cursor
  68254. */
  68255. private ensureLimits;
  68256. /**
  68257. * Runs onchange callbacks on change (used by the animation engine)
  68258. * @returns This path cursor
  68259. */
  68260. private raiseOnChange;
  68261. /**
  68262. * Executes a function on change
  68263. * @param f A path cursor onchange callback
  68264. * @returns This path cursor
  68265. */
  68266. onchange(f: (cursor: PathCursor) => void): PathCursor;
  68267. }
  68268. }
  68269. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  68270. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  68271. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  68272. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  68273. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  68274. }
  68275. declare module "babylonjs/Engines/Processors/Expressions/index" {
  68276. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  68277. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  68278. }
  68279. declare module "babylonjs/Engines/Processors/index" {
  68280. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  68281. export * from "babylonjs/Engines/Processors/Expressions/index";
  68282. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  68283. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  68284. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  68285. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  68286. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  68287. export * from "babylonjs/Engines/Processors/shaderProcessor";
  68288. }
  68289. declare module "babylonjs/Legacy/legacy" {
  68290. import * as Babylon from "babylonjs/index";
  68291. export * from "babylonjs/index";
  68292. }
  68293. declare module "babylonjs/Shaders/blur.fragment" {
  68294. /** @hidden */
  68295. export var blurPixelShader: {
  68296. name: string;
  68297. shader: string;
  68298. };
  68299. }
  68300. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  68301. /** @hidden */
  68302. export var pointCloudVertexDeclaration: {
  68303. name: string;
  68304. shader: string;
  68305. };
  68306. }
  68307. declare module "babylonjs" {
  68308. export * from "babylonjs/Legacy/legacy";
  68309. }
  68310. declare module BABYLON {
  68311. /** Alias type for value that can be null */
  68312. export type Nullable<T> = T | null;
  68313. /**
  68314. * Alias type for number that are floats
  68315. * @ignorenaming
  68316. */
  68317. export type float = number;
  68318. /**
  68319. * Alias type for number that are doubles.
  68320. * @ignorenaming
  68321. */
  68322. export type double = number;
  68323. /**
  68324. * Alias type for number that are integer
  68325. * @ignorenaming
  68326. */
  68327. export type int = number;
  68328. /** Alias type for number array or Float32Array */
  68329. export type FloatArray = number[] | Float32Array;
  68330. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  68331. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  68332. /**
  68333. * Alias for types that can be used by a Buffer or VertexBuffer.
  68334. */
  68335. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  68336. /**
  68337. * Alias type for primitive types
  68338. * @ignorenaming
  68339. */
  68340. type Primitive = undefined | null | boolean | string | number | Function;
  68341. /**
  68342. * Type modifier to make all the properties of an object Readonly
  68343. */
  68344. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  68345. /**
  68346. * Type modifier to make all the properties of an object Readonly recursively
  68347. */
  68348. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  68349. /**
  68350. * Type modifier to make object properties readonly.
  68351. */
  68352. export type DeepImmutableObject<T> = {
  68353. readonly [K in keyof T]: DeepImmutable<T[K]>;
  68354. };
  68355. /** @hidden */
  68356. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  68357. }
  68358. }
  68359. declare module BABYLON {
  68360. /**
  68361. * A class serves as a medium between the observable and its observers
  68362. */
  68363. export class EventState {
  68364. /**
  68365. * Create a new EventState
  68366. * @param mask defines the mask associated with this state
  68367. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68368. * @param target defines the original target of the state
  68369. * @param currentTarget defines the current target of the state
  68370. */
  68371. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  68372. /**
  68373. * Initialize the current event state
  68374. * @param mask defines the mask associated with this state
  68375. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68376. * @param target defines the original target of the state
  68377. * @param currentTarget defines the current target of the state
  68378. * @returns the current event state
  68379. */
  68380. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  68381. /**
  68382. * An Observer can set this property to true to prevent subsequent observers of being notified
  68383. */
  68384. skipNextObservers: boolean;
  68385. /**
  68386. * Get the mask value that were used to trigger the event corresponding to this EventState object
  68387. */
  68388. mask: number;
  68389. /**
  68390. * The object that originally notified the event
  68391. */
  68392. target?: any;
  68393. /**
  68394. * The current object in the bubbling phase
  68395. */
  68396. currentTarget?: any;
  68397. /**
  68398. * This will be populated with the return value of the last function that was executed.
  68399. * If it is the first function in the callback chain it will be the event data.
  68400. */
  68401. lastReturnValue?: any;
  68402. }
  68403. /**
  68404. * Represent an Observer registered to a given Observable object.
  68405. */
  68406. export class Observer<T> {
  68407. /**
  68408. * Defines the callback to call when the observer is notified
  68409. */
  68410. callback: (eventData: T, eventState: EventState) => void;
  68411. /**
  68412. * Defines the mask of the observer (used to filter notifications)
  68413. */
  68414. mask: number;
  68415. /**
  68416. * Defines the current scope used to restore the JS context
  68417. */
  68418. scope: any;
  68419. /** @hidden */
  68420. _willBeUnregistered: boolean;
  68421. /**
  68422. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  68423. */
  68424. unregisterOnNextCall: boolean;
  68425. /**
  68426. * Creates a new observer
  68427. * @param callback defines the callback to call when the observer is notified
  68428. * @param mask defines the mask of the observer (used to filter notifications)
  68429. * @param scope defines the current scope used to restore the JS context
  68430. */
  68431. constructor(
  68432. /**
  68433. * Defines the callback to call when the observer is notified
  68434. */
  68435. callback: (eventData: T, eventState: EventState) => void,
  68436. /**
  68437. * Defines the mask of the observer (used to filter notifications)
  68438. */
  68439. mask: number,
  68440. /**
  68441. * Defines the current scope used to restore the JS context
  68442. */
  68443. scope?: any);
  68444. }
  68445. /**
  68446. * Represent a list of observers registered to multiple Observables object.
  68447. */
  68448. export class MultiObserver<T> {
  68449. private _observers;
  68450. private _observables;
  68451. /**
  68452. * Release associated resources
  68453. */
  68454. dispose(): void;
  68455. /**
  68456. * Raise a callback when one of the observable will notify
  68457. * @param observables defines a list of observables to watch
  68458. * @param callback defines the callback to call on notification
  68459. * @param mask defines the mask used to filter notifications
  68460. * @param scope defines the current scope used to restore the JS context
  68461. * @returns the new MultiObserver
  68462. */
  68463. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  68464. }
  68465. /**
  68466. * The Observable class is a simple implementation of the Observable pattern.
  68467. *
  68468. * 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.
  68469. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  68470. * 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).
  68471. * 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.
  68472. */
  68473. export class Observable<T> {
  68474. private _observers;
  68475. private _eventState;
  68476. private _onObserverAdded;
  68477. /**
  68478. * Gets the list of observers
  68479. */
  68480. readonly observers: Array<Observer<T>>;
  68481. /**
  68482. * Creates a new observable
  68483. * @param onObserverAdded defines a callback to call when a new observer is added
  68484. */
  68485. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  68486. /**
  68487. * Create a new Observer with the specified callback
  68488. * @param callback the callback that will be executed for that Observer
  68489. * @param mask the mask used to filter observers
  68490. * @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.
  68491. * @param scope optional scope for the callback to be called from
  68492. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  68493. * @returns the new observer created for the callback
  68494. */
  68495. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  68496. /**
  68497. * Create a new Observer with the specified callback and unregisters after the next notification
  68498. * @param callback the callback that will be executed for that Observer
  68499. * @returns the new observer created for the callback
  68500. */
  68501. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  68502. /**
  68503. * Remove an Observer from the Observable object
  68504. * @param observer the instance of the Observer to remove
  68505. * @returns false if it doesn't belong to this Observable
  68506. */
  68507. remove(observer: Nullable<Observer<T>>): boolean;
  68508. /**
  68509. * Remove a callback from the Observable object
  68510. * @param callback the callback to remove
  68511. * @param scope optional scope. If used only the callbacks with this scope will be removed
  68512. * @returns false if it doesn't belong to this Observable
  68513. */
  68514. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  68515. private _deferUnregister;
  68516. private _remove;
  68517. /**
  68518. * Moves the observable to the top of the observer list making it get called first when notified
  68519. * @param observer the observer to move
  68520. */
  68521. makeObserverTopPriority(observer: Observer<T>): void;
  68522. /**
  68523. * Moves the observable to the bottom of the observer list making it get called last when notified
  68524. * @param observer the observer to move
  68525. */
  68526. makeObserverBottomPriority(observer: Observer<T>): void;
  68527. /**
  68528. * Notify all Observers by calling their respective callback with the given data
  68529. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  68530. * @param eventData defines the data to send to all observers
  68531. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  68532. * @param target defines the original target of the state
  68533. * @param currentTarget defines the current target of the state
  68534. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  68535. */
  68536. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  68537. /**
  68538. * Calling this will execute each callback, expecting it to be a promise or return a value.
  68539. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  68540. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  68541. * and it is crucial that all callbacks will be executed.
  68542. * The order of the callbacks is kept, callbacks are not executed parallel.
  68543. *
  68544. * @param eventData The data to be sent to each callback
  68545. * @param mask is used to filter observers defaults to -1
  68546. * @param target defines the callback target (see EventState)
  68547. * @param currentTarget defines he current object in the bubbling phase
  68548. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  68549. */
  68550. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  68551. /**
  68552. * Notify a specific observer
  68553. * @param observer defines the observer to notify
  68554. * @param eventData defines the data to be sent to each callback
  68555. * @param mask is used to filter observers defaults to -1
  68556. */
  68557. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  68558. /**
  68559. * Gets a boolean indicating if the observable has at least one observer
  68560. * @returns true is the Observable has at least one Observer registered
  68561. */
  68562. hasObservers(): boolean;
  68563. /**
  68564. * Clear the list of observers
  68565. */
  68566. clear(): void;
  68567. /**
  68568. * Clone the current observable
  68569. * @returns a new observable
  68570. */
  68571. clone(): Observable<T>;
  68572. /**
  68573. * Does this observable handles observer registered with a given mask
  68574. * @param mask defines the mask to be tested
  68575. * @return whether or not one observer registered with the given mask is handeled
  68576. **/
  68577. hasSpecificMask(mask?: number): boolean;
  68578. }
  68579. }
  68580. declare module BABYLON {
  68581. /**
  68582. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  68583. * Babylon.js
  68584. */
  68585. export class DomManagement {
  68586. /**
  68587. * Checks if the window object exists
  68588. * @returns true if the window object exists
  68589. */
  68590. static IsWindowObjectExist(): boolean;
  68591. /**
  68592. * Checks if the navigator object exists
  68593. * @returns true if the navigator object exists
  68594. */
  68595. static IsNavigatorAvailable(): boolean;
  68596. /**
  68597. * Extracts text content from a DOM element hierarchy
  68598. * @param element defines the root element
  68599. * @returns a string
  68600. */
  68601. static GetDOMTextContent(element: HTMLElement): string;
  68602. }
  68603. }
  68604. declare module BABYLON {
  68605. /**
  68606. * Logger used througouht the application to allow configuration of
  68607. * the log level required for the messages.
  68608. */
  68609. export class Logger {
  68610. /**
  68611. * No log
  68612. */
  68613. static readonly NoneLogLevel: number;
  68614. /**
  68615. * Only message logs
  68616. */
  68617. static readonly MessageLogLevel: number;
  68618. /**
  68619. * Only warning logs
  68620. */
  68621. static readonly WarningLogLevel: number;
  68622. /**
  68623. * Only error logs
  68624. */
  68625. static readonly ErrorLogLevel: number;
  68626. /**
  68627. * All logs
  68628. */
  68629. static readonly AllLogLevel: number;
  68630. private static _LogCache;
  68631. /**
  68632. * Gets a value indicating the number of loading errors
  68633. * @ignorenaming
  68634. */
  68635. static errorsCount: number;
  68636. /**
  68637. * Callback called when a new log is added
  68638. */
  68639. static OnNewCacheEntry: (entry: string) => void;
  68640. private static _AddLogEntry;
  68641. private static _FormatMessage;
  68642. private static _LogDisabled;
  68643. private static _LogEnabled;
  68644. private static _WarnDisabled;
  68645. private static _WarnEnabled;
  68646. private static _ErrorDisabled;
  68647. private static _ErrorEnabled;
  68648. /**
  68649. * Log a message to the console
  68650. */
  68651. static Log: (message: string) => void;
  68652. /**
  68653. * Write a warning message to the console
  68654. */
  68655. static Warn: (message: string) => void;
  68656. /**
  68657. * Write an error message to the console
  68658. */
  68659. static Error: (message: string) => void;
  68660. /**
  68661. * Gets current log cache (list of logs)
  68662. */
  68663. static readonly LogCache: string;
  68664. /**
  68665. * Clears the log cache
  68666. */
  68667. static ClearLogCache(): void;
  68668. /**
  68669. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  68670. */
  68671. static LogLevels: number;
  68672. }
  68673. }
  68674. declare module BABYLON {
  68675. /** @hidden */
  68676. export class _TypeStore {
  68677. /** @hidden */
  68678. static RegisteredTypes: {
  68679. [key: string]: Object;
  68680. };
  68681. /** @hidden */
  68682. static GetClass(fqdn: string): any;
  68683. }
  68684. }
  68685. declare module BABYLON {
  68686. /**
  68687. * Helper to manipulate strings
  68688. */
  68689. export class StringTools {
  68690. /**
  68691. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68692. * @param str Source string
  68693. * @param suffix Suffix to search for in the source string
  68694. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68695. */
  68696. static EndsWith(str: string, suffix: string): boolean;
  68697. /**
  68698. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68699. * @param str Source string
  68700. * @param suffix Suffix to search for in the source string
  68701. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68702. */
  68703. static StartsWith(str: string, suffix: string): boolean;
  68704. /**
  68705. * Decodes a buffer into a string
  68706. * @param buffer The buffer to decode
  68707. * @returns The decoded string
  68708. */
  68709. static Decode(buffer: Uint8Array | Uint16Array): string;
  68710. /**
  68711. * Encode a buffer to a base64 string
  68712. * @param buffer defines the buffer to encode
  68713. * @returns the encoded string
  68714. */
  68715. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  68716. }
  68717. }
  68718. declare module BABYLON {
  68719. /**
  68720. * Class containing a set of static utilities functions for deep copy.
  68721. */
  68722. export class DeepCopier {
  68723. /**
  68724. * Tries to copy an object by duplicating every property
  68725. * @param source defines the source object
  68726. * @param destination defines the target object
  68727. * @param doNotCopyList defines a list of properties to avoid
  68728. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  68729. */
  68730. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  68731. }
  68732. }
  68733. declare module BABYLON {
  68734. /**
  68735. * Class containing a set of static utilities functions for precision date
  68736. */
  68737. export class PrecisionDate {
  68738. /**
  68739. * Gets either window.performance.now() if supported or Date.now() else
  68740. */
  68741. static readonly Now: number;
  68742. }
  68743. }
  68744. declare module BABYLON {
  68745. /** @hidden */
  68746. export class _DevTools {
  68747. static WarnImport(name: string): string;
  68748. }
  68749. }
  68750. declare module BABYLON {
  68751. /**
  68752. * Interface used to define the mechanism to get data from the network
  68753. */
  68754. export interface IWebRequest {
  68755. /**
  68756. * Returns client's response url
  68757. */
  68758. responseURL: string;
  68759. /**
  68760. * Returns client's status
  68761. */
  68762. status: number;
  68763. /**
  68764. * Returns client's status as a text
  68765. */
  68766. statusText: string;
  68767. }
  68768. }
  68769. declare module BABYLON {
  68770. /**
  68771. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  68772. */
  68773. export class WebRequest implements IWebRequest {
  68774. private _xhr;
  68775. /**
  68776. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  68777. * i.e. when loading files, where the server/service expects an Authorization header
  68778. */
  68779. static CustomRequestHeaders: {
  68780. [key: string]: string;
  68781. };
  68782. /**
  68783. * Add callback functions in this array to update all the requests before they get sent to the network
  68784. */
  68785. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  68786. private _injectCustomRequestHeaders;
  68787. /**
  68788. * Gets or sets a function to be called when loading progress changes
  68789. */
  68790. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  68791. /**
  68792. * Returns client's state
  68793. */
  68794. readonly readyState: number;
  68795. /**
  68796. * Returns client's status
  68797. */
  68798. readonly status: number;
  68799. /**
  68800. * Returns client's status as a text
  68801. */
  68802. readonly statusText: string;
  68803. /**
  68804. * Returns client's response
  68805. */
  68806. readonly response: any;
  68807. /**
  68808. * Returns client's response url
  68809. */
  68810. readonly responseURL: string;
  68811. /**
  68812. * Returns client's response as text
  68813. */
  68814. readonly responseText: string;
  68815. /**
  68816. * Gets or sets the expected response type
  68817. */
  68818. responseType: XMLHttpRequestResponseType;
  68819. /** @hidden */
  68820. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  68821. /** @hidden */
  68822. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  68823. /**
  68824. * Cancels any network activity
  68825. */
  68826. abort(): void;
  68827. /**
  68828. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  68829. * @param body defines an optional request body
  68830. */
  68831. send(body?: Document | BodyInit | null): void;
  68832. /**
  68833. * Sets the request method, request URL
  68834. * @param method defines the method to use (GET, POST, etc..)
  68835. * @param url defines the url to connect with
  68836. */
  68837. open(method: string, url: string): void;
  68838. /**
  68839. * Sets the value of a request header.
  68840. * @param name The name of the header whose value is to be set
  68841. * @param value The value to set as the body of the header
  68842. */
  68843. setRequestHeader(name: string, value: string): void;
  68844. /**
  68845. * Get the string containing the text of a particular header's value.
  68846. * @param name The name of the header
  68847. * @returns The string containing the text of the given header name
  68848. */
  68849. getResponseHeader(name: string): Nullable<string>;
  68850. }
  68851. }
  68852. declare module BABYLON {
  68853. /**
  68854. * File request interface
  68855. */
  68856. export interface IFileRequest {
  68857. /**
  68858. * Raised when the request is complete (success or error).
  68859. */
  68860. onCompleteObservable: Observable<IFileRequest>;
  68861. /**
  68862. * Aborts the request for a file.
  68863. */
  68864. abort: () => void;
  68865. }
  68866. }
  68867. declare module BABYLON {
  68868. /**
  68869. * Define options used to create a render target texture
  68870. */
  68871. export class RenderTargetCreationOptions {
  68872. /**
  68873. * Specifies is mipmaps must be generated
  68874. */
  68875. generateMipMaps?: boolean;
  68876. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68877. generateDepthBuffer?: boolean;
  68878. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68879. generateStencilBuffer?: boolean;
  68880. /** Defines texture type (int by default) */
  68881. type?: number;
  68882. /** Defines sampling mode (trilinear by default) */
  68883. samplingMode?: number;
  68884. /** Defines format (RGBA by default) */
  68885. format?: number;
  68886. }
  68887. }
  68888. declare module BABYLON {
  68889. /**
  68890. * @hidden
  68891. **/
  68892. export class _TimeToken {
  68893. _startTimeQuery: Nullable<WebGLQuery>;
  68894. _endTimeQuery: Nullable<WebGLQuery>;
  68895. _timeElapsedQuery: Nullable<WebGLQuery>;
  68896. _timeElapsedQueryEnded: boolean;
  68897. }
  68898. }
  68899. declare module BABYLON {
  68900. /** Defines the cross module used constants to avoid circular dependncies */
  68901. export class Constants {
  68902. /** Defines that alpha blending is disabled */
  68903. static readonly ALPHA_DISABLE: number;
  68904. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68905. static readonly ALPHA_ADD: number;
  68906. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68907. static readonly ALPHA_COMBINE: number;
  68908. /** Defines that alpha blending to DEST - SRC * DEST */
  68909. static readonly ALPHA_SUBTRACT: number;
  68910. /** Defines that alpha blending to SRC * DEST */
  68911. static readonly ALPHA_MULTIPLY: number;
  68912. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68913. static readonly ALPHA_MAXIMIZED: number;
  68914. /** Defines that alpha blending to SRC + DEST */
  68915. static readonly ALPHA_ONEONE: number;
  68916. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68917. static readonly ALPHA_PREMULTIPLIED: number;
  68918. /**
  68919. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68920. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68921. */
  68922. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68923. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68924. static readonly ALPHA_INTERPOLATE: number;
  68925. /**
  68926. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68927. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68928. */
  68929. static readonly ALPHA_SCREENMODE: number;
  68930. /**
  68931. * Defines that alpha blending to SRC + DST
  68932. * Alpha will be set to SRC ALPHA + DST ALPHA
  68933. */
  68934. static readonly ALPHA_ONEONE_ONEONE: number;
  68935. /**
  68936. * Defines that alpha blending to SRC * DST ALPHA + DST
  68937. * Alpha will be set to 0
  68938. */
  68939. static readonly ALPHA_ALPHATOCOLOR: number;
  68940. /**
  68941. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  68942. */
  68943. static readonly ALPHA_REVERSEONEMINUS: number;
  68944. /**
  68945. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  68946. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  68947. */
  68948. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  68949. /**
  68950. * Defines that alpha blending to SRC + DST
  68951. * Alpha will be set to SRC ALPHA
  68952. */
  68953. static readonly ALPHA_ONEONE_ONEZERO: number;
  68954. /** Defines that alpha blending equation a SUM */
  68955. static readonly ALPHA_EQUATION_ADD: number;
  68956. /** Defines that alpha blending equation a SUBSTRACTION */
  68957. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  68958. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  68959. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  68960. /** Defines that alpha blending equation a MAX operation */
  68961. static readonly ALPHA_EQUATION_MAX: number;
  68962. /** Defines that alpha blending equation a MIN operation */
  68963. static readonly ALPHA_EQUATION_MIN: number;
  68964. /**
  68965. * Defines that alpha blending equation a DARKEN operation:
  68966. * It takes the min of the src and sums the alpha channels.
  68967. */
  68968. static readonly ALPHA_EQUATION_DARKEN: number;
  68969. /** Defines that the ressource is not delayed*/
  68970. static readonly DELAYLOADSTATE_NONE: number;
  68971. /** Defines that the ressource was successfully delay loaded */
  68972. static readonly DELAYLOADSTATE_LOADED: number;
  68973. /** Defines that the ressource is currently delay loading */
  68974. static readonly DELAYLOADSTATE_LOADING: number;
  68975. /** Defines that the ressource is delayed and has not started loading */
  68976. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68977. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68978. static readonly NEVER: number;
  68979. /** 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 */
  68980. static readonly ALWAYS: number;
  68981. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68982. static readonly LESS: number;
  68983. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68984. static readonly EQUAL: number;
  68985. /** 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 */
  68986. static readonly LEQUAL: number;
  68987. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68988. static readonly GREATER: number;
  68989. /** 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 */
  68990. static readonly GEQUAL: number;
  68991. /** 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 */
  68992. static readonly NOTEQUAL: number;
  68993. /** Passed to stencilOperation to specify that stencil value must be kept */
  68994. static readonly KEEP: number;
  68995. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68996. static readonly REPLACE: number;
  68997. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68998. static readonly INCR: number;
  68999. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69000. static readonly DECR: number;
  69001. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69002. static readonly INVERT: number;
  69003. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69004. static readonly INCR_WRAP: number;
  69005. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69006. static readonly DECR_WRAP: number;
  69007. /** Texture is not repeating outside of 0..1 UVs */
  69008. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69009. /** Texture is repeating outside of 0..1 UVs */
  69010. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69011. /** Texture is repeating and mirrored */
  69012. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69013. /** ALPHA */
  69014. static readonly TEXTUREFORMAT_ALPHA: number;
  69015. /** LUMINANCE */
  69016. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69017. /** LUMINANCE_ALPHA */
  69018. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69019. /** RGB */
  69020. static readonly TEXTUREFORMAT_RGB: number;
  69021. /** RGBA */
  69022. static readonly TEXTUREFORMAT_RGBA: number;
  69023. /** RED */
  69024. static readonly TEXTUREFORMAT_RED: number;
  69025. /** RED (2nd reference) */
  69026. static readonly TEXTUREFORMAT_R: number;
  69027. /** RG */
  69028. static readonly TEXTUREFORMAT_RG: number;
  69029. /** RED_INTEGER */
  69030. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69031. /** RED_INTEGER (2nd reference) */
  69032. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69033. /** RG_INTEGER */
  69034. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69035. /** RGB_INTEGER */
  69036. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69037. /** RGBA_INTEGER */
  69038. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69039. /** UNSIGNED_BYTE */
  69040. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69041. /** UNSIGNED_BYTE (2nd reference) */
  69042. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69043. /** FLOAT */
  69044. static readonly TEXTURETYPE_FLOAT: number;
  69045. /** HALF_FLOAT */
  69046. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69047. /** BYTE */
  69048. static readonly TEXTURETYPE_BYTE: number;
  69049. /** SHORT */
  69050. static readonly TEXTURETYPE_SHORT: number;
  69051. /** UNSIGNED_SHORT */
  69052. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69053. /** INT */
  69054. static readonly TEXTURETYPE_INT: number;
  69055. /** UNSIGNED_INT */
  69056. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69057. /** UNSIGNED_SHORT_4_4_4_4 */
  69058. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69059. /** UNSIGNED_SHORT_5_5_5_1 */
  69060. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69061. /** UNSIGNED_SHORT_5_6_5 */
  69062. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69063. /** UNSIGNED_INT_2_10_10_10_REV */
  69064. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69065. /** UNSIGNED_INT_24_8 */
  69066. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69067. /** UNSIGNED_INT_10F_11F_11F_REV */
  69068. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69069. /** UNSIGNED_INT_5_9_9_9_REV */
  69070. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69071. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69072. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69073. /** nearest is mag = nearest and min = nearest and mip = nearest */
  69074. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69075. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69076. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69077. /** Trilinear is mag = linear and min = linear and mip = linear */
  69078. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69079. /** nearest is mag = nearest and min = nearest and mip = linear */
  69080. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69081. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69082. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69083. /** Trilinear is mag = linear and min = linear and mip = linear */
  69084. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69085. /** mag = nearest and min = nearest and mip = nearest */
  69086. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  69087. /** mag = nearest and min = linear and mip = nearest */
  69088. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  69089. /** mag = nearest and min = linear and mip = linear */
  69090. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  69091. /** mag = nearest and min = linear and mip = none */
  69092. static readonly TEXTURE_NEAREST_LINEAR: number;
  69093. /** mag = nearest and min = nearest and mip = none */
  69094. static readonly TEXTURE_NEAREST_NEAREST: number;
  69095. /** mag = linear and min = nearest and mip = nearest */
  69096. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  69097. /** mag = linear and min = nearest and mip = linear */
  69098. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  69099. /** mag = linear and min = linear and mip = none */
  69100. static readonly TEXTURE_LINEAR_LINEAR: number;
  69101. /** mag = linear and min = nearest and mip = none */
  69102. static readonly TEXTURE_LINEAR_NEAREST: number;
  69103. /** Explicit coordinates mode */
  69104. static readonly TEXTURE_EXPLICIT_MODE: number;
  69105. /** Spherical coordinates mode */
  69106. static readonly TEXTURE_SPHERICAL_MODE: number;
  69107. /** Planar coordinates mode */
  69108. static readonly TEXTURE_PLANAR_MODE: number;
  69109. /** Cubic coordinates mode */
  69110. static readonly TEXTURE_CUBIC_MODE: number;
  69111. /** Projection coordinates mode */
  69112. static readonly TEXTURE_PROJECTION_MODE: number;
  69113. /** Skybox coordinates mode */
  69114. static readonly TEXTURE_SKYBOX_MODE: number;
  69115. /** Inverse Cubic coordinates mode */
  69116. static readonly TEXTURE_INVCUBIC_MODE: number;
  69117. /** Equirectangular coordinates mode */
  69118. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  69119. /** Equirectangular Fixed coordinates mode */
  69120. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  69121. /** Equirectangular Fixed Mirrored coordinates mode */
  69122. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  69123. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  69124. static readonly SCALEMODE_FLOOR: number;
  69125. /** Defines that texture rescaling will look for the nearest power of 2 size */
  69126. static readonly SCALEMODE_NEAREST: number;
  69127. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  69128. static readonly SCALEMODE_CEILING: number;
  69129. /**
  69130. * The dirty texture flag value
  69131. */
  69132. static readonly MATERIAL_TextureDirtyFlag: number;
  69133. /**
  69134. * The dirty light flag value
  69135. */
  69136. static readonly MATERIAL_LightDirtyFlag: number;
  69137. /**
  69138. * The dirty fresnel flag value
  69139. */
  69140. static readonly MATERIAL_FresnelDirtyFlag: number;
  69141. /**
  69142. * The dirty attribute flag value
  69143. */
  69144. static readonly MATERIAL_AttributesDirtyFlag: number;
  69145. /**
  69146. * The dirty misc flag value
  69147. */
  69148. static readonly MATERIAL_MiscDirtyFlag: number;
  69149. /**
  69150. * The all dirty flag value
  69151. */
  69152. static readonly MATERIAL_AllDirtyFlag: number;
  69153. /**
  69154. * Returns the triangle fill mode
  69155. */
  69156. static readonly MATERIAL_TriangleFillMode: number;
  69157. /**
  69158. * Returns the wireframe mode
  69159. */
  69160. static readonly MATERIAL_WireFrameFillMode: number;
  69161. /**
  69162. * Returns the point fill mode
  69163. */
  69164. static readonly MATERIAL_PointFillMode: number;
  69165. /**
  69166. * Returns the point list draw mode
  69167. */
  69168. static readonly MATERIAL_PointListDrawMode: number;
  69169. /**
  69170. * Returns the line list draw mode
  69171. */
  69172. static readonly MATERIAL_LineListDrawMode: number;
  69173. /**
  69174. * Returns the line loop draw mode
  69175. */
  69176. static readonly MATERIAL_LineLoopDrawMode: number;
  69177. /**
  69178. * Returns the line strip draw mode
  69179. */
  69180. static readonly MATERIAL_LineStripDrawMode: number;
  69181. /**
  69182. * Returns the triangle strip draw mode
  69183. */
  69184. static readonly MATERIAL_TriangleStripDrawMode: number;
  69185. /**
  69186. * Returns the triangle fan draw mode
  69187. */
  69188. static readonly MATERIAL_TriangleFanDrawMode: number;
  69189. /**
  69190. * Stores the clock-wise side orientation
  69191. */
  69192. static readonly MATERIAL_ClockWiseSideOrientation: number;
  69193. /**
  69194. * Stores the counter clock-wise side orientation
  69195. */
  69196. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  69197. /**
  69198. * Nothing
  69199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69200. */
  69201. static readonly ACTION_NothingTrigger: number;
  69202. /**
  69203. * On pick
  69204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69205. */
  69206. static readonly ACTION_OnPickTrigger: number;
  69207. /**
  69208. * On left pick
  69209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69210. */
  69211. static readonly ACTION_OnLeftPickTrigger: number;
  69212. /**
  69213. * On right pick
  69214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69215. */
  69216. static readonly ACTION_OnRightPickTrigger: number;
  69217. /**
  69218. * On center pick
  69219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69220. */
  69221. static readonly ACTION_OnCenterPickTrigger: number;
  69222. /**
  69223. * On pick down
  69224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69225. */
  69226. static readonly ACTION_OnPickDownTrigger: number;
  69227. /**
  69228. * On double pick
  69229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69230. */
  69231. static readonly ACTION_OnDoublePickTrigger: number;
  69232. /**
  69233. * On pick up
  69234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69235. */
  69236. static readonly ACTION_OnPickUpTrigger: number;
  69237. /**
  69238. * On pick out.
  69239. * This trigger will only be raised if you also declared a OnPickDown
  69240. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69241. */
  69242. static readonly ACTION_OnPickOutTrigger: number;
  69243. /**
  69244. * On long press
  69245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69246. */
  69247. static readonly ACTION_OnLongPressTrigger: number;
  69248. /**
  69249. * On pointer over
  69250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69251. */
  69252. static readonly ACTION_OnPointerOverTrigger: number;
  69253. /**
  69254. * On pointer out
  69255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69256. */
  69257. static readonly ACTION_OnPointerOutTrigger: number;
  69258. /**
  69259. * On every frame
  69260. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69261. */
  69262. static readonly ACTION_OnEveryFrameTrigger: number;
  69263. /**
  69264. * On intersection enter
  69265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69266. */
  69267. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69268. /**
  69269. * On intersection exit
  69270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69271. */
  69272. static readonly ACTION_OnIntersectionExitTrigger: number;
  69273. /**
  69274. * On key down
  69275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69276. */
  69277. static readonly ACTION_OnKeyDownTrigger: number;
  69278. /**
  69279. * On key up
  69280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69281. */
  69282. static readonly ACTION_OnKeyUpTrigger: number;
  69283. /**
  69284. * Billboard mode will only apply to Y axis
  69285. */
  69286. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69287. /**
  69288. * Billboard mode will apply to all axes
  69289. */
  69290. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69291. /**
  69292. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69293. */
  69294. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69295. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69296. * Test order :
  69297. * Is the bounding sphere outside the frustum ?
  69298. * If not, are the bounding box vertices outside the frustum ?
  69299. * It not, then the cullable object is in the frustum.
  69300. */
  69301. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69302. /** Culling strategy : Bounding Sphere Only.
  69303. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69304. * It's also less accurate than the standard because some not visible objects can still be selected.
  69305. * Test : is the bounding sphere outside the frustum ?
  69306. * If not, then the cullable object is in the frustum.
  69307. */
  69308. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69309. /** Culling strategy : Optimistic Inclusion.
  69310. * This in an inclusion test first, then the standard exclusion test.
  69311. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69312. * 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.
  69313. * Anyway, it's as accurate as the standard strategy.
  69314. * Test :
  69315. * Is the cullable object bounding sphere center in the frustum ?
  69316. * If not, apply the default culling strategy.
  69317. */
  69318. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69319. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69320. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69321. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69322. * 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.
  69323. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69324. * Test :
  69325. * Is the cullable object bounding sphere center in the frustum ?
  69326. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69327. */
  69328. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69329. /**
  69330. * No logging while loading
  69331. */
  69332. static readonly SCENELOADER_NO_LOGGING: number;
  69333. /**
  69334. * Minimal logging while loading
  69335. */
  69336. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69337. /**
  69338. * Summary logging while loading
  69339. */
  69340. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69341. /**
  69342. * Detailled logging while loading
  69343. */
  69344. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69345. }
  69346. }
  69347. declare module BABYLON {
  69348. /**
  69349. * This represents the required contract to create a new type of texture loader.
  69350. */
  69351. export interface IInternalTextureLoader {
  69352. /**
  69353. * Defines wether the loader supports cascade loading the different faces.
  69354. */
  69355. supportCascades: boolean;
  69356. /**
  69357. * This returns if the loader support the current file information.
  69358. * @param extension defines the file extension of the file being loaded
  69359. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69360. * @param fallback defines the fallback internal texture if any
  69361. * @param isBase64 defines whether the texture is encoded as a base64
  69362. * @param isBuffer defines whether the texture data are stored as a buffer
  69363. * @returns true if the loader can load the specified file
  69364. */
  69365. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  69366. /**
  69367. * Transform the url before loading if required.
  69368. * @param rootUrl the url of the texture
  69369. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69370. * @returns the transformed texture
  69371. */
  69372. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  69373. /**
  69374. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  69375. * @param rootUrl the url of the texture
  69376. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69377. * @returns the fallback texture
  69378. */
  69379. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  69380. /**
  69381. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  69382. * @param data contains the texture data
  69383. * @param texture defines the BabylonJS internal texture
  69384. * @param createPolynomials will be true if polynomials have been requested
  69385. * @param onLoad defines the callback to trigger once the texture is ready
  69386. * @param onError defines the callback to trigger in case of error
  69387. */
  69388. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69389. /**
  69390. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  69391. * @param data contains the texture data
  69392. * @param texture defines the BabylonJS internal texture
  69393. * @param callback defines the method to call once ready to upload
  69394. */
  69395. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  69396. }
  69397. }
  69398. declare module BABYLON {
  69399. /**
  69400. * Class used to store and describe the pipeline context associated with an effect
  69401. */
  69402. export interface IPipelineContext {
  69403. /**
  69404. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  69405. */
  69406. isAsync: boolean;
  69407. /**
  69408. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  69409. */
  69410. isReady: boolean;
  69411. /** @hidden */
  69412. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  69413. }
  69414. }
  69415. declare module BABYLON {
  69416. /**
  69417. * Class used to store gfx data (like WebGLBuffer)
  69418. */
  69419. export class DataBuffer {
  69420. /**
  69421. * Gets or sets the number of objects referencing this buffer
  69422. */
  69423. references: number;
  69424. /** Gets or sets the size of the underlying buffer */
  69425. capacity: number;
  69426. /**
  69427. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  69428. */
  69429. is32Bits: boolean;
  69430. /**
  69431. * Gets the underlying buffer
  69432. */
  69433. readonly underlyingResource: any;
  69434. }
  69435. }
  69436. declare module BABYLON {
  69437. /** @hidden */
  69438. export interface IShaderProcessor {
  69439. attributeProcessor?: (attribute: string) => string;
  69440. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  69441. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  69442. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  69443. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  69444. lineProcessor?: (line: string, isFragment: boolean) => string;
  69445. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69446. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69447. }
  69448. }
  69449. declare module BABYLON {
  69450. /** @hidden */
  69451. export interface ProcessingOptions {
  69452. defines: string[];
  69453. indexParameters: any;
  69454. isFragment: boolean;
  69455. shouldUseHighPrecisionShader: boolean;
  69456. supportsUniformBuffers: boolean;
  69457. shadersRepository: string;
  69458. includesShadersStore: {
  69459. [key: string]: string;
  69460. };
  69461. processor?: IShaderProcessor;
  69462. version: string;
  69463. platformName: string;
  69464. lookForClosingBracketForUniformBuffer?: boolean;
  69465. }
  69466. }
  69467. declare module BABYLON {
  69468. /** @hidden */
  69469. export class ShaderCodeNode {
  69470. line: string;
  69471. children: ShaderCodeNode[];
  69472. additionalDefineKey?: string;
  69473. additionalDefineValue?: string;
  69474. isValid(preprocessors: {
  69475. [key: string]: string;
  69476. }): boolean;
  69477. process(preprocessors: {
  69478. [key: string]: string;
  69479. }, options: ProcessingOptions): string;
  69480. }
  69481. }
  69482. declare module BABYLON {
  69483. /** @hidden */
  69484. export class ShaderCodeCursor {
  69485. private _lines;
  69486. lineIndex: number;
  69487. readonly currentLine: string;
  69488. readonly canRead: boolean;
  69489. lines: string[];
  69490. }
  69491. }
  69492. declare module BABYLON {
  69493. /** @hidden */
  69494. export class ShaderCodeConditionNode extends ShaderCodeNode {
  69495. process(preprocessors: {
  69496. [key: string]: string;
  69497. }, options: ProcessingOptions): string;
  69498. }
  69499. }
  69500. declare module BABYLON {
  69501. /** @hidden */
  69502. export class ShaderDefineExpression {
  69503. isTrue(preprocessors: {
  69504. [key: string]: string;
  69505. }): boolean;
  69506. }
  69507. }
  69508. declare module BABYLON {
  69509. /** @hidden */
  69510. export class ShaderCodeTestNode extends ShaderCodeNode {
  69511. testExpression: ShaderDefineExpression;
  69512. isValid(preprocessors: {
  69513. [key: string]: string;
  69514. }): boolean;
  69515. }
  69516. }
  69517. declare module BABYLON {
  69518. /** @hidden */
  69519. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  69520. define: string;
  69521. not: boolean;
  69522. constructor(define: string, not?: boolean);
  69523. isTrue(preprocessors: {
  69524. [key: string]: string;
  69525. }): boolean;
  69526. }
  69527. }
  69528. declare module BABYLON {
  69529. /** @hidden */
  69530. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  69531. leftOperand: ShaderDefineExpression;
  69532. rightOperand: ShaderDefineExpression;
  69533. isTrue(preprocessors: {
  69534. [key: string]: string;
  69535. }): boolean;
  69536. }
  69537. }
  69538. declare module BABYLON {
  69539. /** @hidden */
  69540. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  69541. leftOperand: ShaderDefineExpression;
  69542. rightOperand: ShaderDefineExpression;
  69543. isTrue(preprocessors: {
  69544. [key: string]: string;
  69545. }): boolean;
  69546. }
  69547. }
  69548. declare module BABYLON {
  69549. /** @hidden */
  69550. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  69551. define: string;
  69552. operand: string;
  69553. testValue: string;
  69554. constructor(define: string, operand: string, testValue: string);
  69555. isTrue(preprocessors: {
  69556. [key: string]: string;
  69557. }): boolean;
  69558. }
  69559. }
  69560. declare module BABYLON {
  69561. /**
  69562. * Class used to enable access to offline support
  69563. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69564. */
  69565. export interface IOfflineProvider {
  69566. /**
  69567. * Gets a boolean indicating if scene must be saved in the database
  69568. */
  69569. enableSceneOffline: boolean;
  69570. /**
  69571. * Gets a boolean indicating if textures must be saved in the database
  69572. */
  69573. enableTexturesOffline: boolean;
  69574. /**
  69575. * Open the offline support and make it available
  69576. * @param successCallback defines the callback to call on success
  69577. * @param errorCallback defines the callback to call on error
  69578. */
  69579. open(successCallback: () => void, errorCallback: () => void): void;
  69580. /**
  69581. * Loads an image from the offline support
  69582. * @param url defines the url to load from
  69583. * @param image defines the target DOM image
  69584. */
  69585. loadImage(url: string, image: HTMLImageElement): void;
  69586. /**
  69587. * Loads a file from offline support
  69588. * @param url defines the URL to load from
  69589. * @param sceneLoaded defines a callback to call on success
  69590. * @param progressCallBack defines a callback to call when progress changed
  69591. * @param errorCallback defines a callback to call on error
  69592. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69593. */
  69594. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69595. }
  69596. }
  69597. declare module BABYLON {
  69598. /**
  69599. * Class used to help managing file picking and drag'n'drop
  69600. * File Storage
  69601. */
  69602. export class FilesInputStore {
  69603. /**
  69604. * List of files ready to be loaded
  69605. */
  69606. static FilesToLoad: {
  69607. [key: string]: File;
  69608. };
  69609. }
  69610. }
  69611. declare module BABYLON {
  69612. /**
  69613. * Class used to define a retry strategy when error happens while loading assets
  69614. */
  69615. export class RetryStrategy {
  69616. /**
  69617. * Function used to defines an exponential back off strategy
  69618. * @param maxRetries defines the maximum number of retries (3 by default)
  69619. * @param baseInterval defines the interval between retries
  69620. * @returns the strategy function to use
  69621. */
  69622. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  69623. }
  69624. }
  69625. declare module BABYLON {
  69626. /**
  69627. * @ignore
  69628. * Application error to support additional information when loading a file
  69629. */
  69630. export abstract class BaseError extends Error {
  69631. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  69632. }
  69633. }
  69634. declare module BABYLON {
  69635. /** @ignore */
  69636. export class LoadFileError extends BaseError {
  69637. request?: WebRequest;
  69638. file?: File;
  69639. /**
  69640. * Creates a new LoadFileError
  69641. * @param message defines the message of the error
  69642. * @param request defines the optional web request
  69643. * @param file defines the optional file
  69644. */
  69645. constructor(message: string, object?: WebRequest | File);
  69646. }
  69647. /** @ignore */
  69648. export class RequestFileError extends BaseError {
  69649. request: WebRequest;
  69650. /**
  69651. * Creates a new LoadFileError
  69652. * @param message defines the message of the error
  69653. * @param request defines the optional web request
  69654. */
  69655. constructor(message: string, request: WebRequest);
  69656. }
  69657. /** @ignore */
  69658. export class ReadFileError extends BaseError {
  69659. file: File;
  69660. /**
  69661. * Creates a new ReadFileError
  69662. * @param message defines the message of the error
  69663. * @param file defines the optional file
  69664. */
  69665. constructor(message: string, file: File);
  69666. }
  69667. /**
  69668. * @hidden
  69669. */
  69670. export class FileTools {
  69671. /**
  69672. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  69673. */
  69674. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  69675. /**
  69676. * Gets or sets the base URL to use to load assets
  69677. */
  69678. static BaseUrl: string;
  69679. /**
  69680. * Default behaviour for cors in the application.
  69681. * It can be a string if the expected behavior is identical in the entire app.
  69682. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  69683. */
  69684. static CorsBehavior: string | ((url: string | string[]) => string);
  69685. /**
  69686. * Gets or sets a function used to pre-process url before using them to load assets
  69687. */
  69688. static PreprocessUrl: (url: string) => string;
  69689. /**
  69690. * Removes unwanted characters from an url
  69691. * @param url defines the url to clean
  69692. * @returns the cleaned url
  69693. */
  69694. private static _CleanUrl;
  69695. /**
  69696. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  69697. * @param url define the url we are trying
  69698. * @param element define the dom element where to configure the cors policy
  69699. */
  69700. static SetCorsBehavior(url: string | string[], element: {
  69701. crossOrigin: string | null;
  69702. }): void;
  69703. /**
  69704. * Loads an image as an HTMLImageElement.
  69705. * @param input url string, ArrayBuffer, or Blob to load
  69706. * @param onLoad callback called when the image successfully loads
  69707. * @param onError callback called when the image fails to load
  69708. * @param offlineProvider offline provider for caching
  69709. * @param mimeType optional mime type
  69710. * @returns the HTMLImageElement of the loaded image
  69711. */
  69712. 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>;
  69713. /**
  69714. * Reads a file from a File object
  69715. * @param file defines the file to load
  69716. * @param onSuccess defines the callback to call when data is loaded
  69717. * @param onProgress defines the callback to call during loading process
  69718. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  69719. * @param onError defines the callback to call when an error occurs
  69720. * @returns a file request object
  69721. */
  69722. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  69723. /**
  69724. * Loads a file from a url
  69725. * @param url url to load
  69726. * @param onSuccess callback called when the file successfully loads
  69727. * @param onProgress callback called while file is loading (if the server supports this mode)
  69728. * @param offlineProvider defines the offline provider for caching
  69729. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69730. * @param onError callback called when the file fails to load
  69731. * @returns a file request object
  69732. */
  69733. 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;
  69734. /**
  69735. * Loads a file
  69736. * @param url url to load
  69737. * @param onSuccess callback called when the file successfully loads
  69738. * @param onProgress callback called while file is loading (if the server supports this mode)
  69739. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69740. * @param onError callback called when the file fails to load
  69741. * @param onOpened callback called when the web request is opened
  69742. * @returns a file request object
  69743. */
  69744. 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;
  69745. /**
  69746. * Checks if the loaded document was accessed via `file:`-Protocol.
  69747. * @returns boolean
  69748. */
  69749. static IsFileURL(): boolean;
  69750. }
  69751. }
  69752. declare module BABYLON {
  69753. /** @hidden */
  69754. export class ShaderProcessor {
  69755. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  69756. private static _ProcessPrecision;
  69757. private static _ExtractOperation;
  69758. private static _BuildSubExpression;
  69759. private static _BuildExpression;
  69760. private static _MoveCursorWithinIf;
  69761. private static _MoveCursor;
  69762. private static _EvaluatePreProcessors;
  69763. private static _PreparePreProcessors;
  69764. private static _ProcessShaderConversion;
  69765. private static _ProcessIncludes;
  69766. }
  69767. }
  69768. declare module BABYLON {
  69769. /**
  69770. * @hidden
  69771. */
  69772. export interface IColor4Like {
  69773. r: float;
  69774. g: float;
  69775. b: float;
  69776. a: float;
  69777. }
  69778. /**
  69779. * @hidden
  69780. */
  69781. export interface IColor3Like {
  69782. r: float;
  69783. g: float;
  69784. b: float;
  69785. }
  69786. /**
  69787. * @hidden
  69788. */
  69789. export interface IVector4Like {
  69790. x: float;
  69791. y: float;
  69792. z: float;
  69793. w: float;
  69794. }
  69795. /**
  69796. * @hidden
  69797. */
  69798. export interface IVector3Like {
  69799. x: float;
  69800. y: float;
  69801. z: float;
  69802. }
  69803. /**
  69804. * @hidden
  69805. */
  69806. export interface IVector2Like {
  69807. x: float;
  69808. y: float;
  69809. }
  69810. /**
  69811. * @hidden
  69812. */
  69813. export interface IMatrixLike {
  69814. toArray(): DeepImmutable<Float32Array>;
  69815. updateFlag: int;
  69816. }
  69817. /**
  69818. * @hidden
  69819. */
  69820. export interface IViewportLike {
  69821. x: float;
  69822. y: float;
  69823. width: float;
  69824. height: float;
  69825. }
  69826. /**
  69827. * @hidden
  69828. */
  69829. export interface IPlaneLike {
  69830. normal: IVector3Like;
  69831. d: float;
  69832. normalize(): void;
  69833. }
  69834. }
  69835. declare module BABYLON {
  69836. /**
  69837. * Interface used to define common properties for effect fallbacks
  69838. */
  69839. export interface IEffectFallbacks {
  69840. /**
  69841. * Removes the defines that should be removed when falling back.
  69842. * @param currentDefines defines the current define statements for the shader.
  69843. * @param effect defines the current effect we try to compile
  69844. * @returns The resulting defines with defines of the current rank removed.
  69845. */
  69846. reduce(currentDefines: string, effect: Effect): string;
  69847. /**
  69848. * Removes the fallback from the bound mesh.
  69849. */
  69850. unBindMesh(): void;
  69851. /**
  69852. * Checks to see if more fallbacks are still availible.
  69853. */
  69854. hasMoreFallbacks: boolean;
  69855. }
  69856. }
  69857. declare module BABYLON {
  69858. /**
  69859. * Class used to evalaute queries containing `and` and `or` operators
  69860. */
  69861. export class AndOrNotEvaluator {
  69862. /**
  69863. * Evaluate a query
  69864. * @param query defines the query to evaluate
  69865. * @param evaluateCallback defines the callback used to filter result
  69866. * @returns true if the query matches
  69867. */
  69868. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69869. private static _HandleParenthesisContent;
  69870. private static _SimplifyNegation;
  69871. }
  69872. }
  69873. declare module BABYLON {
  69874. /**
  69875. * Class used to store custom tags
  69876. */
  69877. export class Tags {
  69878. /**
  69879. * Adds support for tags on the given object
  69880. * @param obj defines the object to use
  69881. */
  69882. static EnableFor(obj: any): void;
  69883. /**
  69884. * Removes tags support
  69885. * @param obj defines the object to use
  69886. */
  69887. static DisableFor(obj: any): void;
  69888. /**
  69889. * Gets a boolean indicating if the given object has tags
  69890. * @param obj defines the object to use
  69891. * @returns a boolean
  69892. */
  69893. static HasTags(obj: any): boolean;
  69894. /**
  69895. * Gets the tags available on a given object
  69896. * @param obj defines the object to use
  69897. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69898. * @returns the tags
  69899. */
  69900. static GetTags(obj: any, asString?: boolean): any;
  69901. /**
  69902. * Adds tags to an object
  69903. * @param obj defines the object to use
  69904. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69905. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69906. */
  69907. static AddTagsTo(obj: any, tagsString: string): void;
  69908. /**
  69909. * @hidden
  69910. */
  69911. static _AddTagTo(obj: any, tag: string): void;
  69912. /**
  69913. * Removes specific tags from a specific object
  69914. * @param obj defines the object to use
  69915. * @param tagsString defines the tags to remove
  69916. */
  69917. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69918. /**
  69919. * @hidden
  69920. */
  69921. static _RemoveTagFrom(obj: any, tag: string): void;
  69922. /**
  69923. * Defines if tags hosted on an object match a given query
  69924. * @param obj defines the object to use
  69925. * @param tagsQuery defines the tag query
  69926. * @returns a boolean
  69927. */
  69928. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69929. }
  69930. }
  69931. declare module BABYLON {
  69932. /**
  69933. * Scalar computation library
  69934. */
  69935. export class Scalar {
  69936. /**
  69937. * Two pi constants convenient for computation.
  69938. */
  69939. static TwoPi: number;
  69940. /**
  69941. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69942. * @param a number
  69943. * @param b number
  69944. * @param epsilon (default = 1.401298E-45)
  69945. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69946. */
  69947. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  69948. /**
  69949. * Returns a string : the upper case translation of the number i to hexadecimal.
  69950. * @param i number
  69951. * @returns the upper case translation of the number i to hexadecimal.
  69952. */
  69953. static ToHex(i: number): string;
  69954. /**
  69955. * Returns -1 if value is negative and +1 is value is positive.
  69956. * @param value the value
  69957. * @returns the value itself if it's equal to zero.
  69958. */
  69959. static Sign(value: number): number;
  69960. /**
  69961. * Returns the value itself if it's between min and max.
  69962. * Returns min if the value is lower than min.
  69963. * Returns max if the value is greater than max.
  69964. * @param value the value to clmap
  69965. * @param min the min value to clamp to (default: 0)
  69966. * @param max the max value to clamp to (default: 1)
  69967. * @returns the clamped value
  69968. */
  69969. static Clamp(value: number, min?: number, max?: number): number;
  69970. /**
  69971. * the log2 of value.
  69972. * @param value the value to compute log2 of
  69973. * @returns the log2 of value.
  69974. */
  69975. static Log2(value: number): number;
  69976. /**
  69977. * Loops the value, so that it is never larger than length and never smaller than 0.
  69978. *
  69979. * This is similar to the modulo operator but it works with floating point numbers.
  69980. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  69981. * With t = 5 and length = 2.5, the result would be 0.0.
  69982. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  69983. * @param value the value
  69984. * @param length the length
  69985. * @returns the looped value
  69986. */
  69987. static Repeat(value: number, length: number): number;
  69988. /**
  69989. * Normalize the value between 0.0 and 1.0 using min and max values
  69990. * @param value value to normalize
  69991. * @param min max to normalize between
  69992. * @param max min to normalize between
  69993. * @returns the normalized value
  69994. */
  69995. static Normalize(value: number, min: number, max: number): number;
  69996. /**
  69997. * Denormalize the value from 0.0 and 1.0 using min and max values
  69998. * @param normalized value to denormalize
  69999. * @param min max to denormalize between
  70000. * @param max min to denormalize between
  70001. * @returns the denormalized value
  70002. */
  70003. static Denormalize(normalized: number, min: number, max: number): number;
  70004. /**
  70005. * Calculates the shortest difference between two given angles given in degrees.
  70006. * @param current current angle in degrees
  70007. * @param target target angle in degrees
  70008. * @returns the delta
  70009. */
  70010. static DeltaAngle(current: number, target: number): number;
  70011. /**
  70012. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  70013. * @param tx value
  70014. * @param length length
  70015. * @returns The returned value will move back and forth between 0 and length
  70016. */
  70017. static PingPong(tx: number, length: number): number;
  70018. /**
  70019. * Interpolates between min and max with smoothing at the limits.
  70020. *
  70021. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  70022. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  70023. * @param from from
  70024. * @param to to
  70025. * @param tx value
  70026. * @returns the smooth stepped value
  70027. */
  70028. static SmoothStep(from: number, to: number, tx: number): number;
  70029. /**
  70030. * Moves a value current towards target.
  70031. *
  70032. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  70033. * Negative values of maxDelta pushes the value away from target.
  70034. * @param current current value
  70035. * @param target target value
  70036. * @param maxDelta max distance to move
  70037. * @returns resulting value
  70038. */
  70039. static MoveTowards(current: number, target: number, maxDelta: number): number;
  70040. /**
  70041. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70042. *
  70043. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  70044. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  70045. * @param current current value
  70046. * @param target target value
  70047. * @param maxDelta max distance to move
  70048. * @returns resulting angle
  70049. */
  70050. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  70051. /**
  70052. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  70053. * @param start start value
  70054. * @param end target value
  70055. * @param amount amount to lerp between
  70056. * @returns the lerped value
  70057. */
  70058. static Lerp(start: number, end: number, amount: number): number;
  70059. /**
  70060. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70061. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  70062. * @param start start value
  70063. * @param end target value
  70064. * @param amount amount to lerp between
  70065. * @returns the lerped value
  70066. */
  70067. static LerpAngle(start: number, end: number, amount: number): number;
  70068. /**
  70069. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  70070. * @param a start value
  70071. * @param b target value
  70072. * @param value value between a and b
  70073. * @returns the inverseLerp value
  70074. */
  70075. static InverseLerp(a: number, b: number, value: number): number;
  70076. /**
  70077. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  70078. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  70079. * @param value1 spline value
  70080. * @param tangent1 spline value
  70081. * @param value2 spline value
  70082. * @param tangent2 spline value
  70083. * @param amount input value
  70084. * @returns hermite result
  70085. */
  70086. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  70087. /**
  70088. * Returns a random float number between and min and max values
  70089. * @param min min value of random
  70090. * @param max max value of random
  70091. * @returns random value
  70092. */
  70093. static RandomRange(min: number, max: number): number;
  70094. /**
  70095. * This function returns percentage of a number in a given range.
  70096. *
  70097. * RangeToPercent(40,20,60) will return 0.5 (50%)
  70098. * RangeToPercent(34,0,100) will return 0.34 (34%)
  70099. * @param number to convert to percentage
  70100. * @param min min range
  70101. * @param max max range
  70102. * @returns the percentage
  70103. */
  70104. static RangeToPercent(number: number, min: number, max: number): number;
  70105. /**
  70106. * This function returns number that corresponds to the percentage in a given range.
  70107. *
  70108. * PercentToRange(0.34,0,100) will return 34.
  70109. * @param percent to convert to number
  70110. * @param min min range
  70111. * @param max max range
  70112. * @returns the number
  70113. */
  70114. static PercentToRange(percent: number, min: number, max: number): number;
  70115. /**
  70116. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  70117. * @param angle The angle to normalize in radian.
  70118. * @return The converted angle.
  70119. */
  70120. static NormalizeRadians(angle: number): number;
  70121. }
  70122. }
  70123. declare module BABYLON {
  70124. /**
  70125. * Constant used to convert a value to gamma space
  70126. * @ignorenaming
  70127. */
  70128. export const ToGammaSpace: number;
  70129. /**
  70130. * Constant used to convert a value to linear space
  70131. * @ignorenaming
  70132. */
  70133. export const ToLinearSpace = 2.2;
  70134. /**
  70135. * Constant used to define the minimal number value in Babylon.js
  70136. * @ignorenaming
  70137. */
  70138. let Epsilon: number;
  70139. }
  70140. declare module BABYLON {
  70141. /**
  70142. * Class used to represent a viewport on screen
  70143. */
  70144. export class Viewport {
  70145. /** viewport left coordinate */
  70146. x: number;
  70147. /** viewport top coordinate */
  70148. y: number;
  70149. /**viewport width */
  70150. width: number;
  70151. /** viewport height */
  70152. height: number;
  70153. /**
  70154. * Creates a Viewport object located at (x, y) and sized (width, height)
  70155. * @param x defines viewport left coordinate
  70156. * @param y defines viewport top coordinate
  70157. * @param width defines the viewport width
  70158. * @param height defines the viewport height
  70159. */
  70160. constructor(
  70161. /** viewport left coordinate */
  70162. x: number,
  70163. /** viewport top coordinate */
  70164. y: number,
  70165. /**viewport width */
  70166. width: number,
  70167. /** viewport height */
  70168. height: number);
  70169. /**
  70170. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  70171. * @param renderWidth defines the rendering width
  70172. * @param renderHeight defines the rendering height
  70173. * @returns a new Viewport
  70174. */
  70175. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  70176. /**
  70177. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  70178. * @param renderWidth defines the rendering width
  70179. * @param renderHeight defines the rendering height
  70180. * @param ref defines the target viewport
  70181. * @returns the current viewport
  70182. */
  70183. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  70184. /**
  70185. * Returns a new Viewport copied from the current one
  70186. * @returns a new Viewport
  70187. */
  70188. clone(): Viewport;
  70189. }
  70190. }
  70191. declare module BABYLON {
  70192. /**
  70193. * Class containing a set of static utilities functions for arrays.
  70194. */
  70195. export class ArrayTools {
  70196. /**
  70197. * Returns an array of the given size filled with element built from the given constructor and the paramters
  70198. * @param size the number of element to construct and put in the array
  70199. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  70200. * @returns a new array filled with new objects
  70201. */
  70202. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  70203. }
  70204. }
  70205. declare module BABYLON {
  70206. /**
  70207. * Class representing a vector containing 2 coordinates
  70208. */
  70209. export class Vector2 {
  70210. /** defines the first coordinate */
  70211. x: number;
  70212. /** defines the second coordinate */
  70213. y: number;
  70214. /**
  70215. * Creates a new Vector2 from the given x and y coordinates
  70216. * @param x defines the first coordinate
  70217. * @param y defines the second coordinate
  70218. */
  70219. constructor(
  70220. /** defines the first coordinate */
  70221. x?: number,
  70222. /** defines the second coordinate */
  70223. y?: number);
  70224. /**
  70225. * Gets a string with the Vector2 coordinates
  70226. * @returns a string with the Vector2 coordinates
  70227. */
  70228. toString(): string;
  70229. /**
  70230. * Gets class name
  70231. * @returns the string "Vector2"
  70232. */
  70233. getClassName(): string;
  70234. /**
  70235. * Gets current vector hash code
  70236. * @returns the Vector2 hash code as a number
  70237. */
  70238. getHashCode(): number;
  70239. /**
  70240. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  70241. * @param array defines the source array
  70242. * @param index defines the offset in source array
  70243. * @returns the current Vector2
  70244. */
  70245. toArray(array: FloatArray, index?: number): Vector2;
  70246. /**
  70247. * Copy the current vector to an array
  70248. * @returns a new array with 2 elements: the Vector2 coordinates.
  70249. */
  70250. asArray(): number[];
  70251. /**
  70252. * Sets the Vector2 coordinates with the given Vector2 coordinates
  70253. * @param source defines the source Vector2
  70254. * @returns the current updated Vector2
  70255. */
  70256. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  70257. /**
  70258. * Sets the Vector2 coordinates with the given floats
  70259. * @param x defines the first coordinate
  70260. * @param y defines the second coordinate
  70261. * @returns the current updated Vector2
  70262. */
  70263. copyFromFloats(x: number, y: number): Vector2;
  70264. /**
  70265. * Sets the Vector2 coordinates with the given floats
  70266. * @param x defines the first coordinate
  70267. * @param y defines the second coordinate
  70268. * @returns the current updated Vector2
  70269. */
  70270. set(x: number, y: number): Vector2;
  70271. /**
  70272. * Add another vector with the current one
  70273. * @param otherVector defines the other vector
  70274. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  70275. */
  70276. add(otherVector: DeepImmutable<Vector2>): Vector2;
  70277. /**
  70278. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  70279. * @param otherVector defines the other vector
  70280. * @param result defines the target vector
  70281. * @returns the unmodified current Vector2
  70282. */
  70283. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70284. /**
  70285. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  70286. * @param otherVector defines the other vector
  70287. * @returns the current updated Vector2
  70288. */
  70289. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70290. /**
  70291. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  70292. * @param otherVector defines the other vector
  70293. * @returns a new Vector2
  70294. */
  70295. addVector3(otherVector: Vector3): Vector2;
  70296. /**
  70297. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  70298. * @param otherVector defines the other vector
  70299. * @returns a new Vector2
  70300. */
  70301. subtract(otherVector: Vector2): Vector2;
  70302. /**
  70303. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  70304. * @param otherVector defines the other vector
  70305. * @param result defines the target vector
  70306. * @returns the unmodified current Vector2
  70307. */
  70308. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70309. /**
  70310. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  70311. * @param otherVector defines the other vector
  70312. * @returns the current updated Vector2
  70313. */
  70314. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70315. /**
  70316. * Multiplies in place the current Vector2 coordinates by the given ones
  70317. * @param otherVector defines the other vector
  70318. * @returns the current updated Vector2
  70319. */
  70320. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70321. /**
  70322. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  70323. * @param otherVector defines the other vector
  70324. * @returns a new Vector2
  70325. */
  70326. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  70327. /**
  70328. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  70329. * @param otherVector defines the other vector
  70330. * @param result defines the target vector
  70331. * @returns the unmodified current Vector2
  70332. */
  70333. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70334. /**
  70335. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  70336. * @param x defines the first coordinate
  70337. * @param y defines the second coordinate
  70338. * @returns a new Vector2
  70339. */
  70340. multiplyByFloats(x: number, y: number): Vector2;
  70341. /**
  70342. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  70343. * @param otherVector defines the other vector
  70344. * @returns a new Vector2
  70345. */
  70346. divide(otherVector: Vector2): Vector2;
  70347. /**
  70348. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  70349. * @param otherVector defines the other vector
  70350. * @param result defines the target vector
  70351. * @returns the unmodified current Vector2
  70352. */
  70353. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70354. /**
  70355. * Divides the current Vector2 coordinates by the given ones
  70356. * @param otherVector defines the other vector
  70357. * @returns the current updated Vector2
  70358. */
  70359. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70360. /**
  70361. * Gets a new Vector2 with current Vector2 negated coordinates
  70362. * @returns a new Vector2
  70363. */
  70364. negate(): Vector2;
  70365. /**
  70366. * Multiply the Vector2 coordinates by scale
  70367. * @param scale defines the scaling factor
  70368. * @returns the current updated Vector2
  70369. */
  70370. scaleInPlace(scale: number): Vector2;
  70371. /**
  70372. * Returns a new Vector2 scaled by "scale" from the current Vector2
  70373. * @param scale defines the scaling factor
  70374. * @returns a new Vector2
  70375. */
  70376. scale(scale: number): Vector2;
  70377. /**
  70378. * Scale the current Vector2 values by a factor to a given Vector2
  70379. * @param scale defines the scale factor
  70380. * @param result defines the Vector2 object where to store the result
  70381. * @returns the unmodified current Vector2
  70382. */
  70383. scaleToRef(scale: number, result: Vector2): Vector2;
  70384. /**
  70385. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  70386. * @param scale defines the scale factor
  70387. * @param result defines the Vector2 object where to store the result
  70388. * @returns the unmodified current Vector2
  70389. */
  70390. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  70391. /**
  70392. * Gets a boolean if two vectors are equals
  70393. * @param otherVector defines the other vector
  70394. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  70395. */
  70396. equals(otherVector: DeepImmutable<Vector2>): boolean;
  70397. /**
  70398. * Gets a boolean if two vectors are equals (using an epsilon value)
  70399. * @param otherVector defines the other vector
  70400. * @param epsilon defines the minimal distance to consider equality
  70401. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  70402. */
  70403. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  70404. /**
  70405. * Gets a new Vector2 from current Vector2 floored values
  70406. * @returns a new Vector2
  70407. */
  70408. floor(): Vector2;
  70409. /**
  70410. * Gets a new Vector2 from current Vector2 floored values
  70411. * @returns a new Vector2
  70412. */
  70413. fract(): Vector2;
  70414. /**
  70415. * Gets the length of the vector
  70416. * @returns the vector length (float)
  70417. */
  70418. length(): number;
  70419. /**
  70420. * Gets the vector squared length
  70421. * @returns the vector squared length (float)
  70422. */
  70423. lengthSquared(): number;
  70424. /**
  70425. * Normalize the vector
  70426. * @returns the current updated Vector2
  70427. */
  70428. normalize(): Vector2;
  70429. /**
  70430. * Gets a new Vector2 copied from the Vector2
  70431. * @returns a new Vector2
  70432. */
  70433. clone(): Vector2;
  70434. /**
  70435. * Gets a new Vector2(0, 0)
  70436. * @returns a new Vector2
  70437. */
  70438. static Zero(): Vector2;
  70439. /**
  70440. * Gets a new Vector2(1, 1)
  70441. * @returns a new Vector2
  70442. */
  70443. static One(): Vector2;
  70444. /**
  70445. * Gets a new Vector2 set from the given index element of the given array
  70446. * @param array defines the data source
  70447. * @param offset defines the offset in the data source
  70448. * @returns a new Vector2
  70449. */
  70450. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  70451. /**
  70452. * Sets "result" from the given index element of the given array
  70453. * @param array defines the data source
  70454. * @param offset defines the offset in the data source
  70455. * @param result defines the target vector
  70456. */
  70457. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  70458. /**
  70459. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  70460. * @param value1 defines 1st point of control
  70461. * @param value2 defines 2nd point of control
  70462. * @param value3 defines 3rd point of control
  70463. * @param value4 defines 4th point of control
  70464. * @param amount defines the interpolation factor
  70465. * @returns a new Vector2
  70466. */
  70467. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  70468. /**
  70469. * 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".
  70470. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  70471. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  70472. * @param value defines the value to clamp
  70473. * @param min defines the lower limit
  70474. * @param max defines the upper limit
  70475. * @returns a new Vector2
  70476. */
  70477. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  70478. /**
  70479. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  70480. * @param value1 defines the 1st control point
  70481. * @param tangent1 defines the outgoing tangent
  70482. * @param value2 defines the 2nd control point
  70483. * @param tangent2 defines the incoming tangent
  70484. * @param amount defines the interpolation factor
  70485. * @returns a new Vector2
  70486. */
  70487. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  70488. /**
  70489. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  70490. * @param start defines the start vector
  70491. * @param end defines the end vector
  70492. * @param amount defines the interpolation factor
  70493. * @returns a new Vector2
  70494. */
  70495. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  70496. /**
  70497. * Gets the dot product of the vector "left" and the vector "right"
  70498. * @param left defines first vector
  70499. * @param right defines second vector
  70500. * @returns the dot product (float)
  70501. */
  70502. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  70503. /**
  70504. * Returns a new Vector2 equal to the normalized given vector
  70505. * @param vector defines the vector to normalize
  70506. * @returns a new Vector2
  70507. */
  70508. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  70509. /**
  70510. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  70511. * @param left defines 1st vector
  70512. * @param right defines 2nd vector
  70513. * @returns a new Vector2
  70514. */
  70515. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70516. /**
  70517. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  70518. * @param left defines 1st vector
  70519. * @param right defines 2nd vector
  70520. * @returns a new Vector2
  70521. */
  70522. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70523. /**
  70524. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  70525. * @param vector defines the vector to transform
  70526. * @param transformation defines the matrix to apply
  70527. * @returns a new Vector2
  70528. */
  70529. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  70530. /**
  70531. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  70532. * @param vector defines the vector to transform
  70533. * @param transformation defines the matrix to apply
  70534. * @param result defines the target vector
  70535. */
  70536. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  70537. /**
  70538. * Determines if a given vector is included in a triangle
  70539. * @param p defines the vector to test
  70540. * @param p0 defines 1st triangle point
  70541. * @param p1 defines 2nd triangle point
  70542. * @param p2 defines 3rd triangle point
  70543. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  70544. */
  70545. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  70546. /**
  70547. * Gets the distance between the vectors "value1" and "value2"
  70548. * @param value1 defines first vector
  70549. * @param value2 defines second vector
  70550. * @returns the distance between vectors
  70551. */
  70552. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70553. /**
  70554. * Returns the squared distance between the vectors "value1" and "value2"
  70555. * @param value1 defines first vector
  70556. * @param value2 defines second vector
  70557. * @returns the squared distance between vectors
  70558. */
  70559. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70560. /**
  70561. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  70562. * @param value1 defines first vector
  70563. * @param value2 defines second vector
  70564. * @returns a new Vector2
  70565. */
  70566. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  70567. /**
  70568. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  70569. * @param p defines the middle point
  70570. * @param segA defines one point of the segment
  70571. * @param segB defines the other point of the segment
  70572. * @returns the shortest distance
  70573. */
  70574. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  70575. }
  70576. /**
  70577. * Classed used to store (x,y,z) vector representation
  70578. * A Vector3 is the main object used in 3D geometry
  70579. * It can represent etiher the coordinates of a point the space, either a direction
  70580. * Reminder: js uses a left handed forward facing system
  70581. */
  70582. export class Vector3 {
  70583. /**
  70584. * Defines the first coordinates (on X axis)
  70585. */
  70586. x: number;
  70587. /**
  70588. * Defines the second coordinates (on Y axis)
  70589. */
  70590. y: number;
  70591. /**
  70592. * Defines the third coordinates (on Z axis)
  70593. */
  70594. z: number;
  70595. private static _UpReadOnly;
  70596. private static _ZeroReadOnly;
  70597. /**
  70598. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  70599. * @param x defines the first coordinates (on X axis)
  70600. * @param y defines the second coordinates (on Y axis)
  70601. * @param z defines the third coordinates (on Z axis)
  70602. */
  70603. constructor(
  70604. /**
  70605. * Defines the first coordinates (on X axis)
  70606. */
  70607. x?: number,
  70608. /**
  70609. * Defines the second coordinates (on Y axis)
  70610. */
  70611. y?: number,
  70612. /**
  70613. * Defines the third coordinates (on Z axis)
  70614. */
  70615. z?: number);
  70616. /**
  70617. * Creates a string representation of the Vector3
  70618. * @returns a string with the Vector3 coordinates.
  70619. */
  70620. toString(): string;
  70621. /**
  70622. * Gets the class name
  70623. * @returns the string "Vector3"
  70624. */
  70625. getClassName(): string;
  70626. /**
  70627. * Creates the Vector3 hash code
  70628. * @returns a number which tends to be unique between Vector3 instances
  70629. */
  70630. getHashCode(): number;
  70631. /**
  70632. * Creates an array containing three elements : the coordinates of the Vector3
  70633. * @returns a new array of numbers
  70634. */
  70635. asArray(): number[];
  70636. /**
  70637. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  70638. * @param array defines the destination array
  70639. * @param index defines the offset in the destination array
  70640. * @returns the current Vector3
  70641. */
  70642. toArray(array: FloatArray, index?: number): Vector3;
  70643. /**
  70644. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  70645. * @returns a new Quaternion object, computed from the Vector3 coordinates
  70646. */
  70647. toQuaternion(): Quaternion;
  70648. /**
  70649. * Adds the given vector to the current Vector3
  70650. * @param otherVector defines the second operand
  70651. * @returns the current updated Vector3
  70652. */
  70653. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70654. /**
  70655. * Adds the given coordinates to the current Vector3
  70656. * @param x defines the x coordinate of the operand
  70657. * @param y defines the y coordinate of the operand
  70658. * @param z defines the z coordinate of the operand
  70659. * @returns the current updated Vector3
  70660. */
  70661. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70662. /**
  70663. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  70664. * @param otherVector defines the second operand
  70665. * @returns the resulting Vector3
  70666. */
  70667. add(otherVector: DeepImmutable<Vector3>): Vector3;
  70668. /**
  70669. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  70670. * @param otherVector defines the second operand
  70671. * @param result defines the Vector3 object where to store the result
  70672. * @returns the current Vector3
  70673. */
  70674. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70675. /**
  70676. * Subtract the given vector from the current Vector3
  70677. * @param otherVector defines the second operand
  70678. * @returns the current updated Vector3
  70679. */
  70680. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70681. /**
  70682. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  70683. * @param otherVector defines the second operand
  70684. * @returns the resulting Vector3
  70685. */
  70686. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  70687. /**
  70688. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  70689. * @param otherVector defines the second operand
  70690. * @param result defines the Vector3 object where to store the result
  70691. * @returns the current Vector3
  70692. */
  70693. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70694. /**
  70695. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  70696. * @param x defines the x coordinate of the operand
  70697. * @param y defines the y coordinate of the operand
  70698. * @param z defines the z coordinate of the operand
  70699. * @returns the resulting Vector3
  70700. */
  70701. subtractFromFloats(x: number, y: number, z: number): Vector3;
  70702. /**
  70703. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  70704. * @param x defines the x coordinate of the operand
  70705. * @param y defines the y coordinate of the operand
  70706. * @param z defines the z coordinate of the operand
  70707. * @param result defines the Vector3 object where to store the result
  70708. * @returns the current Vector3
  70709. */
  70710. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  70711. /**
  70712. * Gets a new Vector3 set with the current Vector3 negated coordinates
  70713. * @returns a new Vector3
  70714. */
  70715. negate(): Vector3;
  70716. /**
  70717. * Multiplies the Vector3 coordinates by the float "scale"
  70718. * @param scale defines the multiplier factor
  70719. * @returns the current updated Vector3
  70720. */
  70721. scaleInPlace(scale: number): Vector3;
  70722. /**
  70723. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  70724. * @param scale defines the multiplier factor
  70725. * @returns a new Vector3
  70726. */
  70727. scale(scale: number): Vector3;
  70728. /**
  70729. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  70730. * @param scale defines the multiplier factor
  70731. * @param result defines the Vector3 object where to store the result
  70732. * @returns the current Vector3
  70733. */
  70734. scaleToRef(scale: number, result: Vector3): Vector3;
  70735. /**
  70736. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  70737. * @param scale defines the scale factor
  70738. * @param result defines the Vector3 object where to store the result
  70739. * @returns the unmodified current Vector3
  70740. */
  70741. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  70742. /**
  70743. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  70744. * @param otherVector defines the second operand
  70745. * @returns true if both vectors are equals
  70746. */
  70747. equals(otherVector: DeepImmutable<Vector3>): boolean;
  70748. /**
  70749. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  70750. * @param otherVector defines the second operand
  70751. * @param epsilon defines the minimal distance to define values as equals
  70752. * @returns true if both vectors are distant less than epsilon
  70753. */
  70754. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  70755. /**
  70756. * Returns true if the current Vector3 coordinates equals the given floats
  70757. * @param x defines the x coordinate of the operand
  70758. * @param y defines the y coordinate of the operand
  70759. * @param z defines the z coordinate of the operand
  70760. * @returns true if both vectors are equals
  70761. */
  70762. equalsToFloats(x: number, y: number, z: number): boolean;
  70763. /**
  70764. * Multiplies the current Vector3 coordinates by the given ones
  70765. * @param otherVector defines the second operand
  70766. * @returns the current updated Vector3
  70767. */
  70768. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70769. /**
  70770. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  70771. * @param otherVector defines the second operand
  70772. * @returns the new Vector3
  70773. */
  70774. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  70775. /**
  70776. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  70777. * @param otherVector defines the second operand
  70778. * @param result defines the Vector3 object where to store the result
  70779. * @returns the current Vector3
  70780. */
  70781. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70782. /**
  70783. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  70784. * @param x defines the x coordinate of the operand
  70785. * @param y defines the y coordinate of the operand
  70786. * @param z defines the z coordinate of the operand
  70787. * @returns the new Vector3
  70788. */
  70789. multiplyByFloats(x: number, y: number, z: number): Vector3;
  70790. /**
  70791. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  70792. * @param otherVector defines the second operand
  70793. * @returns the new Vector3
  70794. */
  70795. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  70796. /**
  70797. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  70798. * @param otherVector defines the second operand
  70799. * @param result defines the Vector3 object where to store the result
  70800. * @returns the current Vector3
  70801. */
  70802. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70803. /**
  70804. * Divides the current Vector3 coordinates by the given ones.
  70805. * @param otherVector defines the second operand
  70806. * @returns the current updated Vector3
  70807. */
  70808. divideInPlace(otherVector: Vector3): Vector3;
  70809. /**
  70810. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  70811. * @param other defines the second operand
  70812. * @returns the current updated Vector3
  70813. */
  70814. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70815. /**
  70816. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  70817. * @param other defines the second operand
  70818. * @returns the current updated Vector3
  70819. */
  70820. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70821. /**
  70822. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  70823. * @param x defines the x coordinate of the operand
  70824. * @param y defines the y coordinate of the operand
  70825. * @param z defines the z coordinate of the operand
  70826. * @returns the current updated Vector3
  70827. */
  70828. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70829. /**
  70830. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  70831. * @param x defines the x coordinate of the operand
  70832. * @param y defines the y coordinate of the operand
  70833. * @param z defines the z coordinate of the operand
  70834. * @returns the current updated Vector3
  70835. */
  70836. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70837. /**
  70838. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  70839. * Check if is non uniform within a certain amount of decimal places to account for this
  70840. * @param epsilon the amount the values can differ
  70841. * @returns if the the vector is non uniform to a certain number of decimal places
  70842. */
  70843. isNonUniformWithinEpsilon(epsilon: number): boolean;
  70844. /**
  70845. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  70846. */
  70847. readonly isNonUniform: boolean;
  70848. /**
  70849. * Gets a new Vector3 from current Vector3 floored values
  70850. * @returns a new Vector3
  70851. */
  70852. floor(): Vector3;
  70853. /**
  70854. * Gets a new Vector3 from current Vector3 floored values
  70855. * @returns a new Vector3
  70856. */
  70857. fract(): Vector3;
  70858. /**
  70859. * Gets the length of the Vector3
  70860. * @returns the length of the Vector3
  70861. */
  70862. length(): number;
  70863. /**
  70864. * Gets the squared length of the Vector3
  70865. * @returns squared length of the Vector3
  70866. */
  70867. lengthSquared(): number;
  70868. /**
  70869. * Normalize the current Vector3.
  70870. * Please note that this is an in place operation.
  70871. * @returns the current updated Vector3
  70872. */
  70873. normalize(): Vector3;
  70874. /**
  70875. * Reorders the x y z properties of the vector in place
  70876. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  70877. * @returns the current updated vector
  70878. */
  70879. reorderInPlace(order: string): this;
  70880. /**
  70881. * Rotates the vector around 0,0,0 by a quaternion
  70882. * @param quaternion the rotation quaternion
  70883. * @param result vector to store the result
  70884. * @returns the resulting vector
  70885. */
  70886. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  70887. /**
  70888. * Rotates a vector around a given point
  70889. * @param quaternion the rotation quaternion
  70890. * @param point the point to rotate around
  70891. * @param result vector to store the result
  70892. * @returns the resulting vector
  70893. */
  70894. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  70895. /**
  70896. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  70897. * The cross product is then orthogonal to both current and "other"
  70898. * @param other defines the right operand
  70899. * @returns the cross product
  70900. */
  70901. cross(other: Vector3): Vector3;
  70902. /**
  70903. * Normalize the current Vector3 with the given input length.
  70904. * Please note that this is an in place operation.
  70905. * @param len the length of the vector
  70906. * @returns the current updated Vector3
  70907. */
  70908. normalizeFromLength(len: number): Vector3;
  70909. /**
  70910. * Normalize the current Vector3 to a new vector
  70911. * @returns the new Vector3
  70912. */
  70913. normalizeToNew(): Vector3;
  70914. /**
  70915. * Normalize the current Vector3 to the reference
  70916. * @param reference define the Vector3 to update
  70917. * @returns the updated Vector3
  70918. */
  70919. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  70920. /**
  70921. * Creates a new Vector3 copied from the current Vector3
  70922. * @returns the new Vector3
  70923. */
  70924. clone(): Vector3;
  70925. /**
  70926. * Copies the given vector coordinates to the current Vector3 ones
  70927. * @param source defines the source Vector3
  70928. * @returns the current updated Vector3
  70929. */
  70930. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  70931. /**
  70932. * Copies the given floats to the current Vector3 coordinates
  70933. * @param x defines the x coordinate of the operand
  70934. * @param y defines the y coordinate of the operand
  70935. * @param z defines the z coordinate of the operand
  70936. * @returns the current updated Vector3
  70937. */
  70938. copyFromFloats(x: number, y: number, z: number): Vector3;
  70939. /**
  70940. * Copies the given floats to the current Vector3 coordinates
  70941. * @param x defines the x coordinate of the operand
  70942. * @param y defines the y coordinate of the operand
  70943. * @param z defines the z coordinate of the operand
  70944. * @returns the current updated Vector3
  70945. */
  70946. set(x: number, y: number, z: number): Vector3;
  70947. /**
  70948. * Copies the given float to the current Vector3 coordinates
  70949. * @param v defines the x, y and z coordinates of the operand
  70950. * @returns the current updated Vector3
  70951. */
  70952. setAll(v: number): Vector3;
  70953. /**
  70954. * Get the clip factor between two vectors
  70955. * @param vector0 defines the first operand
  70956. * @param vector1 defines the second operand
  70957. * @param axis defines the axis to use
  70958. * @param size defines the size along the axis
  70959. * @returns the clip factor
  70960. */
  70961. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  70962. /**
  70963. * Get angle between two vectors
  70964. * @param vector0 angle between vector0 and vector1
  70965. * @param vector1 angle between vector0 and vector1
  70966. * @param normal direction of the normal
  70967. * @return the angle between vector0 and vector1
  70968. */
  70969. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  70970. /**
  70971. * Returns a new Vector3 set from the index "offset" of the given array
  70972. * @param array defines the source array
  70973. * @param offset defines the offset in the source array
  70974. * @returns the new Vector3
  70975. */
  70976. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  70977. /**
  70978. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  70979. * This function is deprecated. Use FromArray instead
  70980. * @param array defines the source array
  70981. * @param offset defines the offset in the source array
  70982. * @returns the new Vector3
  70983. */
  70984. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  70985. /**
  70986. * Sets the given vector "result" with the element values from the index "offset" of the given array
  70987. * @param array defines the source array
  70988. * @param offset defines the offset in the source array
  70989. * @param result defines the Vector3 where to store the result
  70990. */
  70991. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  70992. /**
  70993. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  70994. * This function is deprecated. Use FromArrayToRef instead.
  70995. * @param array defines the source array
  70996. * @param offset defines the offset in the source array
  70997. * @param result defines the Vector3 where to store the result
  70998. */
  70999. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  71000. /**
  71001. * Sets the given vector "result" with the given floats.
  71002. * @param x defines the x coordinate of the source
  71003. * @param y defines the y coordinate of the source
  71004. * @param z defines the z coordinate of the source
  71005. * @param result defines the Vector3 where to store the result
  71006. */
  71007. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  71008. /**
  71009. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  71010. * @returns a new empty Vector3
  71011. */
  71012. static Zero(): Vector3;
  71013. /**
  71014. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  71015. * @returns a new unit Vector3
  71016. */
  71017. static One(): Vector3;
  71018. /**
  71019. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  71020. * @returns a new up Vector3
  71021. */
  71022. static Up(): Vector3;
  71023. /**
  71024. * Gets a up Vector3 that must not be updated
  71025. */
  71026. static readonly UpReadOnly: DeepImmutable<Vector3>;
  71027. /**
  71028. * Gets a zero Vector3 that must not be updated
  71029. */
  71030. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  71031. /**
  71032. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  71033. * @returns a new down Vector3
  71034. */
  71035. static Down(): Vector3;
  71036. /**
  71037. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  71038. * @returns a new forward Vector3
  71039. */
  71040. static Forward(): Vector3;
  71041. /**
  71042. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  71043. * @returns a new forward Vector3
  71044. */
  71045. static Backward(): Vector3;
  71046. /**
  71047. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  71048. * @returns a new right Vector3
  71049. */
  71050. static Right(): Vector3;
  71051. /**
  71052. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  71053. * @returns a new left Vector3
  71054. */
  71055. static Left(): Vector3;
  71056. /**
  71057. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  71058. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71059. * @param vector defines the Vector3 to transform
  71060. * @param transformation defines the transformation matrix
  71061. * @returns the transformed Vector3
  71062. */
  71063. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  71064. /**
  71065. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  71066. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71067. * @param vector defines the Vector3 to transform
  71068. * @param transformation defines the transformation matrix
  71069. * @param result defines the Vector3 where to store the result
  71070. */
  71071. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71072. /**
  71073. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  71074. * This method computes tranformed coordinates only, not transformed direction vectors
  71075. * @param x define the x coordinate of the source vector
  71076. * @param y define the y coordinate of the source vector
  71077. * @param z define the z coordinate of the source vector
  71078. * @param transformation defines the transformation matrix
  71079. * @param result defines the Vector3 where to store the result
  71080. */
  71081. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71082. /**
  71083. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  71084. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71085. * @param vector defines the Vector3 to transform
  71086. * @param transformation defines the transformation matrix
  71087. * @returns the new Vector3
  71088. */
  71089. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  71090. /**
  71091. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  71092. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71093. * @param vector defines the Vector3 to transform
  71094. * @param transformation defines the transformation matrix
  71095. * @param result defines the Vector3 where to store the result
  71096. */
  71097. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71098. /**
  71099. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  71100. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71101. * @param x define the x coordinate of the source vector
  71102. * @param y define the y coordinate of the source vector
  71103. * @param z define the z coordinate of the source vector
  71104. * @param transformation defines the transformation matrix
  71105. * @param result defines the Vector3 where to store the result
  71106. */
  71107. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71108. /**
  71109. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  71110. * @param value1 defines the first control point
  71111. * @param value2 defines the second control point
  71112. * @param value3 defines the third control point
  71113. * @param value4 defines the fourth control point
  71114. * @param amount defines the amount on the spline to use
  71115. * @returns the new Vector3
  71116. */
  71117. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  71118. /**
  71119. * 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"
  71120. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71121. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71122. * @param value defines the current value
  71123. * @param min defines the lower range value
  71124. * @param max defines the upper range value
  71125. * @returns the new Vector3
  71126. */
  71127. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  71128. /**
  71129. * 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"
  71130. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71131. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71132. * @param value defines the current value
  71133. * @param min defines the lower range value
  71134. * @param max defines the upper range value
  71135. * @param result defines the Vector3 where to store the result
  71136. */
  71137. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  71138. /**
  71139. * Checks if a given vector is inside a specific range
  71140. * @param v defines the vector to test
  71141. * @param min defines the minimum range
  71142. * @param max defines the maximum range
  71143. */
  71144. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  71145. /**
  71146. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  71147. * @param value1 defines the first control point
  71148. * @param tangent1 defines the first tangent vector
  71149. * @param value2 defines the second control point
  71150. * @param tangent2 defines the second tangent vector
  71151. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  71152. * @returns the new Vector3
  71153. */
  71154. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  71155. /**
  71156. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  71157. * @param start defines the start value
  71158. * @param end defines the end value
  71159. * @param amount max defines amount between both (between 0 and 1)
  71160. * @returns the new Vector3
  71161. */
  71162. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  71163. /**
  71164. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  71165. * @param start defines the start value
  71166. * @param end defines the end value
  71167. * @param amount max defines amount between both (between 0 and 1)
  71168. * @param result defines the Vector3 where to store the result
  71169. */
  71170. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  71171. /**
  71172. * Returns the dot product (float) between the vectors "left" and "right"
  71173. * @param left defines the left operand
  71174. * @param right defines the right operand
  71175. * @returns the dot product
  71176. */
  71177. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  71178. /**
  71179. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  71180. * The cross product is then orthogonal to both "left" and "right"
  71181. * @param left defines the left operand
  71182. * @param right defines the right operand
  71183. * @returns the cross product
  71184. */
  71185. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71186. /**
  71187. * Sets the given vector "result" with the cross product of "left" and "right"
  71188. * The cross product is then orthogonal to both "left" and "right"
  71189. * @param left defines the left operand
  71190. * @param right defines the right operand
  71191. * @param result defines the Vector3 where to store the result
  71192. */
  71193. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  71194. /**
  71195. * Returns a new Vector3 as the normalization of the given vector
  71196. * @param vector defines the Vector3 to normalize
  71197. * @returns the new Vector3
  71198. */
  71199. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  71200. /**
  71201. * Sets the given vector "result" with the normalization of the given first vector
  71202. * @param vector defines the Vector3 to normalize
  71203. * @param result defines the Vector3 where to store the result
  71204. */
  71205. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  71206. /**
  71207. * Project a Vector3 onto screen space
  71208. * @param vector defines the Vector3 to project
  71209. * @param world defines the world matrix to use
  71210. * @param transform defines the transform (view x projection) matrix to use
  71211. * @param viewport defines the screen viewport to use
  71212. * @returns the new Vector3
  71213. */
  71214. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  71215. /** @hidden */
  71216. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  71217. /**
  71218. * Unproject from screen space to object space
  71219. * @param source defines the screen space Vector3 to use
  71220. * @param viewportWidth defines the current width of the viewport
  71221. * @param viewportHeight defines the current height of the viewport
  71222. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71223. * @param transform defines the transform (view x projection) matrix to use
  71224. * @returns the new Vector3
  71225. */
  71226. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  71227. /**
  71228. * Unproject from screen space to object space
  71229. * @param source defines the screen space Vector3 to use
  71230. * @param viewportWidth defines the current width of the viewport
  71231. * @param viewportHeight defines the current height of the viewport
  71232. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71233. * @param view defines the view matrix to use
  71234. * @param projection defines the projection matrix to use
  71235. * @returns the new Vector3
  71236. */
  71237. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  71238. /**
  71239. * Unproject from screen space to object space
  71240. * @param source defines the screen space Vector3 to use
  71241. * @param viewportWidth defines the current width of the viewport
  71242. * @param viewportHeight defines the current height of the viewport
  71243. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71244. * @param view defines the view matrix to use
  71245. * @param projection defines the projection matrix to use
  71246. * @param result defines the Vector3 where to store the result
  71247. */
  71248. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71249. /**
  71250. * Unproject from screen space to object space
  71251. * @param sourceX defines the screen space x coordinate to use
  71252. * @param sourceY defines the screen space y coordinate to use
  71253. * @param sourceZ defines the screen space z coordinate to use
  71254. * @param viewportWidth defines the current width of the viewport
  71255. * @param viewportHeight defines the current height of the viewport
  71256. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71257. * @param view defines the view matrix to use
  71258. * @param projection defines the projection matrix to use
  71259. * @param result defines the Vector3 where to store the result
  71260. */
  71261. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71262. /**
  71263. * Gets the minimal coordinate values between two Vector3
  71264. * @param left defines the first operand
  71265. * @param right defines the second operand
  71266. * @returns the new Vector3
  71267. */
  71268. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71269. /**
  71270. * Gets the maximal coordinate values between two Vector3
  71271. * @param left defines the first operand
  71272. * @param right defines the second operand
  71273. * @returns the new Vector3
  71274. */
  71275. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71276. /**
  71277. * Returns the distance between the vectors "value1" and "value2"
  71278. * @param value1 defines the first operand
  71279. * @param value2 defines the second operand
  71280. * @returns the distance
  71281. */
  71282. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71283. /**
  71284. * Returns the squared distance between the vectors "value1" and "value2"
  71285. * @param value1 defines the first operand
  71286. * @param value2 defines the second operand
  71287. * @returns the squared distance
  71288. */
  71289. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71290. /**
  71291. * Returns a new Vector3 located at the center between "value1" and "value2"
  71292. * @param value1 defines the first operand
  71293. * @param value2 defines the second operand
  71294. * @returns the new Vector3
  71295. */
  71296. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  71297. /**
  71298. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  71299. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  71300. * to something in order to rotate it from its local system to the given target system
  71301. * Note: axis1, axis2 and axis3 are normalized during this operation
  71302. * @param axis1 defines the first axis
  71303. * @param axis2 defines the second axis
  71304. * @param axis3 defines the third axis
  71305. * @returns a new Vector3
  71306. */
  71307. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  71308. /**
  71309. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  71310. * @param axis1 defines the first axis
  71311. * @param axis2 defines the second axis
  71312. * @param axis3 defines the third axis
  71313. * @param ref defines the Vector3 where to store the result
  71314. */
  71315. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  71316. }
  71317. /**
  71318. * Vector4 class created for EulerAngle class conversion to Quaternion
  71319. */
  71320. export class Vector4 {
  71321. /** x value of the vector */
  71322. x: number;
  71323. /** y value of the vector */
  71324. y: number;
  71325. /** z value of the vector */
  71326. z: number;
  71327. /** w value of the vector */
  71328. w: number;
  71329. /**
  71330. * Creates a Vector4 object from the given floats.
  71331. * @param x x value of the vector
  71332. * @param y y value of the vector
  71333. * @param z z value of the vector
  71334. * @param w w value of the vector
  71335. */
  71336. constructor(
  71337. /** x value of the vector */
  71338. x: number,
  71339. /** y value of the vector */
  71340. y: number,
  71341. /** z value of the vector */
  71342. z: number,
  71343. /** w value of the vector */
  71344. w: number);
  71345. /**
  71346. * Returns the string with the Vector4 coordinates.
  71347. * @returns a string containing all the vector values
  71348. */
  71349. toString(): string;
  71350. /**
  71351. * Returns the string "Vector4".
  71352. * @returns "Vector4"
  71353. */
  71354. getClassName(): string;
  71355. /**
  71356. * Returns the Vector4 hash code.
  71357. * @returns a unique hash code
  71358. */
  71359. getHashCode(): number;
  71360. /**
  71361. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  71362. * @returns the resulting array
  71363. */
  71364. asArray(): number[];
  71365. /**
  71366. * Populates the given array from the given index with the Vector4 coordinates.
  71367. * @param array array to populate
  71368. * @param index index of the array to start at (default: 0)
  71369. * @returns the Vector4.
  71370. */
  71371. toArray(array: FloatArray, index?: number): Vector4;
  71372. /**
  71373. * Adds the given vector to the current Vector4.
  71374. * @param otherVector the vector to add
  71375. * @returns the updated Vector4.
  71376. */
  71377. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71378. /**
  71379. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  71380. * @param otherVector the vector to add
  71381. * @returns the resulting vector
  71382. */
  71383. add(otherVector: DeepImmutable<Vector4>): Vector4;
  71384. /**
  71385. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  71386. * @param otherVector the vector to add
  71387. * @param result the vector to store the result
  71388. * @returns the current Vector4.
  71389. */
  71390. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71391. /**
  71392. * Subtract in place the given vector from the current Vector4.
  71393. * @param otherVector the vector to subtract
  71394. * @returns the updated Vector4.
  71395. */
  71396. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71397. /**
  71398. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  71399. * @param otherVector the vector to add
  71400. * @returns the new vector with the result
  71401. */
  71402. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  71403. /**
  71404. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  71405. * @param otherVector the vector to subtract
  71406. * @param result the vector to store the result
  71407. * @returns the current Vector4.
  71408. */
  71409. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71410. /**
  71411. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71412. */
  71413. /**
  71414. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71415. * @param x value to subtract
  71416. * @param y value to subtract
  71417. * @param z value to subtract
  71418. * @param w value to subtract
  71419. * @returns new vector containing the result
  71420. */
  71421. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71422. /**
  71423. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71424. * @param x value to subtract
  71425. * @param y value to subtract
  71426. * @param z value to subtract
  71427. * @param w value to subtract
  71428. * @param result the vector to store the result in
  71429. * @returns the current Vector4.
  71430. */
  71431. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  71432. /**
  71433. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  71434. * @returns a new vector with the negated values
  71435. */
  71436. negate(): Vector4;
  71437. /**
  71438. * Multiplies the current Vector4 coordinates by scale (float).
  71439. * @param scale the number to scale with
  71440. * @returns the updated Vector4.
  71441. */
  71442. scaleInPlace(scale: number): Vector4;
  71443. /**
  71444. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  71445. * @param scale the number to scale with
  71446. * @returns a new vector with the result
  71447. */
  71448. scale(scale: number): Vector4;
  71449. /**
  71450. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  71451. * @param scale the number to scale with
  71452. * @param result a vector to store the result in
  71453. * @returns the current Vector4.
  71454. */
  71455. scaleToRef(scale: number, result: Vector4): Vector4;
  71456. /**
  71457. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  71458. * @param scale defines the scale factor
  71459. * @param result defines the Vector4 object where to store the result
  71460. * @returns the unmodified current Vector4
  71461. */
  71462. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  71463. /**
  71464. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  71465. * @param otherVector the vector to compare against
  71466. * @returns true if they are equal
  71467. */
  71468. equals(otherVector: DeepImmutable<Vector4>): boolean;
  71469. /**
  71470. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  71471. * @param otherVector vector to compare against
  71472. * @param epsilon (Default: very small number)
  71473. * @returns true if they are equal
  71474. */
  71475. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  71476. /**
  71477. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  71478. * @param x x value to compare against
  71479. * @param y y value to compare against
  71480. * @param z z value to compare against
  71481. * @param w w value to compare against
  71482. * @returns true if equal
  71483. */
  71484. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  71485. /**
  71486. * Multiplies in place the current Vector4 by the given one.
  71487. * @param otherVector vector to multiple with
  71488. * @returns the updated Vector4.
  71489. */
  71490. multiplyInPlace(otherVector: Vector4): Vector4;
  71491. /**
  71492. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  71493. * @param otherVector vector to multiple with
  71494. * @returns resulting new vector
  71495. */
  71496. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  71497. /**
  71498. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  71499. * @param otherVector vector to multiple with
  71500. * @param result vector to store the result
  71501. * @returns the current Vector4.
  71502. */
  71503. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71504. /**
  71505. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  71506. * @param x x value multiply with
  71507. * @param y y value multiply with
  71508. * @param z z value multiply with
  71509. * @param w w value multiply with
  71510. * @returns resulting new vector
  71511. */
  71512. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  71513. /**
  71514. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  71515. * @param otherVector vector to devide with
  71516. * @returns resulting new vector
  71517. */
  71518. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  71519. /**
  71520. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  71521. * @param otherVector vector to devide with
  71522. * @param result vector to store the result
  71523. * @returns the current Vector4.
  71524. */
  71525. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71526. /**
  71527. * Divides the current Vector3 coordinates by the given ones.
  71528. * @param otherVector vector to devide with
  71529. * @returns the updated Vector3.
  71530. */
  71531. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71532. /**
  71533. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  71534. * @param other defines the second operand
  71535. * @returns the current updated Vector4
  71536. */
  71537. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71538. /**
  71539. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  71540. * @param other defines the second operand
  71541. * @returns the current updated Vector4
  71542. */
  71543. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71544. /**
  71545. * Gets a new Vector4 from current Vector4 floored values
  71546. * @returns a new Vector4
  71547. */
  71548. floor(): Vector4;
  71549. /**
  71550. * Gets a new Vector4 from current Vector3 floored values
  71551. * @returns a new Vector4
  71552. */
  71553. fract(): Vector4;
  71554. /**
  71555. * Returns the Vector4 length (float).
  71556. * @returns the length
  71557. */
  71558. length(): number;
  71559. /**
  71560. * Returns the Vector4 squared length (float).
  71561. * @returns the length squared
  71562. */
  71563. lengthSquared(): number;
  71564. /**
  71565. * Normalizes in place the Vector4.
  71566. * @returns the updated Vector4.
  71567. */
  71568. normalize(): Vector4;
  71569. /**
  71570. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  71571. * @returns this converted to a new vector3
  71572. */
  71573. toVector3(): Vector3;
  71574. /**
  71575. * Returns a new Vector4 copied from the current one.
  71576. * @returns the new cloned vector
  71577. */
  71578. clone(): Vector4;
  71579. /**
  71580. * Updates the current Vector4 with the given one coordinates.
  71581. * @param source the source vector to copy from
  71582. * @returns the updated Vector4.
  71583. */
  71584. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  71585. /**
  71586. * Updates the current Vector4 coordinates with the given floats.
  71587. * @param x float to copy from
  71588. * @param y float to copy from
  71589. * @param z float to copy from
  71590. * @param w float to copy from
  71591. * @returns the updated Vector4.
  71592. */
  71593. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71594. /**
  71595. * Updates the current Vector4 coordinates with the given floats.
  71596. * @param x float to set from
  71597. * @param y float to set from
  71598. * @param z float to set from
  71599. * @param w float to set from
  71600. * @returns the updated Vector4.
  71601. */
  71602. set(x: number, y: number, z: number, w: number): Vector4;
  71603. /**
  71604. * Copies the given float to the current Vector3 coordinates
  71605. * @param v defines the x, y, z and w coordinates of the operand
  71606. * @returns the current updated Vector3
  71607. */
  71608. setAll(v: number): Vector4;
  71609. /**
  71610. * Returns a new Vector4 set from the starting index of the given array.
  71611. * @param array the array to pull values from
  71612. * @param offset the offset into the array to start at
  71613. * @returns the new vector
  71614. */
  71615. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  71616. /**
  71617. * Updates the given vector "result" from the starting index of the given array.
  71618. * @param array the array to pull values from
  71619. * @param offset the offset into the array to start at
  71620. * @param result the vector to store the result in
  71621. */
  71622. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  71623. /**
  71624. * Updates the given vector "result" from the starting index of the given Float32Array.
  71625. * @param array the array to pull values from
  71626. * @param offset the offset into the array to start at
  71627. * @param result the vector to store the result in
  71628. */
  71629. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  71630. /**
  71631. * Updates the given vector "result" coordinates from the given floats.
  71632. * @param x float to set from
  71633. * @param y float to set from
  71634. * @param z float to set from
  71635. * @param w float to set from
  71636. * @param result the vector to the floats in
  71637. */
  71638. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  71639. /**
  71640. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  71641. * @returns the new vector
  71642. */
  71643. static Zero(): Vector4;
  71644. /**
  71645. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  71646. * @returns the new vector
  71647. */
  71648. static One(): Vector4;
  71649. /**
  71650. * Returns a new normalized Vector4 from the given one.
  71651. * @param vector the vector to normalize
  71652. * @returns the vector
  71653. */
  71654. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  71655. /**
  71656. * Updates the given vector "result" from the normalization of the given one.
  71657. * @param vector the vector to normalize
  71658. * @param result the vector to store the result in
  71659. */
  71660. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  71661. /**
  71662. * Returns a vector with the minimum values from the left and right vectors
  71663. * @param left left vector to minimize
  71664. * @param right right vector to minimize
  71665. * @returns a new vector with the minimum of the left and right vector values
  71666. */
  71667. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71668. /**
  71669. * Returns a vector with the maximum values from the left and right vectors
  71670. * @param left left vector to maximize
  71671. * @param right right vector to maximize
  71672. * @returns a new vector with the maximum of the left and right vector values
  71673. */
  71674. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71675. /**
  71676. * Returns the distance (float) between the vectors "value1" and "value2".
  71677. * @param value1 value to calulate the distance between
  71678. * @param value2 value to calulate the distance between
  71679. * @return the distance between the two vectors
  71680. */
  71681. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71682. /**
  71683. * Returns the squared distance (float) between the vectors "value1" and "value2".
  71684. * @param value1 value to calulate the distance between
  71685. * @param value2 value to calulate the distance between
  71686. * @return the distance between the two vectors squared
  71687. */
  71688. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71689. /**
  71690. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  71691. * @param value1 value to calulate the center between
  71692. * @param value2 value to calulate the center between
  71693. * @return the center between the two vectors
  71694. */
  71695. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  71696. /**
  71697. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  71698. * This methods computes transformed normalized direction vectors only.
  71699. * @param vector the vector to transform
  71700. * @param transformation the transformation matrix to apply
  71701. * @returns the new vector
  71702. */
  71703. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  71704. /**
  71705. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  71706. * This methods computes transformed normalized direction vectors only.
  71707. * @param vector the vector to transform
  71708. * @param transformation the transformation matrix to apply
  71709. * @param result the vector to store the result in
  71710. */
  71711. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71712. /**
  71713. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  71714. * This methods computes transformed normalized direction vectors only.
  71715. * @param x value to transform
  71716. * @param y value to transform
  71717. * @param z value to transform
  71718. * @param w value to transform
  71719. * @param transformation the transformation matrix to apply
  71720. * @param result the vector to store the results in
  71721. */
  71722. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71723. /**
  71724. * Creates a new Vector4 from a Vector3
  71725. * @param source defines the source data
  71726. * @param w defines the 4th component (default is 0)
  71727. * @returns a new Vector4
  71728. */
  71729. static FromVector3(source: Vector3, w?: number): Vector4;
  71730. }
  71731. /**
  71732. * Class used to store quaternion data
  71733. * @see https://en.wikipedia.org/wiki/Quaternion
  71734. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  71735. */
  71736. export class Quaternion {
  71737. /** defines the first component (0 by default) */
  71738. x: number;
  71739. /** defines the second component (0 by default) */
  71740. y: number;
  71741. /** defines the third component (0 by default) */
  71742. z: number;
  71743. /** defines the fourth component (1.0 by default) */
  71744. w: number;
  71745. /**
  71746. * Creates a new Quaternion from the given floats
  71747. * @param x defines the first component (0 by default)
  71748. * @param y defines the second component (0 by default)
  71749. * @param z defines the third component (0 by default)
  71750. * @param w defines the fourth component (1.0 by default)
  71751. */
  71752. constructor(
  71753. /** defines the first component (0 by default) */
  71754. x?: number,
  71755. /** defines the second component (0 by default) */
  71756. y?: number,
  71757. /** defines the third component (0 by default) */
  71758. z?: number,
  71759. /** defines the fourth component (1.0 by default) */
  71760. w?: number);
  71761. /**
  71762. * Gets a string representation for the current quaternion
  71763. * @returns a string with the Quaternion coordinates
  71764. */
  71765. toString(): string;
  71766. /**
  71767. * Gets the class name of the quaternion
  71768. * @returns the string "Quaternion"
  71769. */
  71770. getClassName(): string;
  71771. /**
  71772. * Gets a hash code for this quaternion
  71773. * @returns the quaternion hash code
  71774. */
  71775. getHashCode(): number;
  71776. /**
  71777. * Copy the quaternion to an array
  71778. * @returns a new array populated with 4 elements from the quaternion coordinates
  71779. */
  71780. asArray(): number[];
  71781. /**
  71782. * Check if two quaternions are equals
  71783. * @param otherQuaternion defines the second operand
  71784. * @return true if the current quaternion and the given one coordinates are strictly equals
  71785. */
  71786. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  71787. /**
  71788. * Clone the current quaternion
  71789. * @returns a new quaternion copied from the current one
  71790. */
  71791. clone(): Quaternion;
  71792. /**
  71793. * Copy a quaternion to the current one
  71794. * @param other defines the other quaternion
  71795. * @returns the updated current quaternion
  71796. */
  71797. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  71798. /**
  71799. * Updates the current quaternion with the given float coordinates
  71800. * @param x defines the x coordinate
  71801. * @param y defines the y coordinate
  71802. * @param z defines the z coordinate
  71803. * @param w defines the w coordinate
  71804. * @returns the updated current quaternion
  71805. */
  71806. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  71807. /**
  71808. * Updates the current quaternion from the given float coordinates
  71809. * @param x defines the x coordinate
  71810. * @param y defines the y coordinate
  71811. * @param z defines the z coordinate
  71812. * @param w defines the w coordinate
  71813. * @returns the updated current quaternion
  71814. */
  71815. set(x: number, y: number, z: number, w: number): Quaternion;
  71816. /**
  71817. * Adds two quaternions
  71818. * @param other defines the second operand
  71819. * @returns a new quaternion as the addition result of the given one and the current quaternion
  71820. */
  71821. add(other: DeepImmutable<Quaternion>): Quaternion;
  71822. /**
  71823. * Add a quaternion to the current one
  71824. * @param other defines the quaternion to add
  71825. * @returns the current quaternion
  71826. */
  71827. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  71828. /**
  71829. * Subtract two quaternions
  71830. * @param other defines the second operand
  71831. * @returns a new quaternion as the subtraction result of the given one from the current one
  71832. */
  71833. subtract(other: Quaternion): Quaternion;
  71834. /**
  71835. * Multiplies the current quaternion by a scale factor
  71836. * @param value defines the scale factor
  71837. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  71838. */
  71839. scale(value: number): Quaternion;
  71840. /**
  71841. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  71842. * @param scale defines the scale factor
  71843. * @param result defines the Quaternion object where to store the result
  71844. * @returns the unmodified current quaternion
  71845. */
  71846. scaleToRef(scale: number, result: Quaternion): Quaternion;
  71847. /**
  71848. * Multiplies in place the current quaternion by a scale factor
  71849. * @param value defines the scale factor
  71850. * @returns the current modified quaternion
  71851. */
  71852. scaleInPlace(value: number): Quaternion;
  71853. /**
  71854. * Scale the current quaternion values by a factor and add the result to a given quaternion
  71855. * @param scale defines the scale factor
  71856. * @param result defines the Quaternion object where to store the result
  71857. * @returns the unmodified current quaternion
  71858. */
  71859. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  71860. /**
  71861. * Multiplies two quaternions
  71862. * @param q1 defines the second operand
  71863. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  71864. */
  71865. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  71866. /**
  71867. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  71868. * @param q1 defines the second operand
  71869. * @param result defines the target quaternion
  71870. * @returns the current quaternion
  71871. */
  71872. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  71873. /**
  71874. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  71875. * @param q1 defines the second operand
  71876. * @returns the currentupdated quaternion
  71877. */
  71878. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  71879. /**
  71880. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  71881. * @param ref defines the target quaternion
  71882. * @returns the current quaternion
  71883. */
  71884. conjugateToRef(ref: Quaternion): Quaternion;
  71885. /**
  71886. * Conjugates in place (1-q) the current quaternion
  71887. * @returns the current updated quaternion
  71888. */
  71889. conjugateInPlace(): Quaternion;
  71890. /**
  71891. * Conjugates in place (1-q) the current quaternion
  71892. * @returns a new quaternion
  71893. */
  71894. conjugate(): Quaternion;
  71895. /**
  71896. * Gets length of current quaternion
  71897. * @returns the quaternion length (float)
  71898. */
  71899. length(): number;
  71900. /**
  71901. * Normalize in place the current quaternion
  71902. * @returns the current updated quaternion
  71903. */
  71904. normalize(): Quaternion;
  71905. /**
  71906. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71907. * @param order is a reserved parameter and is ignore for now
  71908. * @returns a new Vector3 containing the Euler angles
  71909. */
  71910. toEulerAngles(order?: string): Vector3;
  71911. /**
  71912. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  71913. * @param result defines the vector which will be filled with the Euler angles
  71914. * @param order is a reserved parameter and is ignore for now
  71915. * @returns the current unchanged quaternion
  71916. */
  71917. toEulerAnglesToRef(result: Vector3): Quaternion;
  71918. /**
  71919. * Updates the given rotation matrix with the current quaternion values
  71920. * @param result defines the target matrix
  71921. * @returns the current unchanged quaternion
  71922. */
  71923. toRotationMatrix(result: Matrix): Quaternion;
  71924. /**
  71925. * Updates the current quaternion from the given rotation matrix values
  71926. * @param matrix defines the source matrix
  71927. * @returns the current updated quaternion
  71928. */
  71929. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71930. /**
  71931. * Creates a new quaternion from a rotation matrix
  71932. * @param matrix defines the source matrix
  71933. * @returns a new quaternion created from the given rotation matrix values
  71934. */
  71935. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71936. /**
  71937. * Updates the given quaternion with the given rotation matrix values
  71938. * @param matrix defines the source matrix
  71939. * @param result defines the target quaternion
  71940. */
  71941. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  71942. /**
  71943. * Returns the dot product (float) between the quaternions "left" and "right"
  71944. * @param left defines the left operand
  71945. * @param right defines the right operand
  71946. * @returns the dot product
  71947. */
  71948. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  71949. /**
  71950. * Checks if the two quaternions are close to each other
  71951. * @param quat0 defines the first quaternion to check
  71952. * @param quat1 defines the second quaternion to check
  71953. * @returns true if the two quaternions are close to each other
  71954. */
  71955. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  71956. /**
  71957. * Creates an empty quaternion
  71958. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  71959. */
  71960. static Zero(): Quaternion;
  71961. /**
  71962. * Inverse a given quaternion
  71963. * @param q defines the source quaternion
  71964. * @returns a new quaternion as the inverted current quaternion
  71965. */
  71966. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  71967. /**
  71968. * Inverse a given quaternion
  71969. * @param q defines the source quaternion
  71970. * @param result the quaternion the result will be stored in
  71971. * @returns the result quaternion
  71972. */
  71973. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  71974. /**
  71975. * Creates an identity quaternion
  71976. * @returns the identity quaternion
  71977. */
  71978. static Identity(): Quaternion;
  71979. /**
  71980. * Gets a boolean indicating if the given quaternion is identity
  71981. * @param quaternion defines the quaternion to check
  71982. * @returns true if the quaternion is identity
  71983. */
  71984. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  71985. /**
  71986. * Creates a quaternion from a rotation around an axis
  71987. * @param axis defines the axis to use
  71988. * @param angle defines the angle to use
  71989. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  71990. */
  71991. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  71992. /**
  71993. * Creates a rotation around an axis and stores it into the given quaternion
  71994. * @param axis defines the axis to use
  71995. * @param angle defines the angle to use
  71996. * @param result defines the target quaternion
  71997. * @returns the target quaternion
  71998. */
  71999. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  72000. /**
  72001. * Creates a new quaternion from data stored into an array
  72002. * @param array defines the data source
  72003. * @param offset defines the offset in the source array where the data starts
  72004. * @returns a new quaternion
  72005. */
  72006. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  72007. /**
  72008. * Create a quaternion from Euler rotation angles
  72009. * @param x Pitch
  72010. * @param y Yaw
  72011. * @param z Roll
  72012. * @returns the new Quaternion
  72013. */
  72014. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  72015. /**
  72016. * Updates a quaternion from Euler rotation angles
  72017. * @param x Pitch
  72018. * @param y Yaw
  72019. * @param z Roll
  72020. * @param result the quaternion to store the result
  72021. * @returns the updated quaternion
  72022. */
  72023. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  72024. /**
  72025. * Create a quaternion from Euler rotation vector
  72026. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  72027. * @returns the new Quaternion
  72028. */
  72029. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  72030. /**
  72031. * Updates a quaternion from Euler rotation vector
  72032. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  72033. * @param result the quaternion to store the result
  72034. * @returns the updated quaternion
  72035. */
  72036. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  72037. /**
  72038. * Creates a new quaternion from the given Euler float angles (y, x, z)
  72039. * @param yaw defines the rotation around Y axis
  72040. * @param pitch defines the rotation around X axis
  72041. * @param roll defines the rotation around Z axis
  72042. * @returns the new quaternion
  72043. */
  72044. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  72045. /**
  72046. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  72047. * @param yaw defines the rotation around Y axis
  72048. * @param pitch defines the rotation around X axis
  72049. * @param roll defines the rotation around Z axis
  72050. * @param result defines the target quaternion
  72051. */
  72052. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  72053. /**
  72054. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  72055. * @param alpha defines the rotation around first axis
  72056. * @param beta defines the rotation around second axis
  72057. * @param gamma defines the rotation around third axis
  72058. * @returns the new quaternion
  72059. */
  72060. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  72061. /**
  72062. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  72063. * @param alpha defines the rotation around first axis
  72064. * @param beta defines the rotation around second axis
  72065. * @param gamma defines the rotation around third axis
  72066. * @param result defines the target quaternion
  72067. */
  72068. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  72069. /**
  72070. * 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)
  72071. * @param axis1 defines the first axis
  72072. * @param axis2 defines the second axis
  72073. * @param axis3 defines the third axis
  72074. * @returns the new quaternion
  72075. */
  72076. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  72077. /**
  72078. * 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
  72079. * @param axis1 defines the first axis
  72080. * @param axis2 defines the second axis
  72081. * @param axis3 defines the third axis
  72082. * @param ref defines the target quaternion
  72083. */
  72084. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  72085. /**
  72086. * Interpolates between two quaternions
  72087. * @param left defines first quaternion
  72088. * @param right defines second quaternion
  72089. * @param amount defines the gradient to use
  72090. * @returns the new interpolated quaternion
  72091. */
  72092. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  72093. /**
  72094. * Interpolates between two quaternions and stores it into a target quaternion
  72095. * @param left defines first quaternion
  72096. * @param right defines second quaternion
  72097. * @param amount defines the gradient to use
  72098. * @param result defines the target quaternion
  72099. */
  72100. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  72101. /**
  72102. * Interpolate between two quaternions using Hermite interpolation
  72103. * @param value1 defines first quaternion
  72104. * @param tangent1 defines the incoming tangent
  72105. * @param value2 defines second quaternion
  72106. * @param tangent2 defines the outgoing tangent
  72107. * @param amount defines the target quaternion
  72108. * @returns the new interpolated quaternion
  72109. */
  72110. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  72111. }
  72112. /**
  72113. * Class used to store matrix data (4x4)
  72114. */
  72115. export class Matrix {
  72116. private static _updateFlagSeed;
  72117. private static _identityReadOnly;
  72118. private _isIdentity;
  72119. private _isIdentityDirty;
  72120. private _isIdentity3x2;
  72121. private _isIdentity3x2Dirty;
  72122. /**
  72123. * Gets the update flag of the matrix which is an unique number for the matrix.
  72124. * It will be incremented every time the matrix data change.
  72125. * You can use it to speed the comparison between two versions of the same matrix.
  72126. */
  72127. updateFlag: number;
  72128. private readonly _m;
  72129. /**
  72130. * Gets the internal data of the matrix
  72131. */
  72132. readonly m: DeepImmutable<Float32Array>;
  72133. /** @hidden */
  72134. _markAsUpdated(): void;
  72135. /** @hidden */
  72136. private _updateIdentityStatus;
  72137. /**
  72138. * Creates an empty matrix (filled with zeros)
  72139. */
  72140. constructor();
  72141. /**
  72142. * Check if the current matrix is identity
  72143. * @returns true is the matrix is the identity matrix
  72144. */
  72145. isIdentity(): boolean;
  72146. /**
  72147. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  72148. * @returns true is the matrix is the identity matrix
  72149. */
  72150. isIdentityAs3x2(): boolean;
  72151. /**
  72152. * Gets the determinant of the matrix
  72153. * @returns the matrix determinant
  72154. */
  72155. determinant(): number;
  72156. /**
  72157. * Returns the matrix as a Float32Array
  72158. * @returns the matrix underlying array
  72159. */
  72160. toArray(): DeepImmutable<Float32Array>;
  72161. /**
  72162. * Returns the matrix as a Float32Array
  72163. * @returns the matrix underlying array.
  72164. */
  72165. asArray(): DeepImmutable<Float32Array>;
  72166. /**
  72167. * Inverts the current matrix in place
  72168. * @returns the current inverted matrix
  72169. */
  72170. invert(): Matrix;
  72171. /**
  72172. * Sets all the matrix elements to zero
  72173. * @returns the current matrix
  72174. */
  72175. reset(): Matrix;
  72176. /**
  72177. * Adds the current matrix with a second one
  72178. * @param other defines the matrix to add
  72179. * @returns a new matrix as the addition of the current matrix and the given one
  72180. */
  72181. add(other: DeepImmutable<Matrix>): Matrix;
  72182. /**
  72183. * Sets the given matrix "result" to the addition of the current matrix and the given one
  72184. * @param other defines the matrix to add
  72185. * @param result defines the target matrix
  72186. * @returns the current matrix
  72187. */
  72188. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72189. /**
  72190. * Adds in place the given matrix to the current matrix
  72191. * @param other defines the second operand
  72192. * @returns the current updated matrix
  72193. */
  72194. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  72195. /**
  72196. * Sets the given matrix to the current inverted Matrix
  72197. * @param other defines the target matrix
  72198. * @returns the unmodified current matrix
  72199. */
  72200. invertToRef(other: Matrix): Matrix;
  72201. /**
  72202. * add a value at the specified position in the current Matrix
  72203. * @param index the index of the value within the matrix. between 0 and 15.
  72204. * @param value the value to be added
  72205. * @returns the current updated matrix
  72206. */
  72207. addAtIndex(index: number, value: number): Matrix;
  72208. /**
  72209. * mutiply the specified position in the current Matrix by a value
  72210. * @param index the index of the value within the matrix. between 0 and 15.
  72211. * @param value the value to be added
  72212. * @returns the current updated matrix
  72213. */
  72214. multiplyAtIndex(index: number, value: number): Matrix;
  72215. /**
  72216. * Inserts the translation vector (using 3 floats) in the current matrix
  72217. * @param x defines the 1st component of the translation
  72218. * @param y defines the 2nd component of the translation
  72219. * @param z defines the 3rd component of the translation
  72220. * @returns the current updated matrix
  72221. */
  72222. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72223. /**
  72224. * Adds the translation vector (using 3 floats) in the current matrix
  72225. * @param x defines the 1st component of the translation
  72226. * @param y defines the 2nd component of the translation
  72227. * @param z defines the 3rd component of the translation
  72228. * @returns the current updated matrix
  72229. */
  72230. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72231. /**
  72232. * Inserts the translation vector in the current matrix
  72233. * @param vector3 defines the translation to insert
  72234. * @returns the current updated matrix
  72235. */
  72236. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  72237. /**
  72238. * Gets the translation value of the current matrix
  72239. * @returns a new Vector3 as the extracted translation from the matrix
  72240. */
  72241. getTranslation(): Vector3;
  72242. /**
  72243. * Fill a Vector3 with the extracted translation from the matrix
  72244. * @param result defines the Vector3 where to store the translation
  72245. * @returns the current matrix
  72246. */
  72247. getTranslationToRef(result: Vector3): Matrix;
  72248. /**
  72249. * Remove rotation and scaling part from the matrix
  72250. * @returns the updated matrix
  72251. */
  72252. removeRotationAndScaling(): Matrix;
  72253. /**
  72254. * Multiply two matrices
  72255. * @param other defines the second operand
  72256. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  72257. */
  72258. multiply(other: DeepImmutable<Matrix>): Matrix;
  72259. /**
  72260. * Copy the current matrix from the given one
  72261. * @param other defines the source matrix
  72262. * @returns the current updated matrix
  72263. */
  72264. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  72265. /**
  72266. * Populates the given array from the starting index with the current matrix values
  72267. * @param array defines the target array
  72268. * @param offset defines the offset in the target array where to start storing values
  72269. * @returns the current matrix
  72270. */
  72271. copyToArray(array: Float32Array, offset?: number): Matrix;
  72272. /**
  72273. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  72274. * @param other defines the second operand
  72275. * @param result defines the matrix where to store the multiplication
  72276. * @returns the current matrix
  72277. */
  72278. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72279. /**
  72280. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  72281. * @param other defines the second operand
  72282. * @param result defines the array where to store the multiplication
  72283. * @param offset defines the offset in the target array where to start storing values
  72284. * @returns the current matrix
  72285. */
  72286. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  72287. /**
  72288. * Check equality between this matrix and a second one
  72289. * @param value defines the second matrix to compare
  72290. * @returns true is the current matrix and the given one values are strictly equal
  72291. */
  72292. equals(value: DeepImmutable<Matrix>): boolean;
  72293. /**
  72294. * Clone the current matrix
  72295. * @returns a new matrix from the current matrix
  72296. */
  72297. clone(): Matrix;
  72298. /**
  72299. * Returns the name of the current matrix class
  72300. * @returns the string "Matrix"
  72301. */
  72302. getClassName(): string;
  72303. /**
  72304. * Gets the hash code of the current matrix
  72305. * @returns the hash code
  72306. */
  72307. getHashCode(): number;
  72308. /**
  72309. * Decomposes the current Matrix into a translation, rotation and scaling components
  72310. * @param scale defines the scale vector3 given as a reference to update
  72311. * @param rotation defines the rotation quaternion given as a reference to update
  72312. * @param translation defines the translation vector3 given as a reference to update
  72313. * @returns true if operation was successful
  72314. */
  72315. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  72316. /**
  72317. * Gets specific row of the matrix
  72318. * @param index defines the number of the row to get
  72319. * @returns the index-th row of the current matrix as a new Vector4
  72320. */
  72321. getRow(index: number): Nullable<Vector4>;
  72322. /**
  72323. * Sets the index-th row of the current matrix to the vector4 values
  72324. * @param index defines the number of the row to set
  72325. * @param row defines the target vector4
  72326. * @returns the updated current matrix
  72327. */
  72328. setRow(index: number, row: Vector4): Matrix;
  72329. /**
  72330. * Compute the transpose of the matrix
  72331. * @returns the new transposed matrix
  72332. */
  72333. transpose(): Matrix;
  72334. /**
  72335. * Compute the transpose of the matrix and store it in a given matrix
  72336. * @param result defines the target matrix
  72337. * @returns the current matrix
  72338. */
  72339. transposeToRef(result: Matrix): Matrix;
  72340. /**
  72341. * Sets the index-th row of the current matrix with the given 4 x float values
  72342. * @param index defines the row index
  72343. * @param x defines the x component to set
  72344. * @param y defines the y component to set
  72345. * @param z defines the z component to set
  72346. * @param w defines the w component to set
  72347. * @returns the updated current matrix
  72348. */
  72349. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  72350. /**
  72351. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  72352. * @param scale defines the scale factor
  72353. * @returns a new matrix
  72354. */
  72355. scale(scale: number): Matrix;
  72356. /**
  72357. * Scale the current matrix values by a factor to a given result matrix
  72358. * @param scale defines the scale factor
  72359. * @param result defines the matrix to store the result
  72360. * @returns the current matrix
  72361. */
  72362. scaleToRef(scale: number, result: Matrix): Matrix;
  72363. /**
  72364. * Scale the current matrix values by a factor and add the result to a given matrix
  72365. * @param scale defines the scale factor
  72366. * @param result defines the Matrix to store the result
  72367. * @returns the current matrix
  72368. */
  72369. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  72370. /**
  72371. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  72372. * @param ref matrix to store the result
  72373. */
  72374. toNormalMatrix(ref: Matrix): void;
  72375. /**
  72376. * Gets only rotation part of the current matrix
  72377. * @returns a new matrix sets to the extracted rotation matrix from the current one
  72378. */
  72379. getRotationMatrix(): Matrix;
  72380. /**
  72381. * Extracts the rotation matrix from the current one and sets it as the given "result"
  72382. * @param result defines the target matrix to store data to
  72383. * @returns the current matrix
  72384. */
  72385. getRotationMatrixToRef(result: Matrix): Matrix;
  72386. /**
  72387. * Toggles model matrix from being right handed to left handed in place and vice versa
  72388. */
  72389. toggleModelMatrixHandInPlace(): void;
  72390. /**
  72391. * Toggles projection matrix from being right handed to left handed in place and vice versa
  72392. */
  72393. toggleProjectionMatrixHandInPlace(): void;
  72394. /**
  72395. * Creates a matrix from an array
  72396. * @param array defines the source array
  72397. * @param offset defines an offset in the source array
  72398. * @returns a new Matrix set from the starting index of the given array
  72399. */
  72400. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  72401. /**
  72402. * Copy the content of an array into a given matrix
  72403. * @param array defines the source array
  72404. * @param offset defines an offset in the source array
  72405. * @param result defines the target matrix
  72406. */
  72407. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  72408. /**
  72409. * Stores an array into a matrix after having multiplied each component by a given factor
  72410. * @param array defines the source array
  72411. * @param offset defines the offset in the source array
  72412. * @param scale defines the scaling factor
  72413. * @param result defines the target matrix
  72414. */
  72415. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  72416. /**
  72417. * Gets an identity matrix that must not be updated
  72418. */
  72419. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  72420. /**
  72421. * Stores a list of values (16) inside a given matrix
  72422. * @param initialM11 defines 1st value of 1st row
  72423. * @param initialM12 defines 2nd value of 1st row
  72424. * @param initialM13 defines 3rd value of 1st row
  72425. * @param initialM14 defines 4th value of 1st row
  72426. * @param initialM21 defines 1st value of 2nd row
  72427. * @param initialM22 defines 2nd value of 2nd row
  72428. * @param initialM23 defines 3rd value of 2nd row
  72429. * @param initialM24 defines 4th value of 2nd row
  72430. * @param initialM31 defines 1st value of 3rd row
  72431. * @param initialM32 defines 2nd value of 3rd row
  72432. * @param initialM33 defines 3rd value of 3rd row
  72433. * @param initialM34 defines 4th value of 3rd row
  72434. * @param initialM41 defines 1st value of 4th row
  72435. * @param initialM42 defines 2nd value of 4th row
  72436. * @param initialM43 defines 3rd value of 4th row
  72437. * @param initialM44 defines 4th value of 4th row
  72438. * @param result defines the target matrix
  72439. */
  72440. 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;
  72441. /**
  72442. * Creates new matrix from a list of values (16)
  72443. * @param initialM11 defines 1st value of 1st row
  72444. * @param initialM12 defines 2nd value of 1st row
  72445. * @param initialM13 defines 3rd value of 1st row
  72446. * @param initialM14 defines 4th value of 1st row
  72447. * @param initialM21 defines 1st value of 2nd row
  72448. * @param initialM22 defines 2nd value of 2nd row
  72449. * @param initialM23 defines 3rd value of 2nd row
  72450. * @param initialM24 defines 4th value of 2nd row
  72451. * @param initialM31 defines 1st value of 3rd row
  72452. * @param initialM32 defines 2nd value of 3rd row
  72453. * @param initialM33 defines 3rd value of 3rd row
  72454. * @param initialM34 defines 4th value of 3rd row
  72455. * @param initialM41 defines 1st value of 4th row
  72456. * @param initialM42 defines 2nd value of 4th row
  72457. * @param initialM43 defines 3rd value of 4th row
  72458. * @param initialM44 defines 4th value of 4th row
  72459. * @returns the new matrix
  72460. */
  72461. 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;
  72462. /**
  72463. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72464. * @param scale defines the scale vector3
  72465. * @param rotation defines the rotation quaternion
  72466. * @param translation defines the translation vector3
  72467. * @returns a new matrix
  72468. */
  72469. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  72470. /**
  72471. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72472. * @param scale defines the scale vector3
  72473. * @param rotation defines the rotation quaternion
  72474. * @param translation defines the translation vector3
  72475. * @param result defines the target matrix
  72476. */
  72477. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  72478. /**
  72479. * Creates a new identity matrix
  72480. * @returns a new identity matrix
  72481. */
  72482. static Identity(): Matrix;
  72483. /**
  72484. * Creates a new identity matrix and stores the result in a given matrix
  72485. * @param result defines the target matrix
  72486. */
  72487. static IdentityToRef(result: Matrix): void;
  72488. /**
  72489. * Creates a new zero matrix
  72490. * @returns a new zero matrix
  72491. */
  72492. static Zero(): Matrix;
  72493. /**
  72494. * Creates a new rotation matrix for "angle" radians around the X axis
  72495. * @param angle defines the angle (in radians) to use
  72496. * @return the new matrix
  72497. */
  72498. static RotationX(angle: number): Matrix;
  72499. /**
  72500. * Creates a new matrix as the invert of a given matrix
  72501. * @param source defines the source matrix
  72502. * @returns the new matrix
  72503. */
  72504. static Invert(source: DeepImmutable<Matrix>): Matrix;
  72505. /**
  72506. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  72507. * @param angle defines the angle (in radians) to use
  72508. * @param result defines the target matrix
  72509. */
  72510. static RotationXToRef(angle: number, result: Matrix): void;
  72511. /**
  72512. * Creates a new rotation matrix for "angle" radians around the Y axis
  72513. * @param angle defines the angle (in radians) to use
  72514. * @return the new matrix
  72515. */
  72516. static RotationY(angle: number): Matrix;
  72517. /**
  72518. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  72519. * @param angle defines the angle (in radians) to use
  72520. * @param result defines the target matrix
  72521. */
  72522. static RotationYToRef(angle: number, result: Matrix): void;
  72523. /**
  72524. * Creates a new rotation matrix for "angle" radians around the Z axis
  72525. * @param angle defines the angle (in radians) to use
  72526. * @return the new matrix
  72527. */
  72528. static RotationZ(angle: number): Matrix;
  72529. /**
  72530. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  72531. * @param angle defines the angle (in radians) to use
  72532. * @param result defines the target matrix
  72533. */
  72534. static RotationZToRef(angle: number, result: Matrix): void;
  72535. /**
  72536. * Creates a new rotation matrix for "angle" radians around the given axis
  72537. * @param axis defines the axis to use
  72538. * @param angle defines the angle (in radians) to use
  72539. * @return the new matrix
  72540. */
  72541. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  72542. /**
  72543. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  72544. * @param axis defines the axis to use
  72545. * @param angle defines the angle (in radians) to use
  72546. * @param result defines the target matrix
  72547. */
  72548. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  72549. /**
  72550. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  72551. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  72552. * @param from defines the vector to align
  72553. * @param to defines the vector to align to
  72554. * @param result defines the target matrix
  72555. */
  72556. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  72557. /**
  72558. * Creates a rotation matrix
  72559. * @param yaw defines the yaw angle in radians (Y axis)
  72560. * @param pitch defines the pitch angle in radians (X axis)
  72561. * @param roll defines the roll angle in radians (X axis)
  72562. * @returns the new rotation matrix
  72563. */
  72564. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  72565. /**
  72566. * Creates a rotation matrix and stores it in a given matrix
  72567. * @param yaw defines the yaw angle in radians (Y axis)
  72568. * @param pitch defines the pitch angle in radians (X axis)
  72569. * @param roll defines the roll angle in radians (X axis)
  72570. * @param result defines the target matrix
  72571. */
  72572. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  72573. /**
  72574. * Creates a scaling matrix
  72575. * @param x defines the scale factor on X axis
  72576. * @param y defines the scale factor on Y axis
  72577. * @param z defines the scale factor on Z axis
  72578. * @returns the new matrix
  72579. */
  72580. static Scaling(x: number, y: number, z: number): Matrix;
  72581. /**
  72582. * Creates a scaling matrix and stores it in a given matrix
  72583. * @param x defines the scale factor on X axis
  72584. * @param y defines the scale factor on Y axis
  72585. * @param z defines the scale factor on Z axis
  72586. * @param result defines the target matrix
  72587. */
  72588. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  72589. /**
  72590. * Creates a translation matrix
  72591. * @param x defines the translation on X axis
  72592. * @param y defines the translation on Y axis
  72593. * @param z defines the translationon Z axis
  72594. * @returns the new matrix
  72595. */
  72596. static Translation(x: number, y: number, z: number): Matrix;
  72597. /**
  72598. * Creates a translation matrix and stores it in a given matrix
  72599. * @param x defines the translation on X axis
  72600. * @param y defines the translation on Y axis
  72601. * @param z defines the translationon Z axis
  72602. * @param result defines the target matrix
  72603. */
  72604. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  72605. /**
  72606. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72607. * @param startValue defines the start value
  72608. * @param endValue defines the end value
  72609. * @param gradient defines the gradient factor
  72610. * @returns the new matrix
  72611. */
  72612. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72613. /**
  72614. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72615. * @param startValue defines the start value
  72616. * @param endValue defines the end value
  72617. * @param gradient defines the gradient factor
  72618. * @param result defines the Matrix object where to store data
  72619. */
  72620. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72621. /**
  72622. * Builds a new matrix whose values are computed by:
  72623. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72624. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72625. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72626. * @param startValue defines the first matrix
  72627. * @param endValue defines the second matrix
  72628. * @param gradient defines the gradient between the two matrices
  72629. * @returns the new matrix
  72630. */
  72631. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72632. /**
  72633. * Update a matrix to values which are computed by:
  72634. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72635. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72636. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72637. * @param startValue defines the first matrix
  72638. * @param endValue defines the second matrix
  72639. * @param gradient defines the gradient between the two matrices
  72640. * @param result defines the target matrix
  72641. */
  72642. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72643. /**
  72644. * 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"
  72645. * This function works in left handed mode
  72646. * @param eye defines the final position of the entity
  72647. * @param target defines where the entity should look at
  72648. * @param up defines the up vector for the entity
  72649. * @returns the new matrix
  72650. */
  72651. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72652. /**
  72653. * 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".
  72654. * This function works in left handed mode
  72655. * @param eye defines the final position of the entity
  72656. * @param target defines where the entity should look at
  72657. * @param up defines the up vector for the entity
  72658. * @param result defines the target matrix
  72659. */
  72660. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72661. /**
  72662. * 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"
  72663. * This function works in right handed mode
  72664. * @param eye defines the final position of the entity
  72665. * @param target defines where the entity should look at
  72666. * @param up defines the up vector for the entity
  72667. * @returns the new matrix
  72668. */
  72669. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72670. /**
  72671. * 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".
  72672. * This function works in right handed mode
  72673. * @param eye defines the final position of the entity
  72674. * @param target defines where the entity should look at
  72675. * @param up defines the up vector for the entity
  72676. * @param result defines the target matrix
  72677. */
  72678. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72679. /**
  72680. * Create a left-handed orthographic projection matrix
  72681. * @param width defines the viewport width
  72682. * @param height defines the viewport height
  72683. * @param znear defines the near clip plane
  72684. * @param zfar defines the far clip plane
  72685. * @returns a new matrix as a left-handed orthographic projection matrix
  72686. */
  72687. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72688. /**
  72689. * Store a left-handed orthographic projection to a given matrix
  72690. * @param width defines the viewport width
  72691. * @param height defines the viewport height
  72692. * @param znear defines the near clip plane
  72693. * @param zfar defines the far clip plane
  72694. * @param result defines the target matrix
  72695. */
  72696. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  72697. /**
  72698. * Create a left-handed orthographic projection matrix
  72699. * @param left defines the viewport left coordinate
  72700. * @param right defines the viewport right coordinate
  72701. * @param bottom defines the viewport bottom coordinate
  72702. * @param top defines the viewport top coordinate
  72703. * @param znear defines the near clip plane
  72704. * @param zfar defines the far clip plane
  72705. * @returns a new matrix as a left-handed orthographic projection matrix
  72706. */
  72707. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72708. /**
  72709. * Stores a left-handed orthographic projection into a given matrix
  72710. * @param left defines the viewport left coordinate
  72711. * @param right defines the viewport right coordinate
  72712. * @param bottom defines the viewport bottom coordinate
  72713. * @param top defines the viewport top coordinate
  72714. * @param znear defines the near clip plane
  72715. * @param zfar defines the far clip plane
  72716. * @param result defines the target matrix
  72717. */
  72718. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72719. /**
  72720. * Creates a right-handed orthographic projection matrix
  72721. * @param left defines the viewport left coordinate
  72722. * @param right defines the viewport right coordinate
  72723. * @param bottom defines the viewport bottom coordinate
  72724. * @param top defines the viewport top coordinate
  72725. * @param znear defines the near clip plane
  72726. * @param zfar defines the far clip plane
  72727. * @returns a new matrix as a right-handed orthographic projection matrix
  72728. */
  72729. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72730. /**
  72731. * Stores a right-handed orthographic projection into a given matrix
  72732. * @param left defines the viewport left coordinate
  72733. * @param right defines the viewport right coordinate
  72734. * @param bottom defines the viewport bottom coordinate
  72735. * @param top defines the viewport top coordinate
  72736. * @param znear defines the near clip plane
  72737. * @param zfar defines the far clip plane
  72738. * @param result defines the target matrix
  72739. */
  72740. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72741. /**
  72742. * Creates a left-handed perspective projection matrix
  72743. * @param width defines the viewport width
  72744. * @param height defines the viewport height
  72745. * @param znear defines the near clip plane
  72746. * @param zfar defines the far clip plane
  72747. * @returns a new matrix as a left-handed perspective projection matrix
  72748. */
  72749. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72750. /**
  72751. * Creates a left-handed perspective projection matrix
  72752. * @param fov defines the horizontal field of view
  72753. * @param aspect defines the aspect ratio
  72754. * @param znear defines the near clip plane
  72755. * @param zfar defines the far clip plane
  72756. * @returns a new matrix as a left-handed perspective projection matrix
  72757. */
  72758. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72759. /**
  72760. * Stores a left-handed perspective projection into a given matrix
  72761. * @param fov defines the horizontal field of view
  72762. * @param aspect defines the aspect ratio
  72763. * @param znear defines the near clip plane
  72764. * @param zfar defines the far clip plane
  72765. * @param result defines the target matrix
  72766. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72767. */
  72768. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72769. /**
  72770. * Creates a right-handed perspective projection matrix
  72771. * @param fov defines the horizontal field of view
  72772. * @param aspect defines the aspect ratio
  72773. * @param znear defines the near clip plane
  72774. * @param zfar defines the far clip plane
  72775. * @returns a new matrix as a right-handed perspective projection matrix
  72776. */
  72777. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72778. /**
  72779. * Stores a right-handed perspective projection into a given matrix
  72780. * @param fov defines the horizontal field of view
  72781. * @param aspect defines the aspect ratio
  72782. * @param znear defines the near clip plane
  72783. * @param zfar defines the far clip plane
  72784. * @param result defines the target matrix
  72785. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72786. */
  72787. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72788. /**
  72789. * Stores a perspective projection for WebVR info a given matrix
  72790. * @param fov defines the field of view
  72791. * @param znear defines the near clip plane
  72792. * @param zfar defines the far clip plane
  72793. * @param result defines the target matrix
  72794. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  72795. */
  72796. static PerspectiveFovWebVRToRef(fov: {
  72797. upDegrees: number;
  72798. downDegrees: number;
  72799. leftDegrees: number;
  72800. rightDegrees: number;
  72801. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  72802. /**
  72803. * Computes a complete transformation matrix
  72804. * @param viewport defines the viewport to use
  72805. * @param world defines the world matrix
  72806. * @param view defines the view matrix
  72807. * @param projection defines the projection matrix
  72808. * @param zmin defines the near clip plane
  72809. * @param zmax defines the far clip plane
  72810. * @returns the transformation matrix
  72811. */
  72812. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  72813. /**
  72814. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  72815. * @param matrix defines the matrix to use
  72816. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  72817. */
  72818. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  72819. /**
  72820. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  72821. * @param matrix defines the matrix to use
  72822. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  72823. */
  72824. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  72825. /**
  72826. * Compute the transpose of a given matrix
  72827. * @param matrix defines the matrix to transpose
  72828. * @returns the new matrix
  72829. */
  72830. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  72831. /**
  72832. * Compute the transpose of a matrix and store it in a target matrix
  72833. * @param matrix defines the matrix to transpose
  72834. * @param result defines the target matrix
  72835. */
  72836. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  72837. /**
  72838. * Computes a reflection matrix from a plane
  72839. * @param plane defines the reflection plane
  72840. * @returns a new matrix
  72841. */
  72842. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  72843. /**
  72844. * Computes a reflection matrix from a plane
  72845. * @param plane defines the reflection plane
  72846. * @param result defines the target matrix
  72847. */
  72848. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  72849. /**
  72850. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  72851. * @param xaxis defines the value of the 1st axis
  72852. * @param yaxis defines the value of the 2nd axis
  72853. * @param zaxis defines the value of the 3rd axis
  72854. * @param result defines the target matrix
  72855. */
  72856. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  72857. /**
  72858. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  72859. * @param quat defines the quaternion to use
  72860. * @param result defines the target matrix
  72861. */
  72862. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  72863. }
  72864. /**
  72865. * @hidden
  72866. */
  72867. export class TmpVectors {
  72868. static Vector2: Vector2[];
  72869. static Vector3: Vector3[];
  72870. static Vector4: Vector4[];
  72871. static Quaternion: Quaternion[];
  72872. static Matrix: Matrix[];
  72873. }
  72874. }
  72875. declare module BABYLON {
  72876. /**
  72877. * Defines potential orientation for back face culling
  72878. */
  72879. export enum Orientation {
  72880. /**
  72881. * Clockwise
  72882. */
  72883. CW = 0,
  72884. /** Counter clockwise */
  72885. CCW = 1
  72886. }
  72887. /** Class used to represent a Bezier curve */
  72888. export class BezierCurve {
  72889. /**
  72890. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  72891. * @param t defines the time
  72892. * @param x1 defines the left coordinate on X axis
  72893. * @param y1 defines the left coordinate on Y axis
  72894. * @param x2 defines the right coordinate on X axis
  72895. * @param y2 defines the right coordinate on Y axis
  72896. * @returns the interpolated value
  72897. */
  72898. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  72899. }
  72900. /**
  72901. * Defines angle representation
  72902. */
  72903. export class Angle {
  72904. private _radians;
  72905. /**
  72906. * Creates an Angle object of "radians" radians (float).
  72907. * @param radians the angle in radians
  72908. */
  72909. constructor(radians: number);
  72910. /**
  72911. * Get value in degrees
  72912. * @returns the Angle value in degrees (float)
  72913. */
  72914. degrees(): number;
  72915. /**
  72916. * Get value in radians
  72917. * @returns the Angle value in radians (float)
  72918. */
  72919. radians(): number;
  72920. /**
  72921. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  72922. * @param a defines first vector
  72923. * @param b defines second vector
  72924. * @returns a new Angle
  72925. */
  72926. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  72927. /**
  72928. * Gets a new Angle object from the given float in radians
  72929. * @param radians defines the angle value in radians
  72930. * @returns a new Angle
  72931. */
  72932. static FromRadians(radians: number): Angle;
  72933. /**
  72934. * Gets a new Angle object from the given float in degrees
  72935. * @param degrees defines the angle value in degrees
  72936. * @returns a new Angle
  72937. */
  72938. static FromDegrees(degrees: number): Angle;
  72939. }
  72940. /**
  72941. * This represents an arc in a 2d space.
  72942. */
  72943. export class Arc2 {
  72944. /** Defines the start point of the arc */
  72945. startPoint: Vector2;
  72946. /** Defines the mid point of the arc */
  72947. midPoint: Vector2;
  72948. /** Defines the end point of the arc */
  72949. endPoint: Vector2;
  72950. /**
  72951. * Defines the center point of the arc.
  72952. */
  72953. centerPoint: Vector2;
  72954. /**
  72955. * Defines the radius of the arc.
  72956. */
  72957. radius: number;
  72958. /**
  72959. * Defines the angle of the arc (from mid point to end point).
  72960. */
  72961. angle: Angle;
  72962. /**
  72963. * Defines the start angle of the arc (from start point to middle point).
  72964. */
  72965. startAngle: Angle;
  72966. /**
  72967. * Defines the orientation of the arc (clock wise/counter clock wise).
  72968. */
  72969. orientation: Orientation;
  72970. /**
  72971. * Creates an Arc object from the three given points : start, middle and end.
  72972. * @param startPoint Defines the start point of the arc
  72973. * @param midPoint Defines the midlle point of the arc
  72974. * @param endPoint Defines the end point of the arc
  72975. */
  72976. constructor(
  72977. /** Defines the start point of the arc */
  72978. startPoint: Vector2,
  72979. /** Defines the mid point of the arc */
  72980. midPoint: Vector2,
  72981. /** Defines the end point of the arc */
  72982. endPoint: Vector2);
  72983. }
  72984. /**
  72985. * Represents a 2D path made up of multiple 2D points
  72986. */
  72987. export class Path2 {
  72988. private _points;
  72989. private _length;
  72990. /**
  72991. * If the path start and end point are the same
  72992. */
  72993. closed: boolean;
  72994. /**
  72995. * Creates a Path2 object from the starting 2D coordinates x and y.
  72996. * @param x the starting points x value
  72997. * @param y the starting points y value
  72998. */
  72999. constructor(x: number, y: number);
  73000. /**
  73001. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  73002. * @param x the added points x value
  73003. * @param y the added points y value
  73004. * @returns the updated Path2.
  73005. */
  73006. addLineTo(x: number, y: number): Path2;
  73007. /**
  73008. * 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.
  73009. * @param midX middle point x value
  73010. * @param midY middle point y value
  73011. * @param endX end point x value
  73012. * @param endY end point y value
  73013. * @param numberOfSegments (default: 36)
  73014. * @returns the updated Path2.
  73015. */
  73016. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  73017. /**
  73018. * Closes the Path2.
  73019. * @returns the Path2.
  73020. */
  73021. close(): Path2;
  73022. /**
  73023. * Gets the sum of the distance between each sequential point in the path
  73024. * @returns the Path2 total length (float).
  73025. */
  73026. length(): number;
  73027. /**
  73028. * Gets the points which construct the path
  73029. * @returns the Path2 internal array of points.
  73030. */
  73031. getPoints(): Vector2[];
  73032. /**
  73033. * Retreives the point at the distance aways from the starting point
  73034. * @param normalizedLengthPosition the length along the path to retreive the point from
  73035. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  73036. */
  73037. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  73038. /**
  73039. * Creates a new path starting from an x and y position
  73040. * @param x starting x value
  73041. * @param y starting y value
  73042. * @returns a new Path2 starting at the coordinates (x, y).
  73043. */
  73044. static StartingAt(x: number, y: number): Path2;
  73045. }
  73046. /**
  73047. * Represents a 3D path made up of multiple 3D points
  73048. */
  73049. export class Path3D {
  73050. /**
  73051. * an array of Vector3, the curve axis of the Path3D
  73052. */
  73053. path: Vector3[];
  73054. private _curve;
  73055. private _distances;
  73056. private _tangents;
  73057. private _normals;
  73058. private _binormals;
  73059. private _raw;
  73060. private _alignTangentsWithPath;
  73061. private readonly _pointAtData;
  73062. /**
  73063. * new Path3D(path, normal, raw)
  73064. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  73065. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  73066. * @param path an array of Vector3, the curve axis of the Path3D
  73067. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  73068. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  73069. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  73070. */
  73071. constructor(
  73072. /**
  73073. * an array of Vector3, the curve axis of the Path3D
  73074. */
  73075. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  73076. /**
  73077. * Returns the Path3D array of successive Vector3 designing its curve.
  73078. * @returns the Path3D array of successive Vector3 designing its curve.
  73079. */
  73080. getCurve(): Vector3[];
  73081. /**
  73082. * Returns the Path3D array of successive Vector3 designing its curve.
  73083. * @returns the Path3D array of successive Vector3 designing its curve.
  73084. */
  73085. getPoints(): Vector3[];
  73086. /**
  73087. * @returns the computed length (float) of the path.
  73088. */
  73089. length(): number;
  73090. /**
  73091. * Returns an array populated with tangent vectors on each Path3D curve point.
  73092. * @returns an array populated with tangent vectors on each Path3D curve point.
  73093. */
  73094. getTangents(): Vector3[];
  73095. /**
  73096. * Returns an array populated with normal vectors on each Path3D curve point.
  73097. * @returns an array populated with normal vectors on each Path3D curve point.
  73098. */
  73099. getNormals(): Vector3[];
  73100. /**
  73101. * Returns an array populated with binormal vectors on each Path3D curve point.
  73102. * @returns an array populated with binormal vectors on each Path3D curve point.
  73103. */
  73104. getBinormals(): Vector3[];
  73105. /**
  73106. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  73107. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  73108. */
  73109. getDistances(): number[];
  73110. /**
  73111. * Returns an interpolated point along this path
  73112. * @param position the position of the point along this path, from 0.0 to 1.0
  73113. * @returns a new Vector3 as the point
  73114. */
  73115. getPointAt(position: number): Vector3;
  73116. /**
  73117. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  73118. * @param position the position of the point along this path, from 0.0 to 1.0
  73119. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  73120. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  73121. */
  73122. getTangentAt(position: number, interpolated?: boolean): Vector3;
  73123. /**
  73124. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  73125. * @param position the position of the point along this path, from 0.0 to 1.0
  73126. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  73127. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  73128. */
  73129. getNormalAt(position: number, interpolated?: boolean): Vector3;
  73130. /**
  73131. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  73132. * @param position the position of the point along this path, from 0.0 to 1.0
  73133. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  73134. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  73135. */
  73136. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  73137. /**
  73138. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  73139. * @param position the position of the point along this path, from 0.0 to 1.0
  73140. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  73141. */
  73142. getDistanceAt(position: number): number;
  73143. /**
  73144. * Returns the array index of the previous point of an interpolated point along this path
  73145. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  73146. * @returns the array index
  73147. */
  73148. getPreviousPointIndexAt(position: number): number;
  73149. /**
  73150. * 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)
  73151. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  73152. * @returns the sub position
  73153. */
  73154. getSubPositionAt(position: number): number;
  73155. /**
  73156. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  73157. * @param target the vector of which to get the closest position to
  73158. * @returns the position of the closest virtual point on this path to the target vector
  73159. */
  73160. getClosestPositionTo(target: Vector3): number;
  73161. /**
  73162. * Returns a sub path (slice) of this path
  73163. * @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
  73164. * @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
  73165. * @returns a sub path (slice) of this path
  73166. */
  73167. slice(start?: number, end?: number): Path3D;
  73168. /**
  73169. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  73170. * @param path path which all values are copied into the curves points
  73171. * @param firstNormal which should be projected onto the curve
  73172. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  73173. * @returns the same object updated.
  73174. */
  73175. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  73176. private _compute;
  73177. private _getFirstNonNullVector;
  73178. private _getLastNonNullVector;
  73179. private _normalVector;
  73180. /**
  73181. * Updates the point at data for an interpolated point along this curve
  73182. * @param position the position of the point along this curve, from 0.0 to 1.0
  73183. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  73184. * @returns the (updated) point at data
  73185. */
  73186. private _updatePointAtData;
  73187. /**
  73188. * Updates the point at data from the specified parameters
  73189. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  73190. * @param point the interpolated point
  73191. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  73192. */
  73193. private _setPointAtData;
  73194. /**
  73195. * Updates the point at interpolation matrix for the tangents, normals and binormals
  73196. */
  73197. private _updateInterpolationMatrix;
  73198. }
  73199. /**
  73200. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73201. * A Curve3 is designed from a series of successive Vector3.
  73202. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  73203. */
  73204. export class Curve3 {
  73205. private _points;
  73206. private _length;
  73207. /**
  73208. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  73209. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  73210. * @param v1 (Vector3) the control point
  73211. * @param v2 (Vector3) the end point of the Quadratic Bezier
  73212. * @param nbPoints (integer) the wanted number of points in the curve
  73213. * @returns the created Curve3
  73214. */
  73215. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73216. /**
  73217. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  73218. * @param v0 (Vector3) the origin point of the Cubic Bezier
  73219. * @param v1 (Vector3) the first control point
  73220. * @param v2 (Vector3) the second control point
  73221. * @param v3 (Vector3) the end point of the Cubic Bezier
  73222. * @param nbPoints (integer) the wanted number of points in the curve
  73223. * @returns the created Curve3
  73224. */
  73225. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73226. /**
  73227. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  73228. * @param p1 (Vector3) the origin point of the Hermite Spline
  73229. * @param t1 (Vector3) the tangent vector at the origin point
  73230. * @param p2 (Vector3) the end point of the Hermite Spline
  73231. * @param t2 (Vector3) the tangent vector at the end point
  73232. * @param nbPoints (integer) the wanted number of points in the curve
  73233. * @returns the created Curve3
  73234. */
  73235. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73236. /**
  73237. * Returns a Curve3 object along a CatmullRom Spline curve :
  73238. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  73239. * @param nbPoints (integer) the wanted number of points between each curve control points
  73240. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  73241. * @returns the created Curve3
  73242. */
  73243. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  73244. /**
  73245. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73246. * A Curve3 is designed from a series of successive Vector3.
  73247. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  73248. * @param points points which make up the curve
  73249. */
  73250. constructor(points: Vector3[]);
  73251. /**
  73252. * @returns the Curve3 stored array of successive Vector3
  73253. */
  73254. getPoints(): Vector3[];
  73255. /**
  73256. * @returns the computed length (float) of the curve.
  73257. */
  73258. length(): number;
  73259. /**
  73260. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  73261. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  73262. * curveA and curveB keep unchanged.
  73263. * @param curve the curve to continue from this curve
  73264. * @returns the newly constructed curve
  73265. */
  73266. continue(curve: DeepImmutable<Curve3>): Curve3;
  73267. private _computeLength;
  73268. }
  73269. }
  73270. declare module BABYLON {
  73271. /**
  73272. * This represents the main contract an easing function should follow.
  73273. * Easing functions are used throughout the animation system.
  73274. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73275. */
  73276. export interface IEasingFunction {
  73277. /**
  73278. * Given an input gradient between 0 and 1, this returns the corrseponding value
  73279. * of the easing function.
  73280. * The link below provides some of the most common examples of easing functions.
  73281. * @see https://easings.net/
  73282. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73283. * @returns the corresponding value on the curve defined by the easing function
  73284. */
  73285. ease(gradient: number): number;
  73286. }
  73287. /**
  73288. * Base class used for every default easing function.
  73289. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73290. */
  73291. export class EasingFunction implements IEasingFunction {
  73292. /**
  73293. * Interpolation follows the mathematical formula associated with the easing function.
  73294. */
  73295. static readonly EASINGMODE_EASEIN: number;
  73296. /**
  73297. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  73298. */
  73299. static readonly EASINGMODE_EASEOUT: number;
  73300. /**
  73301. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  73302. */
  73303. static readonly EASINGMODE_EASEINOUT: number;
  73304. private _easingMode;
  73305. /**
  73306. * Sets the easing mode of the current function.
  73307. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  73308. */
  73309. setEasingMode(easingMode: number): void;
  73310. /**
  73311. * Gets the current easing mode.
  73312. * @returns the easing mode
  73313. */
  73314. getEasingMode(): number;
  73315. /**
  73316. * @hidden
  73317. */
  73318. easeInCore(gradient: number): number;
  73319. /**
  73320. * Given an input gradient between 0 and 1, this returns the corresponding value
  73321. * of the easing function.
  73322. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73323. * @returns the corresponding value on the curve defined by the easing function
  73324. */
  73325. ease(gradient: number): number;
  73326. }
  73327. /**
  73328. * Easing function with a circle shape (see link below).
  73329. * @see https://easings.net/#easeInCirc
  73330. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73331. */
  73332. export class CircleEase extends EasingFunction implements IEasingFunction {
  73333. /** @hidden */
  73334. easeInCore(gradient: number): number;
  73335. }
  73336. /**
  73337. * Easing function with a ease back shape (see link below).
  73338. * @see https://easings.net/#easeInBack
  73339. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73340. */
  73341. export class BackEase extends EasingFunction implements IEasingFunction {
  73342. /** Defines the amplitude of the function */
  73343. amplitude: number;
  73344. /**
  73345. * Instantiates a back ease easing
  73346. * @see https://easings.net/#easeInBack
  73347. * @param amplitude Defines the amplitude of the function
  73348. */
  73349. constructor(
  73350. /** Defines the amplitude of the function */
  73351. amplitude?: number);
  73352. /** @hidden */
  73353. easeInCore(gradient: number): number;
  73354. }
  73355. /**
  73356. * Easing function with a bouncing shape (see link below).
  73357. * @see https://easings.net/#easeInBounce
  73358. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73359. */
  73360. export class BounceEase extends EasingFunction implements IEasingFunction {
  73361. /** Defines the number of bounces */
  73362. bounces: number;
  73363. /** Defines the amplitude of the bounce */
  73364. bounciness: number;
  73365. /**
  73366. * Instantiates a bounce easing
  73367. * @see https://easings.net/#easeInBounce
  73368. * @param bounces Defines the number of bounces
  73369. * @param bounciness Defines the amplitude of the bounce
  73370. */
  73371. constructor(
  73372. /** Defines the number of bounces */
  73373. bounces?: number,
  73374. /** Defines the amplitude of the bounce */
  73375. bounciness?: number);
  73376. /** @hidden */
  73377. easeInCore(gradient: number): number;
  73378. }
  73379. /**
  73380. * Easing function with a power of 3 shape (see link below).
  73381. * @see https://easings.net/#easeInCubic
  73382. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73383. */
  73384. export class CubicEase extends EasingFunction implements IEasingFunction {
  73385. /** @hidden */
  73386. easeInCore(gradient: number): number;
  73387. }
  73388. /**
  73389. * Easing function with an elastic shape (see link below).
  73390. * @see https://easings.net/#easeInElastic
  73391. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73392. */
  73393. export class ElasticEase extends EasingFunction implements IEasingFunction {
  73394. /** Defines the number of oscillations*/
  73395. oscillations: number;
  73396. /** Defines the amplitude of the oscillations*/
  73397. springiness: number;
  73398. /**
  73399. * Instantiates an elastic easing function
  73400. * @see https://easings.net/#easeInElastic
  73401. * @param oscillations Defines the number of oscillations
  73402. * @param springiness Defines the amplitude of the oscillations
  73403. */
  73404. constructor(
  73405. /** Defines the number of oscillations*/
  73406. oscillations?: number,
  73407. /** Defines the amplitude of the oscillations*/
  73408. springiness?: number);
  73409. /** @hidden */
  73410. easeInCore(gradient: number): number;
  73411. }
  73412. /**
  73413. * Easing function with an exponential shape (see link below).
  73414. * @see https://easings.net/#easeInExpo
  73415. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73416. */
  73417. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  73418. /** Defines the exponent of the function */
  73419. exponent: number;
  73420. /**
  73421. * Instantiates an exponential easing function
  73422. * @see https://easings.net/#easeInExpo
  73423. * @param exponent Defines the exponent of the function
  73424. */
  73425. constructor(
  73426. /** Defines the exponent of the function */
  73427. exponent?: number);
  73428. /** @hidden */
  73429. easeInCore(gradient: number): number;
  73430. }
  73431. /**
  73432. * Easing function with a power shape (see link below).
  73433. * @see https://easings.net/#easeInQuad
  73434. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73435. */
  73436. export class PowerEase extends EasingFunction implements IEasingFunction {
  73437. /** Defines the power of the function */
  73438. power: number;
  73439. /**
  73440. * Instantiates an power base easing function
  73441. * @see https://easings.net/#easeInQuad
  73442. * @param power Defines the power of the function
  73443. */
  73444. constructor(
  73445. /** Defines the power of the function */
  73446. power?: number);
  73447. /** @hidden */
  73448. easeInCore(gradient: number): number;
  73449. }
  73450. /**
  73451. * Easing function with a power of 2 shape (see link below).
  73452. * @see https://easings.net/#easeInQuad
  73453. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73454. */
  73455. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  73456. /** @hidden */
  73457. easeInCore(gradient: number): number;
  73458. }
  73459. /**
  73460. * Easing function with a power of 4 shape (see link below).
  73461. * @see https://easings.net/#easeInQuart
  73462. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73463. */
  73464. export class QuarticEase extends EasingFunction implements IEasingFunction {
  73465. /** @hidden */
  73466. easeInCore(gradient: number): number;
  73467. }
  73468. /**
  73469. * Easing function with a power of 5 shape (see link below).
  73470. * @see https://easings.net/#easeInQuint
  73471. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73472. */
  73473. export class QuinticEase extends EasingFunction implements IEasingFunction {
  73474. /** @hidden */
  73475. easeInCore(gradient: number): number;
  73476. }
  73477. /**
  73478. * Easing function with a sin shape (see link below).
  73479. * @see https://easings.net/#easeInSine
  73480. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73481. */
  73482. export class SineEase extends EasingFunction implements IEasingFunction {
  73483. /** @hidden */
  73484. easeInCore(gradient: number): number;
  73485. }
  73486. /**
  73487. * Easing function with a bezier shape (see link below).
  73488. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73489. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73490. */
  73491. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  73492. /** Defines the x component of the start tangent in the bezier curve */
  73493. x1: number;
  73494. /** Defines the y component of the start tangent in the bezier curve */
  73495. y1: number;
  73496. /** Defines the x component of the end tangent in the bezier curve */
  73497. x2: number;
  73498. /** Defines the y component of the end tangent in the bezier curve */
  73499. y2: number;
  73500. /**
  73501. * Instantiates a bezier function
  73502. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73503. * @param x1 Defines the x component of the start tangent in the bezier curve
  73504. * @param y1 Defines the y component of the start tangent in the bezier curve
  73505. * @param x2 Defines the x component of the end tangent in the bezier curve
  73506. * @param y2 Defines the y component of the end tangent in the bezier curve
  73507. */
  73508. constructor(
  73509. /** Defines the x component of the start tangent in the bezier curve */
  73510. x1?: number,
  73511. /** Defines the y component of the start tangent in the bezier curve */
  73512. y1?: number,
  73513. /** Defines the x component of the end tangent in the bezier curve */
  73514. x2?: number,
  73515. /** Defines the y component of the end tangent in the bezier curve */
  73516. y2?: number);
  73517. /** @hidden */
  73518. easeInCore(gradient: number): number;
  73519. }
  73520. }
  73521. declare module BABYLON {
  73522. /**
  73523. * Class used to hold a RBG color
  73524. */
  73525. export class Color3 {
  73526. /**
  73527. * Defines the red component (between 0 and 1, default is 0)
  73528. */
  73529. r: number;
  73530. /**
  73531. * Defines the green component (between 0 and 1, default is 0)
  73532. */
  73533. g: number;
  73534. /**
  73535. * Defines the blue component (between 0 and 1, default is 0)
  73536. */
  73537. b: number;
  73538. /**
  73539. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  73540. * @param r defines the red component (between 0 and 1, default is 0)
  73541. * @param g defines the green component (between 0 and 1, default is 0)
  73542. * @param b defines the blue component (between 0 and 1, default is 0)
  73543. */
  73544. constructor(
  73545. /**
  73546. * Defines the red component (between 0 and 1, default is 0)
  73547. */
  73548. r?: number,
  73549. /**
  73550. * Defines the green component (between 0 and 1, default is 0)
  73551. */
  73552. g?: number,
  73553. /**
  73554. * Defines the blue component (between 0 and 1, default is 0)
  73555. */
  73556. b?: number);
  73557. /**
  73558. * Creates a string with the Color3 current values
  73559. * @returns the string representation of the Color3 object
  73560. */
  73561. toString(): string;
  73562. /**
  73563. * Returns the string "Color3"
  73564. * @returns "Color3"
  73565. */
  73566. getClassName(): string;
  73567. /**
  73568. * Compute the Color3 hash code
  73569. * @returns an unique number that can be used to hash Color3 objects
  73570. */
  73571. getHashCode(): number;
  73572. /**
  73573. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  73574. * @param array defines the array where to store the r,g,b components
  73575. * @param index defines an optional index in the target array to define where to start storing values
  73576. * @returns the current Color3 object
  73577. */
  73578. toArray(array: FloatArray, index?: number): Color3;
  73579. /**
  73580. * Returns a new Color4 object from the current Color3 and the given alpha
  73581. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  73582. * @returns a new Color4 object
  73583. */
  73584. toColor4(alpha?: number): Color4;
  73585. /**
  73586. * Returns a new array populated with 3 numeric elements : red, green and blue values
  73587. * @returns the new array
  73588. */
  73589. asArray(): number[];
  73590. /**
  73591. * Returns the luminance value
  73592. * @returns a float value
  73593. */
  73594. toLuminance(): number;
  73595. /**
  73596. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  73597. * @param otherColor defines the second operand
  73598. * @returns the new Color3 object
  73599. */
  73600. multiply(otherColor: DeepImmutable<Color3>): Color3;
  73601. /**
  73602. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  73603. * @param otherColor defines the second operand
  73604. * @param result defines the Color3 object where to store the result
  73605. * @returns the current Color3
  73606. */
  73607. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73608. /**
  73609. * Determines equality between Color3 objects
  73610. * @param otherColor defines the second operand
  73611. * @returns true if the rgb values are equal to the given ones
  73612. */
  73613. equals(otherColor: DeepImmutable<Color3>): boolean;
  73614. /**
  73615. * Determines equality between the current Color3 object and a set of r,b,g values
  73616. * @param r defines the red component to check
  73617. * @param g defines the green component to check
  73618. * @param b defines the blue component to check
  73619. * @returns true if the rgb values are equal to the given ones
  73620. */
  73621. equalsFloats(r: number, g: number, b: number): boolean;
  73622. /**
  73623. * Multiplies in place each rgb value by scale
  73624. * @param scale defines the scaling factor
  73625. * @returns the updated Color3
  73626. */
  73627. scale(scale: number): Color3;
  73628. /**
  73629. * Multiplies the rgb values by scale and stores the result into "result"
  73630. * @param scale defines the scaling factor
  73631. * @param result defines the Color3 object where to store the result
  73632. * @returns the unmodified current Color3
  73633. */
  73634. scaleToRef(scale: number, result: Color3): Color3;
  73635. /**
  73636. * Scale the current Color3 values by a factor and add the result to a given Color3
  73637. * @param scale defines the scale factor
  73638. * @param result defines color to store the result into
  73639. * @returns the unmodified current Color3
  73640. */
  73641. scaleAndAddToRef(scale: number, result: Color3): Color3;
  73642. /**
  73643. * Clamps the rgb values by the min and max values and stores the result into "result"
  73644. * @param min defines minimum clamping value (default is 0)
  73645. * @param max defines maximum clamping value (default is 1)
  73646. * @param result defines color to store the result into
  73647. * @returns the original Color3
  73648. */
  73649. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  73650. /**
  73651. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  73652. * @param otherColor defines the second operand
  73653. * @returns the new Color3
  73654. */
  73655. add(otherColor: DeepImmutable<Color3>): Color3;
  73656. /**
  73657. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  73658. * @param otherColor defines the second operand
  73659. * @param result defines Color3 object to store the result into
  73660. * @returns the unmodified current Color3
  73661. */
  73662. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73663. /**
  73664. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  73665. * @param otherColor defines the second operand
  73666. * @returns the new Color3
  73667. */
  73668. subtract(otherColor: DeepImmutable<Color3>): Color3;
  73669. /**
  73670. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  73671. * @param otherColor defines the second operand
  73672. * @param result defines Color3 object to store the result into
  73673. * @returns the unmodified current Color3
  73674. */
  73675. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73676. /**
  73677. * Copy the current object
  73678. * @returns a new Color3 copied the current one
  73679. */
  73680. clone(): Color3;
  73681. /**
  73682. * Copies the rgb values from the source in the current Color3
  73683. * @param source defines the source Color3 object
  73684. * @returns the updated Color3 object
  73685. */
  73686. copyFrom(source: DeepImmutable<Color3>): Color3;
  73687. /**
  73688. * Updates the Color3 rgb values from the given floats
  73689. * @param r defines the red component to read from
  73690. * @param g defines the green component to read from
  73691. * @param b defines the blue component to read from
  73692. * @returns the current Color3 object
  73693. */
  73694. copyFromFloats(r: number, g: number, b: number): Color3;
  73695. /**
  73696. * Updates the Color3 rgb values from the given floats
  73697. * @param r defines the red component to read from
  73698. * @param g defines the green component to read from
  73699. * @param b defines the blue component to read from
  73700. * @returns the current Color3 object
  73701. */
  73702. set(r: number, g: number, b: number): Color3;
  73703. /**
  73704. * Compute the Color3 hexadecimal code as a string
  73705. * @returns a string containing the hexadecimal representation of the Color3 object
  73706. */
  73707. toHexString(): string;
  73708. /**
  73709. * Computes a new Color3 converted from the current one to linear space
  73710. * @returns a new Color3 object
  73711. */
  73712. toLinearSpace(): Color3;
  73713. /**
  73714. * Converts current color in rgb space to HSV values
  73715. * @returns a new color3 representing the HSV values
  73716. */
  73717. toHSV(): Color3;
  73718. /**
  73719. * Converts current color in rgb space to HSV values
  73720. * @param result defines the Color3 where to store the HSV values
  73721. */
  73722. toHSVToRef(result: Color3): void;
  73723. /**
  73724. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  73725. * @param convertedColor defines the Color3 object where to store the linear space version
  73726. * @returns the unmodified Color3
  73727. */
  73728. toLinearSpaceToRef(convertedColor: Color3): Color3;
  73729. /**
  73730. * Computes a new Color3 converted from the current one to gamma space
  73731. * @returns a new Color3 object
  73732. */
  73733. toGammaSpace(): Color3;
  73734. /**
  73735. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  73736. * @param convertedColor defines the Color3 object where to store the gamma space version
  73737. * @returns the unmodified Color3
  73738. */
  73739. toGammaSpaceToRef(convertedColor: Color3): Color3;
  73740. private static _BlackReadOnly;
  73741. /**
  73742. * Convert Hue, saturation and value to a Color3 (RGB)
  73743. * @param hue defines the hue
  73744. * @param saturation defines the saturation
  73745. * @param value defines the value
  73746. * @param result defines the Color3 where to store the RGB values
  73747. */
  73748. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  73749. /**
  73750. * Creates a new Color3 from the string containing valid hexadecimal values
  73751. * @param hex defines a string containing valid hexadecimal values
  73752. * @returns a new Color3 object
  73753. */
  73754. static FromHexString(hex: string): Color3;
  73755. /**
  73756. * Creates a new Color3 from the starting index of the given array
  73757. * @param array defines the source array
  73758. * @param offset defines an offset in the source array
  73759. * @returns a new Color3 object
  73760. */
  73761. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  73762. /**
  73763. * Creates a new Color3 from integer values (< 256)
  73764. * @param r defines the red component to read from (value between 0 and 255)
  73765. * @param g defines the green component to read from (value between 0 and 255)
  73766. * @param b defines the blue component to read from (value between 0 and 255)
  73767. * @returns a new Color3 object
  73768. */
  73769. static FromInts(r: number, g: number, b: number): Color3;
  73770. /**
  73771. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73772. * @param start defines the start Color3 value
  73773. * @param end defines the end Color3 value
  73774. * @param amount defines the gradient value between start and end
  73775. * @returns a new Color3 object
  73776. */
  73777. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  73778. /**
  73779. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73780. * @param left defines the start value
  73781. * @param right defines the end value
  73782. * @param amount defines the gradient factor
  73783. * @param result defines the Color3 object where to store the result
  73784. */
  73785. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  73786. /**
  73787. * Returns a Color3 value containing a red color
  73788. * @returns a new Color3 object
  73789. */
  73790. static Red(): Color3;
  73791. /**
  73792. * Returns a Color3 value containing a green color
  73793. * @returns a new Color3 object
  73794. */
  73795. static Green(): Color3;
  73796. /**
  73797. * Returns a Color3 value containing a blue color
  73798. * @returns a new Color3 object
  73799. */
  73800. static Blue(): Color3;
  73801. /**
  73802. * Returns a Color3 value containing a black color
  73803. * @returns a new Color3 object
  73804. */
  73805. static Black(): Color3;
  73806. /**
  73807. * Gets a Color3 value containing a black color that must not be updated
  73808. */
  73809. static readonly BlackReadOnly: DeepImmutable<Color3>;
  73810. /**
  73811. * Returns a Color3 value containing a white color
  73812. * @returns a new Color3 object
  73813. */
  73814. static White(): Color3;
  73815. /**
  73816. * Returns a Color3 value containing a purple color
  73817. * @returns a new Color3 object
  73818. */
  73819. static Purple(): Color3;
  73820. /**
  73821. * Returns a Color3 value containing a magenta color
  73822. * @returns a new Color3 object
  73823. */
  73824. static Magenta(): Color3;
  73825. /**
  73826. * Returns a Color3 value containing a yellow color
  73827. * @returns a new Color3 object
  73828. */
  73829. static Yellow(): Color3;
  73830. /**
  73831. * Returns a Color3 value containing a gray color
  73832. * @returns a new Color3 object
  73833. */
  73834. static Gray(): Color3;
  73835. /**
  73836. * Returns a Color3 value containing a teal color
  73837. * @returns a new Color3 object
  73838. */
  73839. static Teal(): Color3;
  73840. /**
  73841. * Returns a Color3 value containing a random color
  73842. * @returns a new Color3 object
  73843. */
  73844. static Random(): Color3;
  73845. }
  73846. /**
  73847. * Class used to hold a RBGA color
  73848. */
  73849. export class Color4 {
  73850. /**
  73851. * Defines the red component (between 0 and 1, default is 0)
  73852. */
  73853. r: number;
  73854. /**
  73855. * Defines the green component (between 0 and 1, default is 0)
  73856. */
  73857. g: number;
  73858. /**
  73859. * Defines the blue component (between 0 and 1, default is 0)
  73860. */
  73861. b: number;
  73862. /**
  73863. * Defines the alpha component (between 0 and 1, default is 1)
  73864. */
  73865. a: number;
  73866. /**
  73867. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  73868. * @param r defines the red component (between 0 and 1, default is 0)
  73869. * @param g defines the green component (between 0 and 1, default is 0)
  73870. * @param b defines the blue component (between 0 and 1, default is 0)
  73871. * @param a defines the alpha component (between 0 and 1, default is 1)
  73872. */
  73873. constructor(
  73874. /**
  73875. * Defines the red component (between 0 and 1, default is 0)
  73876. */
  73877. r?: number,
  73878. /**
  73879. * Defines the green component (between 0 and 1, default is 0)
  73880. */
  73881. g?: number,
  73882. /**
  73883. * Defines the blue component (between 0 and 1, default is 0)
  73884. */
  73885. b?: number,
  73886. /**
  73887. * Defines the alpha component (between 0 and 1, default is 1)
  73888. */
  73889. a?: number);
  73890. /**
  73891. * Adds in place the given Color4 values to the current Color4 object
  73892. * @param right defines the second operand
  73893. * @returns the current updated Color4 object
  73894. */
  73895. addInPlace(right: DeepImmutable<Color4>): Color4;
  73896. /**
  73897. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  73898. * @returns the new array
  73899. */
  73900. asArray(): number[];
  73901. /**
  73902. * Stores from the starting index in the given array the Color4 successive values
  73903. * @param array defines the array where to store the r,g,b components
  73904. * @param index defines an optional index in the target array to define where to start storing values
  73905. * @returns the current Color4 object
  73906. */
  73907. toArray(array: number[], index?: number): Color4;
  73908. /**
  73909. * Determines equality between Color4 objects
  73910. * @param otherColor defines the second operand
  73911. * @returns true if the rgba values are equal to the given ones
  73912. */
  73913. equals(otherColor: DeepImmutable<Color4>): boolean;
  73914. /**
  73915. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  73916. * @param right defines the second operand
  73917. * @returns a new Color4 object
  73918. */
  73919. add(right: DeepImmutable<Color4>): Color4;
  73920. /**
  73921. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  73922. * @param right defines the second operand
  73923. * @returns a new Color4 object
  73924. */
  73925. subtract(right: DeepImmutable<Color4>): Color4;
  73926. /**
  73927. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  73928. * @param right defines the second operand
  73929. * @param result defines the Color4 object where to store the result
  73930. * @returns the current Color4 object
  73931. */
  73932. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  73933. /**
  73934. * Creates a new Color4 with the current Color4 values multiplied by scale
  73935. * @param scale defines the scaling factor to apply
  73936. * @returns a new Color4 object
  73937. */
  73938. scale(scale: number): Color4;
  73939. /**
  73940. * Multiplies the current Color4 values by scale and stores the result in "result"
  73941. * @param scale defines the scaling factor to apply
  73942. * @param result defines the Color4 object where to store the result
  73943. * @returns the current unmodified Color4
  73944. */
  73945. scaleToRef(scale: number, result: Color4): Color4;
  73946. /**
  73947. * Scale the current Color4 values by a factor and add the result to a given Color4
  73948. * @param scale defines the scale factor
  73949. * @param result defines the Color4 object where to store the result
  73950. * @returns the unmodified current Color4
  73951. */
  73952. scaleAndAddToRef(scale: number, result: Color4): Color4;
  73953. /**
  73954. * Clamps the rgb values by the min and max values and stores the result into "result"
  73955. * @param min defines minimum clamping value (default is 0)
  73956. * @param max defines maximum clamping value (default is 1)
  73957. * @param result defines color to store the result into.
  73958. * @returns the cuurent Color4
  73959. */
  73960. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  73961. /**
  73962. * Multipy an Color4 value by another and return a new Color4 object
  73963. * @param color defines the Color4 value to multiply by
  73964. * @returns a new Color4 object
  73965. */
  73966. multiply(color: Color4): Color4;
  73967. /**
  73968. * Multipy a Color4 value by another and push the result in a reference value
  73969. * @param color defines the Color4 value to multiply by
  73970. * @param result defines the Color4 to fill the result in
  73971. * @returns the result Color4
  73972. */
  73973. multiplyToRef(color: Color4, result: Color4): Color4;
  73974. /**
  73975. * Creates a string with the Color4 current values
  73976. * @returns the string representation of the Color4 object
  73977. */
  73978. toString(): string;
  73979. /**
  73980. * Returns the string "Color4"
  73981. * @returns "Color4"
  73982. */
  73983. getClassName(): string;
  73984. /**
  73985. * Compute the Color4 hash code
  73986. * @returns an unique number that can be used to hash Color4 objects
  73987. */
  73988. getHashCode(): number;
  73989. /**
  73990. * Creates a new Color4 copied from the current one
  73991. * @returns a new Color4 object
  73992. */
  73993. clone(): Color4;
  73994. /**
  73995. * Copies the given Color4 values into the current one
  73996. * @param source defines the source Color4 object
  73997. * @returns the current updated Color4 object
  73998. */
  73999. copyFrom(source: Color4): Color4;
  74000. /**
  74001. * Copies the given float values into the current one
  74002. * @param r defines the red component to read from
  74003. * @param g defines the green component to read from
  74004. * @param b defines the blue component to read from
  74005. * @param a defines the alpha component to read from
  74006. * @returns the current updated Color4 object
  74007. */
  74008. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  74009. /**
  74010. * Copies the given float values into the current one
  74011. * @param r defines the red component to read from
  74012. * @param g defines the green component to read from
  74013. * @param b defines the blue component to read from
  74014. * @param a defines the alpha component to read from
  74015. * @returns the current updated Color4 object
  74016. */
  74017. set(r: number, g: number, b: number, a: number): Color4;
  74018. /**
  74019. * Compute the Color4 hexadecimal code as a string
  74020. * @returns a string containing the hexadecimal representation of the Color4 object
  74021. */
  74022. toHexString(): string;
  74023. /**
  74024. * Computes a new Color4 converted from the current one to linear space
  74025. * @returns a new Color4 object
  74026. */
  74027. toLinearSpace(): Color4;
  74028. /**
  74029. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  74030. * @param convertedColor defines the Color4 object where to store the linear space version
  74031. * @returns the unmodified Color4
  74032. */
  74033. toLinearSpaceToRef(convertedColor: Color4): Color4;
  74034. /**
  74035. * Computes a new Color4 converted from the current one to gamma space
  74036. * @returns a new Color4 object
  74037. */
  74038. toGammaSpace(): Color4;
  74039. /**
  74040. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  74041. * @param convertedColor defines the Color4 object where to store the gamma space version
  74042. * @returns the unmodified Color4
  74043. */
  74044. toGammaSpaceToRef(convertedColor: Color4): Color4;
  74045. /**
  74046. * Creates a new Color4 from the string containing valid hexadecimal values
  74047. * @param hex defines a string containing valid hexadecimal values
  74048. * @returns a new Color4 object
  74049. */
  74050. static FromHexString(hex: string): Color4;
  74051. /**
  74052. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  74053. * @param left defines the start value
  74054. * @param right defines the end value
  74055. * @param amount defines the gradient factor
  74056. * @returns a new Color4 object
  74057. */
  74058. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  74059. /**
  74060. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  74061. * @param left defines the start value
  74062. * @param right defines the end value
  74063. * @param amount defines the gradient factor
  74064. * @param result defines the Color4 object where to store data
  74065. */
  74066. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  74067. /**
  74068. * Creates a new Color4 from a Color3 and an alpha value
  74069. * @param color3 defines the source Color3 to read from
  74070. * @param alpha defines the alpha component (1.0 by default)
  74071. * @returns a new Color4 object
  74072. */
  74073. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  74074. /**
  74075. * Creates a new Color4 from the starting index element of the given array
  74076. * @param array defines the source array to read from
  74077. * @param offset defines the offset in the source array
  74078. * @returns a new Color4 object
  74079. */
  74080. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  74081. /**
  74082. * Creates a new Color3 from integer values (< 256)
  74083. * @param r defines the red component to read from (value between 0 and 255)
  74084. * @param g defines the green component to read from (value between 0 and 255)
  74085. * @param b defines the blue component to read from (value between 0 and 255)
  74086. * @param a defines the alpha component to read from (value between 0 and 255)
  74087. * @returns a new Color3 object
  74088. */
  74089. static FromInts(r: number, g: number, b: number, a: number): Color4;
  74090. /**
  74091. * Check the content of a given array and convert it to an array containing RGBA data
  74092. * If the original array was already containing count * 4 values then it is returned directly
  74093. * @param colors defines the array to check
  74094. * @param count defines the number of RGBA data to expect
  74095. * @returns an array containing count * 4 values (RGBA)
  74096. */
  74097. static CheckColors4(colors: number[], count: number): number[];
  74098. }
  74099. /**
  74100. * @hidden
  74101. */
  74102. export class TmpColors {
  74103. static Color3: Color3[];
  74104. static Color4: Color4[];
  74105. }
  74106. }
  74107. declare module BABYLON {
  74108. /**
  74109. * Defines an interface which represents an animation key frame
  74110. */
  74111. export interface IAnimationKey {
  74112. /**
  74113. * Frame of the key frame
  74114. */
  74115. frame: number;
  74116. /**
  74117. * Value at the specifies key frame
  74118. */
  74119. value: any;
  74120. /**
  74121. * The input tangent for the cubic hermite spline
  74122. */
  74123. inTangent?: any;
  74124. /**
  74125. * The output tangent for the cubic hermite spline
  74126. */
  74127. outTangent?: any;
  74128. /**
  74129. * The animation interpolation type
  74130. */
  74131. interpolation?: AnimationKeyInterpolation;
  74132. }
  74133. /**
  74134. * Enum for the animation key frame interpolation type
  74135. */
  74136. export enum AnimationKeyInterpolation {
  74137. /**
  74138. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  74139. */
  74140. STEP = 1
  74141. }
  74142. }
  74143. declare module BABYLON {
  74144. /**
  74145. * Represents the range of an animation
  74146. */
  74147. export class AnimationRange {
  74148. /**The name of the animation range**/
  74149. name: string;
  74150. /**The starting frame of the animation */
  74151. from: number;
  74152. /**The ending frame of the animation*/
  74153. to: number;
  74154. /**
  74155. * Initializes the range of an animation
  74156. * @param name The name of the animation range
  74157. * @param from The starting frame of the animation
  74158. * @param to The ending frame of the animation
  74159. */
  74160. constructor(
  74161. /**The name of the animation range**/
  74162. name: string,
  74163. /**The starting frame of the animation */
  74164. from: number,
  74165. /**The ending frame of the animation*/
  74166. to: number);
  74167. /**
  74168. * Makes a copy of the animation range
  74169. * @returns A copy of the animation range
  74170. */
  74171. clone(): AnimationRange;
  74172. }
  74173. }
  74174. declare module BABYLON {
  74175. /**
  74176. * Composed of a frame, and an action function
  74177. */
  74178. export class AnimationEvent {
  74179. /** The frame for which the event is triggered **/
  74180. frame: number;
  74181. /** The event to perform when triggered **/
  74182. action: (currentFrame: number) => void;
  74183. /** Specifies if the event should be triggered only once**/
  74184. onlyOnce?: boolean | undefined;
  74185. /**
  74186. * Specifies if the animation event is done
  74187. */
  74188. isDone: boolean;
  74189. /**
  74190. * Initializes the animation event
  74191. * @param frame The frame for which the event is triggered
  74192. * @param action The event to perform when triggered
  74193. * @param onlyOnce Specifies if the event should be triggered only once
  74194. */
  74195. constructor(
  74196. /** The frame for which the event is triggered **/
  74197. frame: number,
  74198. /** The event to perform when triggered **/
  74199. action: (currentFrame: number) => void,
  74200. /** Specifies if the event should be triggered only once**/
  74201. onlyOnce?: boolean | undefined);
  74202. /** @hidden */
  74203. _clone(): AnimationEvent;
  74204. }
  74205. }
  74206. declare module BABYLON {
  74207. /**
  74208. * Interface used to define a behavior
  74209. */
  74210. export interface Behavior<T> {
  74211. /** gets or sets behavior's name */
  74212. name: string;
  74213. /**
  74214. * Function called when the behavior needs to be initialized (after attaching it to a target)
  74215. */
  74216. init(): void;
  74217. /**
  74218. * Called when the behavior is attached to a target
  74219. * @param target defines the target where the behavior is attached to
  74220. */
  74221. attach(target: T): void;
  74222. /**
  74223. * Called when the behavior is detached from its target
  74224. */
  74225. detach(): void;
  74226. }
  74227. /**
  74228. * Interface implemented by classes supporting behaviors
  74229. */
  74230. export interface IBehaviorAware<T> {
  74231. /**
  74232. * Attach a behavior
  74233. * @param behavior defines the behavior to attach
  74234. * @returns the current host
  74235. */
  74236. addBehavior(behavior: Behavior<T>): T;
  74237. /**
  74238. * Remove a behavior from the current object
  74239. * @param behavior defines the behavior to detach
  74240. * @returns the current host
  74241. */
  74242. removeBehavior(behavior: Behavior<T>): T;
  74243. /**
  74244. * Gets a behavior using its name to search
  74245. * @param name defines the name to search
  74246. * @returns the behavior or null if not found
  74247. */
  74248. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  74249. }
  74250. }
  74251. declare module BABYLON {
  74252. /**
  74253. * Defines an array and its length.
  74254. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  74255. */
  74256. export interface ISmartArrayLike<T> {
  74257. /**
  74258. * The data of the array.
  74259. */
  74260. data: Array<T>;
  74261. /**
  74262. * The active length of the array.
  74263. */
  74264. length: number;
  74265. }
  74266. /**
  74267. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74268. */
  74269. export class SmartArray<T> implements ISmartArrayLike<T> {
  74270. /**
  74271. * The full set of data from the array.
  74272. */
  74273. data: Array<T>;
  74274. /**
  74275. * The active length of the array.
  74276. */
  74277. length: number;
  74278. protected _id: number;
  74279. /**
  74280. * Instantiates a Smart Array.
  74281. * @param capacity defines the default capacity of the array.
  74282. */
  74283. constructor(capacity: number);
  74284. /**
  74285. * Pushes a value at the end of the active data.
  74286. * @param value defines the object to push in the array.
  74287. */
  74288. push(value: T): void;
  74289. /**
  74290. * Iterates over the active data and apply the lambda to them.
  74291. * @param func defines the action to apply on each value.
  74292. */
  74293. forEach(func: (content: T) => void): void;
  74294. /**
  74295. * Sorts the full sets of data.
  74296. * @param compareFn defines the comparison function to apply.
  74297. */
  74298. sort(compareFn: (a: T, b: T) => number): void;
  74299. /**
  74300. * Resets the active data to an empty array.
  74301. */
  74302. reset(): void;
  74303. /**
  74304. * Releases all the data from the array as well as the array.
  74305. */
  74306. dispose(): void;
  74307. /**
  74308. * Concats the active data with a given array.
  74309. * @param array defines the data to concatenate with.
  74310. */
  74311. concat(array: any): void;
  74312. /**
  74313. * Returns the position of a value in the active data.
  74314. * @param value defines the value to find the index for
  74315. * @returns the index if found in the active data otherwise -1
  74316. */
  74317. indexOf(value: T): number;
  74318. /**
  74319. * Returns whether an element is part of the active data.
  74320. * @param value defines the value to look for
  74321. * @returns true if found in the active data otherwise false
  74322. */
  74323. contains(value: T): boolean;
  74324. private static _GlobalId;
  74325. }
  74326. /**
  74327. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74328. * The data in this array can only be present once
  74329. */
  74330. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  74331. private _duplicateId;
  74332. /**
  74333. * Pushes a value at the end of the active data.
  74334. * THIS DOES NOT PREVENT DUPPLICATE DATA
  74335. * @param value defines the object to push in the array.
  74336. */
  74337. push(value: T): void;
  74338. /**
  74339. * Pushes a value at the end of the active data.
  74340. * If the data is already present, it won t be added again
  74341. * @param value defines the object to push in the array.
  74342. * @returns true if added false if it was already present
  74343. */
  74344. pushNoDuplicate(value: T): boolean;
  74345. /**
  74346. * Resets the active data to an empty array.
  74347. */
  74348. reset(): void;
  74349. /**
  74350. * Concats the active data with a given array.
  74351. * This ensures no dupplicate will be present in the result.
  74352. * @param array defines the data to concatenate with.
  74353. */
  74354. concatWithNoDuplicate(array: any): void;
  74355. }
  74356. }
  74357. declare module BABYLON {
  74358. /**
  74359. * @ignore
  74360. * This is a list of all the different input types that are available in the application.
  74361. * Fo instance: ArcRotateCameraGamepadInput...
  74362. */
  74363. export var CameraInputTypes: {};
  74364. /**
  74365. * This is the contract to implement in order to create a new input class.
  74366. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  74367. */
  74368. export interface ICameraInput<TCamera extends Camera> {
  74369. /**
  74370. * Defines the camera the input is attached to.
  74371. */
  74372. camera: Nullable<TCamera>;
  74373. /**
  74374. * Gets the class name of the current intput.
  74375. * @returns the class name
  74376. */
  74377. getClassName(): string;
  74378. /**
  74379. * Get the friendly name associated with the input class.
  74380. * @returns the input friendly name
  74381. */
  74382. getSimpleName(): string;
  74383. /**
  74384. * Attach the input controls to a specific dom element to get the input from.
  74385. * @param element Defines the element the controls should be listened from
  74386. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74387. */
  74388. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74389. /**
  74390. * Detach the current controls from the specified dom element.
  74391. * @param element Defines the element to stop listening the inputs from
  74392. */
  74393. detachControl(element: Nullable<HTMLElement>): void;
  74394. /**
  74395. * Update the current camera state depending on the inputs that have been used this frame.
  74396. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74397. */
  74398. checkInputs?: () => void;
  74399. }
  74400. /**
  74401. * Represents a map of input types to input instance or input index to input instance.
  74402. */
  74403. export interface CameraInputsMap<TCamera extends Camera> {
  74404. /**
  74405. * Accessor to the input by input type.
  74406. */
  74407. [name: string]: ICameraInput<TCamera>;
  74408. /**
  74409. * Accessor to the input by input index.
  74410. */
  74411. [idx: number]: ICameraInput<TCamera>;
  74412. }
  74413. /**
  74414. * This represents the input manager used within a camera.
  74415. * It helps dealing with all the different kind of input attached to a camera.
  74416. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74417. */
  74418. export class CameraInputsManager<TCamera extends Camera> {
  74419. /**
  74420. * Defines the list of inputs attahed to the camera.
  74421. */
  74422. attached: CameraInputsMap<TCamera>;
  74423. /**
  74424. * Defines the dom element the camera is collecting inputs from.
  74425. * This is null if the controls have not been attached.
  74426. */
  74427. attachedElement: Nullable<HTMLElement>;
  74428. /**
  74429. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74430. */
  74431. noPreventDefault: boolean;
  74432. /**
  74433. * Defined the camera the input manager belongs to.
  74434. */
  74435. camera: TCamera;
  74436. /**
  74437. * Update the current camera state depending on the inputs that have been used this frame.
  74438. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74439. */
  74440. checkInputs: () => void;
  74441. /**
  74442. * Instantiate a new Camera Input Manager.
  74443. * @param camera Defines the camera the input manager blongs to
  74444. */
  74445. constructor(camera: TCamera);
  74446. /**
  74447. * Add an input method to a camera
  74448. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74449. * @param input camera input method
  74450. */
  74451. add(input: ICameraInput<TCamera>): void;
  74452. /**
  74453. * Remove a specific input method from a camera
  74454. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  74455. * @param inputToRemove camera input method
  74456. */
  74457. remove(inputToRemove: ICameraInput<TCamera>): void;
  74458. /**
  74459. * Remove a specific input type from a camera
  74460. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  74461. * @param inputType the type of the input to remove
  74462. */
  74463. removeByType(inputType: string): void;
  74464. private _addCheckInputs;
  74465. /**
  74466. * Attach the input controls to the currently attached dom element to listen the events from.
  74467. * @param input Defines the input to attach
  74468. */
  74469. attachInput(input: ICameraInput<TCamera>): void;
  74470. /**
  74471. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  74472. * @param element Defines the dom element to collect the events from
  74473. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74474. */
  74475. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  74476. /**
  74477. * Detach the current manager inputs controls from a specific dom element.
  74478. * @param element Defines the dom element to collect the events from
  74479. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  74480. */
  74481. detachElement(element: HTMLElement, disconnect?: boolean): void;
  74482. /**
  74483. * Rebuild the dynamic inputCheck function from the current list of
  74484. * defined inputs in the manager.
  74485. */
  74486. rebuildInputCheck(): void;
  74487. /**
  74488. * Remove all attached input methods from a camera
  74489. */
  74490. clear(): void;
  74491. /**
  74492. * Serialize the current input manager attached to a camera.
  74493. * This ensures than once parsed,
  74494. * the input associated to the camera will be identical to the current ones
  74495. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  74496. */
  74497. serialize(serializedCamera: any): void;
  74498. /**
  74499. * Parses an input manager serialized JSON to restore the previous list of inputs
  74500. * and states associated to a camera.
  74501. * @param parsedCamera Defines the JSON to parse
  74502. */
  74503. parse(parsedCamera: any): void;
  74504. }
  74505. }
  74506. declare module BABYLON {
  74507. /**
  74508. * Class used to store data that will be store in GPU memory
  74509. */
  74510. export class Buffer {
  74511. private _engine;
  74512. private _buffer;
  74513. /** @hidden */
  74514. _data: Nullable<DataArray>;
  74515. private _updatable;
  74516. private _instanced;
  74517. private _divisor;
  74518. /**
  74519. * Gets the byte stride.
  74520. */
  74521. readonly byteStride: number;
  74522. /**
  74523. * Constructor
  74524. * @param engine the engine
  74525. * @param data the data to use for this buffer
  74526. * @param updatable whether the data is updatable
  74527. * @param stride the stride (optional)
  74528. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74529. * @param instanced whether the buffer is instanced (optional)
  74530. * @param useBytes set to true if the stride in in bytes (optional)
  74531. * @param divisor sets an optional divisor for instances (1 by default)
  74532. */
  74533. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  74534. /**
  74535. * Create a new VertexBuffer based on the current buffer
  74536. * @param kind defines the vertex buffer kind (position, normal, etc.)
  74537. * @param offset defines offset in the buffer (0 by default)
  74538. * @param size defines the size in floats of attributes (position is 3 for instance)
  74539. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  74540. * @param instanced defines if the vertex buffer contains indexed data
  74541. * @param useBytes defines if the offset and stride are in bytes *
  74542. * @param divisor sets an optional divisor for instances (1 by default)
  74543. * @returns the new vertex buffer
  74544. */
  74545. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  74546. /**
  74547. * Gets a boolean indicating if the Buffer is updatable?
  74548. * @returns true if the buffer is updatable
  74549. */
  74550. isUpdatable(): boolean;
  74551. /**
  74552. * Gets current buffer's data
  74553. * @returns a DataArray or null
  74554. */
  74555. getData(): Nullable<DataArray>;
  74556. /**
  74557. * Gets underlying native buffer
  74558. * @returns underlying native buffer
  74559. */
  74560. getBuffer(): Nullable<DataBuffer>;
  74561. /**
  74562. * Gets the stride in float32 units (i.e. byte stride / 4).
  74563. * May not be an integer if the byte stride is not divisible by 4.
  74564. * DEPRECATED. Use byteStride instead.
  74565. * @returns the stride in float32 units
  74566. */
  74567. getStrideSize(): number;
  74568. /**
  74569. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74570. * @param data defines the data to store
  74571. */
  74572. create(data?: Nullable<DataArray>): void;
  74573. /** @hidden */
  74574. _rebuild(): void;
  74575. /**
  74576. * Update current buffer data
  74577. * @param data defines the data to store
  74578. */
  74579. update(data: DataArray): void;
  74580. /**
  74581. * Updates the data directly.
  74582. * @param data the new data
  74583. * @param offset the new offset
  74584. * @param vertexCount the vertex count (optional)
  74585. * @param useBytes set to true if the offset is in bytes
  74586. */
  74587. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  74588. /**
  74589. * Release all resources
  74590. */
  74591. dispose(): void;
  74592. }
  74593. /**
  74594. * Specialized buffer used to store vertex data
  74595. */
  74596. export class VertexBuffer {
  74597. /** @hidden */
  74598. _buffer: Buffer;
  74599. private _kind;
  74600. private _size;
  74601. private _ownsBuffer;
  74602. private _instanced;
  74603. private _instanceDivisor;
  74604. /**
  74605. * The byte type.
  74606. */
  74607. static readonly BYTE: number;
  74608. /**
  74609. * The unsigned byte type.
  74610. */
  74611. static readonly UNSIGNED_BYTE: number;
  74612. /**
  74613. * The short type.
  74614. */
  74615. static readonly SHORT: number;
  74616. /**
  74617. * The unsigned short type.
  74618. */
  74619. static readonly UNSIGNED_SHORT: number;
  74620. /**
  74621. * The integer type.
  74622. */
  74623. static readonly INT: number;
  74624. /**
  74625. * The unsigned integer type.
  74626. */
  74627. static readonly UNSIGNED_INT: number;
  74628. /**
  74629. * The float type.
  74630. */
  74631. static readonly FLOAT: number;
  74632. /**
  74633. * Gets or sets the instance divisor when in instanced mode
  74634. */
  74635. instanceDivisor: number;
  74636. /**
  74637. * Gets the byte stride.
  74638. */
  74639. readonly byteStride: number;
  74640. /**
  74641. * Gets the byte offset.
  74642. */
  74643. readonly byteOffset: number;
  74644. /**
  74645. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  74646. */
  74647. readonly normalized: boolean;
  74648. /**
  74649. * Gets the data type of each component in the array.
  74650. */
  74651. readonly type: number;
  74652. /**
  74653. * Constructor
  74654. * @param engine the engine
  74655. * @param data the data to use for this vertex buffer
  74656. * @param kind the vertex buffer kind
  74657. * @param updatable whether the data is updatable
  74658. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74659. * @param stride the stride (optional)
  74660. * @param instanced whether the buffer is instanced (optional)
  74661. * @param offset the offset of the data (optional)
  74662. * @param size the number of components (optional)
  74663. * @param type the type of the component (optional)
  74664. * @param normalized whether the data contains normalized data (optional)
  74665. * @param useBytes set to true if stride and offset are in bytes (optional)
  74666. * @param divisor defines the instance divisor to use (1 by default)
  74667. */
  74668. 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);
  74669. /** @hidden */
  74670. _rebuild(): void;
  74671. /**
  74672. * Returns the kind of the VertexBuffer (string)
  74673. * @returns a string
  74674. */
  74675. getKind(): string;
  74676. /**
  74677. * Gets a boolean indicating if the VertexBuffer is updatable?
  74678. * @returns true if the buffer is updatable
  74679. */
  74680. isUpdatable(): boolean;
  74681. /**
  74682. * Gets current buffer's data
  74683. * @returns a DataArray or null
  74684. */
  74685. getData(): Nullable<DataArray>;
  74686. /**
  74687. * Gets underlying native buffer
  74688. * @returns underlying native buffer
  74689. */
  74690. getBuffer(): Nullable<DataBuffer>;
  74691. /**
  74692. * Gets the stride in float32 units (i.e. byte stride / 4).
  74693. * May not be an integer if the byte stride is not divisible by 4.
  74694. * DEPRECATED. Use byteStride instead.
  74695. * @returns the stride in float32 units
  74696. */
  74697. getStrideSize(): number;
  74698. /**
  74699. * Returns the offset as a multiple of the type byte length.
  74700. * DEPRECATED. Use byteOffset instead.
  74701. * @returns the offset in bytes
  74702. */
  74703. getOffset(): number;
  74704. /**
  74705. * Returns the number of components per vertex attribute (integer)
  74706. * @returns the size in float
  74707. */
  74708. getSize(): number;
  74709. /**
  74710. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  74711. * @returns true if this buffer is instanced
  74712. */
  74713. getIsInstanced(): boolean;
  74714. /**
  74715. * Returns the instancing divisor, zero for non-instanced (integer).
  74716. * @returns a number
  74717. */
  74718. getInstanceDivisor(): number;
  74719. /**
  74720. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74721. * @param data defines the data to store
  74722. */
  74723. create(data?: DataArray): void;
  74724. /**
  74725. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  74726. * This function will create a new buffer if the current one is not updatable
  74727. * @param data defines the data to store
  74728. */
  74729. update(data: DataArray): void;
  74730. /**
  74731. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  74732. * Returns the directly updated WebGLBuffer.
  74733. * @param data the new data
  74734. * @param offset the new offset
  74735. * @param useBytes set to true if the offset is in bytes
  74736. */
  74737. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  74738. /**
  74739. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  74740. */
  74741. dispose(): void;
  74742. /**
  74743. * Enumerates each value of this vertex buffer as numbers.
  74744. * @param count the number of values to enumerate
  74745. * @param callback the callback function called for each value
  74746. */
  74747. forEach(count: number, callback: (value: number, index: number) => void): void;
  74748. /**
  74749. * Positions
  74750. */
  74751. static readonly PositionKind: string;
  74752. /**
  74753. * Normals
  74754. */
  74755. static readonly NormalKind: string;
  74756. /**
  74757. * Tangents
  74758. */
  74759. static readonly TangentKind: string;
  74760. /**
  74761. * Texture coordinates
  74762. */
  74763. static readonly UVKind: string;
  74764. /**
  74765. * Texture coordinates 2
  74766. */
  74767. static readonly UV2Kind: string;
  74768. /**
  74769. * Texture coordinates 3
  74770. */
  74771. static readonly UV3Kind: string;
  74772. /**
  74773. * Texture coordinates 4
  74774. */
  74775. static readonly UV4Kind: string;
  74776. /**
  74777. * Texture coordinates 5
  74778. */
  74779. static readonly UV5Kind: string;
  74780. /**
  74781. * Texture coordinates 6
  74782. */
  74783. static readonly UV6Kind: string;
  74784. /**
  74785. * Colors
  74786. */
  74787. static readonly ColorKind: string;
  74788. /**
  74789. * Matrix indices (for bones)
  74790. */
  74791. static readonly MatricesIndicesKind: string;
  74792. /**
  74793. * Matrix weights (for bones)
  74794. */
  74795. static readonly MatricesWeightsKind: string;
  74796. /**
  74797. * Additional matrix indices (for bones)
  74798. */
  74799. static readonly MatricesIndicesExtraKind: string;
  74800. /**
  74801. * Additional matrix weights (for bones)
  74802. */
  74803. static readonly MatricesWeightsExtraKind: string;
  74804. /**
  74805. * Deduces the stride given a kind.
  74806. * @param kind The kind string to deduce
  74807. * @returns The deduced stride
  74808. */
  74809. static DeduceStride(kind: string): number;
  74810. /**
  74811. * Gets the byte length of the given type.
  74812. * @param type the type
  74813. * @returns the number of bytes
  74814. */
  74815. static GetTypeByteLength(type: number): number;
  74816. /**
  74817. * Enumerates each value of the given parameters as numbers.
  74818. * @param data the data to enumerate
  74819. * @param byteOffset the byte offset of the data
  74820. * @param byteStride the byte stride of the data
  74821. * @param componentCount the number of components per element
  74822. * @param componentType the type of the component
  74823. * @param count the number of values to enumerate
  74824. * @param normalized whether the data is normalized
  74825. * @param callback the callback function called for each value
  74826. */
  74827. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  74828. private static _GetFloatValue;
  74829. }
  74830. }
  74831. declare module BABYLON {
  74832. /**
  74833. * @hidden
  74834. */
  74835. export class IntersectionInfo {
  74836. bu: Nullable<number>;
  74837. bv: Nullable<number>;
  74838. distance: number;
  74839. faceId: number;
  74840. subMeshId: number;
  74841. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  74842. }
  74843. }
  74844. declare module BABYLON {
  74845. /**
  74846. * Represens a plane by the equation ax + by + cz + d = 0
  74847. */
  74848. export class Plane {
  74849. private static _TmpMatrix;
  74850. /**
  74851. * Normal of the plane (a,b,c)
  74852. */
  74853. normal: Vector3;
  74854. /**
  74855. * d component of the plane
  74856. */
  74857. d: number;
  74858. /**
  74859. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  74860. * @param a a component of the plane
  74861. * @param b b component of the plane
  74862. * @param c c component of the plane
  74863. * @param d d component of the plane
  74864. */
  74865. constructor(a: number, b: number, c: number, d: number);
  74866. /**
  74867. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  74868. */
  74869. asArray(): number[];
  74870. /**
  74871. * @returns a new plane copied from the current Plane.
  74872. */
  74873. clone(): Plane;
  74874. /**
  74875. * @returns the string "Plane".
  74876. */
  74877. getClassName(): string;
  74878. /**
  74879. * @returns the Plane hash code.
  74880. */
  74881. getHashCode(): number;
  74882. /**
  74883. * Normalize the current Plane in place.
  74884. * @returns the updated Plane.
  74885. */
  74886. normalize(): Plane;
  74887. /**
  74888. * Applies a transformation the plane and returns the result
  74889. * @param transformation the transformation matrix to be applied to the plane
  74890. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  74891. */
  74892. transform(transformation: DeepImmutable<Matrix>): Plane;
  74893. /**
  74894. * Calcualtte the dot product between the point and the plane normal
  74895. * @param point point to calculate the dot product with
  74896. * @returns the dot product (float) of the point coordinates and the plane normal.
  74897. */
  74898. dotCoordinate(point: DeepImmutable<Vector3>): number;
  74899. /**
  74900. * Updates the current Plane from the plane defined by the three given points.
  74901. * @param point1 one of the points used to contruct the plane
  74902. * @param point2 one of the points used to contruct the plane
  74903. * @param point3 one of the points used to contruct the plane
  74904. * @returns the updated Plane.
  74905. */
  74906. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74907. /**
  74908. * Checks if the plane is facing a given direction
  74909. * @param direction the direction to check if the plane is facing
  74910. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  74911. * @returns True is the vector "direction" is the same side than the plane normal.
  74912. */
  74913. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  74914. /**
  74915. * Calculates the distance to a point
  74916. * @param point point to calculate distance to
  74917. * @returns the signed distance (float) from the given point to the Plane.
  74918. */
  74919. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  74920. /**
  74921. * Creates a plane from an array
  74922. * @param array the array to create a plane from
  74923. * @returns a new Plane from the given array.
  74924. */
  74925. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  74926. /**
  74927. * Creates a plane from three points
  74928. * @param point1 point used to create the plane
  74929. * @param point2 point used to create the plane
  74930. * @param point3 point used to create the plane
  74931. * @returns a new Plane defined by the three given points.
  74932. */
  74933. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74934. /**
  74935. * Creates a plane from an origin point and a normal
  74936. * @param origin origin of the plane to be constructed
  74937. * @param normal normal of the plane to be constructed
  74938. * @returns a new Plane the normal vector to this plane at the given origin point.
  74939. * Note : the vector "normal" is updated because normalized.
  74940. */
  74941. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  74942. /**
  74943. * Calculates the distance from a plane and a point
  74944. * @param origin origin of the plane to be constructed
  74945. * @param normal normal of the plane to be constructed
  74946. * @param point point to calculate distance to
  74947. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  74948. */
  74949. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  74950. }
  74951. }
  74952. declare module BABYLON {
  74953. /**
  74954. * Class used to store bounding sphere information
  74955. */
  74956. export class BoundingSphere {
  74957. /**
  74958. * Gets the center of the bounding sphere in local space
  74959. */
  74960. readonly center: Vector3;
  74961. /**
  74962. * Radius of the bounding sphere in local space
  74963. */
  74964. radius: number;
  74965. /**
  74966. * Gets the center of the bounding sphere in world space
  74967. */
  74968. readonly centerWorld: Vector3;
  74969. /**
  74970. * Radius of the bounding sphere in world space
  74971. */
  74972. radiusWorld: number;
  74973. /**
  74974. * Gets the minimum vector in local space
  74975. */
  74976. readonly minimum: Vector3;
  74977. /**
  74978. * Gets the maximum vector in local space
  74979. */
  74980. readonly maximum: Vector3;
  74981. private _worldMatrix;
  74982. private static readonly TmpVector3;
  74983. /**
  74984. * Creates a new bounding sphere
  74985. * @param min defines the minimum vector (in local space)
  74986. * @param max defines the maximum vector (in local space)
  74987. * @param worldMatrix defines the new world matrix
  74988. */
  74989. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74990. /**
  74991. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  74992. * @param min defines the new minimum vector (in local space)
  74993. * @param max defines the new maximum vector (in local space)
  74994. * @param worldMatrix defines the new world matrix
  74995. */
  74996. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74997. /**
  74998. * Scale the current bounding sphere by applying a scale factor
  74999. * @param factor defines the scale factor to apply
  75000. * @returns the current bounding box
  75001. */
  75002. scale(factor: number): BoundingSphere;
  75003. /**
  75004. * Gets the world matrix of the bounding box
  75005. * @returns a matrix
  75006. */
  75007. getWorldMatrix(): DeepImmutable<Matrix>;
  75008. /** @hidden */
  75009. _update(worldMatrix: DeepImmutable<Matrix>): void;
  75010. /**
  75011. * Tests if the bounding sphere is intersecting the frustum planes
  75012. * @param frustumPlanes defines the frustum planes to test
  75013. * @returns true if there is an intersection
  75014. */
  75015. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75016. /**
  75017. * Tests if the bounding sphere center is in between the frustum planes.
  75018. * Used for optimistic fast inclusion.
  75019. * @param frustumPlanes defines the frustum planes to test
  75020. * @returns true if the sphere center is in between the frustum planes
  75021. */
  75022. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75023. /**
  75024. * Tests if a point is inside the bounding sphere
  75025. * @param point defines the point to test
  75026. * @returns true if the point is inside the bounding sphere
  75027. */
  75028. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75029. /**
  75030. * Checks if two sphere intersct
  75031. * @param sphere0 sphere 0
  75032. * @param sphere1 sphere 1
  75033. * @returns true if the speres intersect
  75034. */
  75035. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  75036. }
  75037. }
  75038. declare module BABYLON {
  75039. /**
  75040. * Class used to store bounding box information
  75041. */
  75042. export class BoundingBox implements ICullable {
  75043. /**
  75044. * Gets the 8 vectors representing the bounding box in local space
  75045. */
  75046. readonly vectors: Vector3[];
  75047. /**
  75048. * Gets the center of the bounding box in local space
  75049. */
  75050. readonly center: Vector3;
  75051. /**
  75052. * Gets the center of the bounding box in world space
  75053. */
  75054. readonly centerWorld: Vector3;
  75055. /**
  75056. * Gets the extend size in local space
  75057. */
  75058. readonly extendSize: Vector3;
  75059. /**
  75060. * Gets the extend size in world space
  75061. */
  75062. readonly extendSizeWorld: Vector3;
  75063. /**
  75064. * Gets the OBB (object bounding box) directions
  75065. */
  75066. readonly directions: Vector3[];
  75067. /**
  75068. * Gets the 8 vectors representing the bounding box in world space
  75069. */
  75070. readonly vectorsWorld: Vector3[];
  75071. /**
  75072. * Gets the minimum vector in world space
  75073. */
  75074. readonly minimumWorld: Vector3;
  75075. /**
  75076. * Gets the maximum vector in world space
  75077. */
  75078. readonly maximumWorld: Vector3;
  75079. /**
  75080. * Gets the minimum vector in local space
  75081. */
  75082. readonly minimum: Vector3;
  75083. /**
  75084. * Gets the maximum vector in local space
  75085. */
  75086. readonly maximum: Vector3;
  75087. private _worldMatrix;
  75088. private static readonly TmpVector3;
  75089. /**
  75090. * @hidden
  75091. */
  75092. _tag: number;
  75093. /**
  75094. * Creates a new bounding box
  75095. * @param min defines the minimum vector (in local space)
  75096. * @param max defines the maximum vector (in local space)
  75097. * @param worldMatrix defines the new world matrix
  75098. */
  75099. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75100. /**
  75101. * Recreates the entire bounding box from scratch as if we call the constructor in place
  75102. * @param min defines the new minimum vector (in local space)
  75103. * @param max defines the new maximum vector (in local space)
  75104. * @param worldMatrix defines the new world matrix
  75105. */
  75106. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75107. /**
  75108. * Scale the current bounding box by applying a scale factor
  75109. * @param factor defines the scale factor to apply
  75110. * @returns the current bounding box
  75111. */
  75112. scale(factor: number): BoundingBox;
  75113. /**
  75114. * Gets the world matrix of the bounding box
  75115. * @returns a matrix
  75116. */
  75117. getWorldMatrix(): DeepImmutable<Matrix>;
  75118. /** @hidden */
  75119. _update(world: DeepImmutable<Matrix>): void;
  75120. /**
  75121. * Tests if the bounding box is intersecting the frustum planes
  75122. * @param frustumPlanes defines the frustum planes to test
  75123. * @returns true if there is an intersection
  75124. */
  75125. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75126. /**
  75127. * Tests if the bounding box is entirely inside the frustum planes
  75128. * @param frustumPlanes defines the frustum planes to test
  75129. * @returns true if there is an inclusion
  75130. */
  75131. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75132. /**
  75133. * Tests if a point is inside the bounding box
  75134. * @param point defines the point to test
  75135. * @returns true if the point is inside the bounding box
  75136. */
  75137. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75138. /**
  75139. * Tests if the bounding box intersects with a bounding sphere
  75140. * @param sphere defines the sphere to test
  75141. * @returns true if there is an intersection
  75142. */
  75143. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  75144. /**
  75145. * Tests if the bounding box intersects with a box defined by a min and max vectors
  75146. * @param min defines the min vector to use
  75147. * @param max defines the max vector to use
  75148. * @returns true if there is an intersection
  75149. */
  75150. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  75151. /**
  75152. * Tests if two bounding boxes are intersections
  75153. * @param box0 defines the first box to test
  75154. * @param box1 defines the second box to test
  75155. * @returns true if there is an intersection
  75156. */
  75157. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  75158. /**
  75159. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  75160. * @param minPoint defines the minimum vector of the bounding box
  75161. * @param maxPoint defines the maximum vector of the bounding box
  75162. * @param sphereCenter defines the sphere center
  75163. * @param sphereRadius defines the sphere radius
  75164. * @returns true if there is an intersection
  75165. */
  75166. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  75167. /**
  75168. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  75169. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75170. * @param frustumPlanes defines the frustum planes to test
  75171. * @return true if there is an inclusion
  75172. */
  75173. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75174. /**
  75175. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  75176. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75177. * @param frustumPlanes defines the frustum planes to test
  75178. * @return true if there is an intersection
  75179. */
  75180. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75181. }
  75182. }
  75183. declare module BABYLON {
  75184. /** @hidden */
  75185. export class Collider {
  75186. /** Define if a collision was found */
  75187. collisionFound: boolean;
  75188. /**
  75189. * Define last intersection point in local space
  75190. */
  75191. intersectionPoint: Vector3;
  75192. /**
  75193. * Define last collided mesh
  75194. */
  75195. collidedMesh: Nullable<AbstractMesh>;
  75196. private _collisionPoint;
  75197. private _planeIntersectionPoint;
  75198. private _tempVector;
  75199. private _tempVector2;
  75200. private _tempVector3;
  75201. private _tempVector4;
  75202. private _edge;
  75203. private _baseToVertex;
  75204. private _destinationPoint;
  75205. private _slidePlaneNormal;
  75206. private _displacementVector;
  75207. /** @hidden */
  75208. _radius: Vector3;
  75209. /** @hidden */
  75210. _retry: number;
  75211. private _velocity;
  75212. private _basePoint;
  75213. private _epsilon;
  75214. /** @hidden */
  75215. _velocityWorldLength: number;
  75216. /** @hidden */
  75217. _basePointWorld: Vector3;
  75218. private _velocityWorld;
  75219. private _normalizedVelocity;
  75220. /** @hidden */
  75221. _initialVelocity: Vector3;
  75222. /** @hidden */
  75223. _initialPosition: Vector3;
  75224. private _nearestDistance;
  75225. private _collisionMask;
  75226. collisionMask: number;
  75227. /**
  75228. * Gets the plane normal used to compute the sliding response (in local space)
  75229. */
  75230. readonly slidePlaneNormal: Vector3;
  75231. /** @hidden */
  75232. _initialize(source: Vector3, dir: Vector3, e: number): void;
  75233. /** @hidden */
  75234. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  75235. /** @hidden */
  75236. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  75237. /** @hidden */
  75238. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75239. /** @hidden */
  75240. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75241. /** @hidden */
  75242. _getResponse(pos: Vector3, vel: Vector3): void;
  75243. }
  75244. }
  75245. declare module BABYLON {
  75246. /**
  75247. * Interface for cullable objects
  75248. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  75249. */
  75250. export interface ICullable {
  75251. /**
  75252. * Checks if the object or part of the object is in the frustum
  75253. * @param frustumPlanes Camera near/planes
  75254. * @returns true if the object is in frustum otherwise false
  75255. */
  75256. isInFrustum(frustumPlanes: Plane[]): boolean;
  75257. /**
  75258. * Checks if a cullable object (mesh...) is in the camera frustum
  75259. * Unlike isInFrustum this cheks the full bounding box
  75260. * @param frustumPlanes Camera near/planes
  75261. * @returns true if the object is in frustum otherwise false
  75262. */
  75263. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  75264. }
  75265. /**
  75266. * Info for a bounding data of a mesh
  75267. */
  75268. export class BoundingInfo implements ICullable {
  75269. /**
  75270. * Bounding box for the mesh
  75271. */
  75272. readonly boundingBox: BoundingBox;
  75273. /**
  75274. * Bounding sphere for the mesh
  75275. */
  75276. readonly boundingSphere: BoundingSphere;
  75277. private _isLocked;
  75278. private static readonly TmpVector3;
  75279. /**
  75280. * Constructs bounding info
  75281. * @param minimum min vector of the bounding box/sphere
  75282. * @param maximum max vector of the bounding box/sphere
  75283. * @param worldMatrix defines the new world matrix
  75284. */
  75285. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75286. /**
  75287. * Recreates the entire bounding info from scratch as if we call the constructor in place
  75288. * @param min defines the new minimum vector (in local space)
  75289. * @param max defines the new maximum vector (in local space)
  75290. * @param worldMatrix defines the new world matrix
  75291. */
  75292. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75293. /**
  75294. * min vector of the bounding box/sphere
  75295. */
  75296. readonly minimum: Vector3;
  75297. /**
  75298. * max vector of the bounding box/sphere
  75299. */
  75300. readonly maximum: Vector3;
  75301. /**
  75302. * If the info is locked and won't be updated to avoid perf overhead
  75303. */
  75304. isLocked: boolean;
  75305. /**
  75306. * Updates the bounding sphere and box
  75307. * @param world world matrix to be used to update
  75308. */
  75309. update(world: DeepImmutable<Matrix>): void;
  75310. /**
  75311. * Recreate the bounding info to be centered around a specific point given a specific extend.
  75312. * @param center New center of the bounding info
  75313. * @param extend New extend of the bounding info
  75314. * @returns the current bounding info
  75315. */
  75316. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  75317. /**
  75318. * Scale the current bounding info by applying a scale factor
  75319. * @param factor defines the scale factor to apply
  75320. * @returns the current bounding info
  75321. */
  75322. scale(factor: number): BoundingInfo;
  75323. /**
  75324. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  75325. * @param frustumPlanes defines the frustum to test
  75326. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  75327. * @returns true if the bounding info is in the frustum planes
  75328. */
  75329. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  75330. /**
  75331. * Gets the world distance between the min and max points of the bounding box
  75332. */
  75333. readonly diagonalLength: number;
  75334. /**
  75335. * Checks if a cullable object (mesh...) is in the camera frustum
  75336. * Unlike isInFrustum this cheks the full bounding box
  75337. * @param frustumPlanes Camera near/planes
  75338. * @returns true if the object is in frustum otherwise false
  75339. */
  75340. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75341. /** @hidden */
  75342. _checkCollision(collider: Collider): boolean;
  75343. /**
  75344. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  75345. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75346. * @param point the point to check intersection with
  75347. * @returns if the point intersects
  75348. */
  75349. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75350. /**
  75351. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  75352. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75353. * @param boundingInfo the bounding info to check intersection with
  75354. * @param precise if the intersection should be done using OBB
  75355. * @returns if the bounding info intersects
  75356. */
  75357. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  75358. }
  75359. }
  75360. declare module BABYLON {
  75361. /**
  75362. * Extracts minimum and maximum values from a list of indexed positions
  75363. * @param positions defines the positions to use
  75364. * @param indices defines the indices to the positions
  75365. * @param indexStart defines the start index
  75366. * @param indexCount defines the end index
  75367. * @param bias defines bias value to add to the result
  75368. * @return minimum and maximum values
  75369. */
  75370. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  75371. minimum: Vector3;
  75372. maximum: Vector3;
  75373. };
  75374. /**
  75375. * Extracts minimum and maximum values from a list of positions
  75376. * @param positions defines the positions to use
  75377. * @param start defines the start index in the positions array
  75378. * @param count defines the number of positions to handle
  75379. * @param bias defines bias value to add to the result
  75380. * @param stride defines the stride size to use (distance between two positions in the positions array)
  75381. * @return minimum and maximum values
  75382. */
  75383. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  75384. minimum: Vector3;
  75385. maximum: Vector3;
  75386. };
  75387. }
  75388. declare module BABYLON {
  75389. /** @hidden */
  75390. export class WebGLDataBuffer extends DataBuffer {
  75391. private _buffer;
  75392. constructor(resource: WebGLBuffer);
  75393. readonly underlyingResource: any;
  75394. }
  75395. }
  75396. declare module BABYLON {
  75397. /** @hidden */
  75398. export class WebGLPipelineContext implements IPipelineContext {
  75399. engine: ThinEngine;
  75400. program: Nullable<WebGLProgram>;
  75401. context?: WebGLRenderingContext;
  75402. vertexShader?: WebGLShader;
  75403. fragmentShader?: WebGLShader;
  75404. isParallelCompiled: boolean;
  75405. onCompiled?: () => void;
  75406. transformFeedback?: WebGLTransformFeedback | null;
  75407. readonly isAsync: boolean;
  75408. readonly isReady: boolean;
  75409. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  75410. }
  75411. }
  75412. declare module BABYLON {
  75413. interface ThinEngine {
  75414. /**
  75415. * Create an uniform buffer
  75416. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75417. * @param elements defines the content of the uniform buffer
  75418. * @returns the webGL uniform buffer
  75419. */
  75420. createUniformBuffer(elements: FloatArray): DataBuffer;
  75421. /**
  75422. * Create a dynamic uniform buffer
  75423. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75424. * @param elements defines the content of the uniform buffer
  75425. * @returns the webGL uniform buffer
  75426. */
  75427. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  75428. /**
  75429. * Update an existing uniform buffer
  75430. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75431. * @param uniformBuffer defines the target uniform buffer
  75432. * @param elements defines the content to update
  75433. * @param offset defines the offset in the uniform buffer where update should start
  75434. * @param count defines the size of the data to update
  75435. */
  75436. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  75437. /**
  75438. * Bind an uniform buffer to the current webGL context
  75439. * @param buffer defines the buffer to bind
  75440. */
  75441. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  75442. /**
  75443. * Bind a buffer to the current webGL context at a given location
  75444. * @param buffer defines the buffer to bind
  75445. * @param location defines the index where to bind the buffer
  75446. */
  75447. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  75448. /**
  75449. * Bind a specific block at a given index in a specific shader program
  75450. * @param pipelineContext defines the pipeline context to use
  75451. * @param blockName defines the block name
  75452. * @param index defines the index where to bind the block
  75453. */
  75454. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  75455. }
  75456. }
  75457. declare module BABYLON {
  75458. /**
  75459. * Uniform buffer objects.
  75460. *
  75461. * Handles blocks of uniform on the GPU.
  75462. *
  75463. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75464. *
  75465. * For more information, please refer to :
  75466. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75467. */
  75468. export class UniformBuffer {
  75469. private _engine;
  75470. private _buffer;
  75471. private _data;
  75472. private _bufferData;
  75473. private _dynamic?;
  75474. private _uniformLocations;
  75475. private _uniformSizes;
  75476. private _uniformLocationPointer;
  75477. private _needSync;
  75478. private _noUBO;
  75479. private _currentEffect;
  75480. /** @hidden */
  75481. _alreadyBound: boolean;
  75482. private static _MAX_UNIFORM_SIZE;
  75483. private static _tempBuffer;
  75484. /**
  75485. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  75486. * This is dynamic to allow compat with webgl 1 and 2.
  75487. * You will need to pass the name of the uniform as well as the value.
  75488. */
  75489. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  75490. /**
  75491. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  75492. * This is dynamic to allow compat with webgl 1 and 2.
  75493. * You will need to pass the name of the uniform as well as the value.
  75494. */
  75495. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  75496. /**
  75497. * Lambda to Update a single float in a uniform buffer.
  75498. * This is dynamic to allow compat with webgl 1 and 2.
  75499. * You will need to pass the name of the uniform as well as the value.
  75500. */
  75501. updateFloat: (name: string, x: number) => void;
  75502. /**
  75503. * Lambda to Update a vec2 of float in a uniform buffer.
  75504. * This is dynamic to allow compat with webgl 1 and 2.
  75505. * You will need to pass the name of the uniform as well as the value.
  75506. */
  75507. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  75508. /**
  75509. * Lambda to Update a vec3 of float in a uniform buffer.
  75510. * This is dynamic to allow compat with webgl 1 and 2.
  75511. * You will need to pass the name of the uniform as well as the value.
  75512. */
  75513. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  75514. /**
  75515. * Lambda to Update a vec4 of float in a uniform buffer.
  75516. * This is dynamic to allow compat with webgl 1 and 2.
  75517. * You will need to pass the name of the uniform as well as the value.
  75518. */
  75519. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  75520. /**
  75521. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  75522. * This is dynamic to allow compat with webgl 1 and 2.
  75523. * You will need to pass the name of the uniform as well as the value.
  75524. */
  75525. updateMatrix: (name: string, mat: Matrix) => void;
  75526. /**
  75527. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  75528. * This is dynamic to allow compat with webgl 1 and 2.
  75529. * You will need to pass the name of the uniform as well as the value.
  75530. */
  75531. updateVector3: (name: string, vector: Vector3) => void;
  75532. /**
  75533. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  75534. * This is dynamic to allow compat with webgl 1 and 2.
  75535. * You will need to pass the name of the uniform as well as the value.
  75536. */
  75537. updateVector4: (name: string, vector: Vector4) => void;
  75538. /**
  75539. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  75540. * This is dynamic to allow compat with webgl 1 and 2.
  75541. * You will need to pass the name of the uniform as well as the value.
  75542. */
  75543. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  75544. /**
  75545. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  75546. * This is dynamic to allow compat with webgl 1 and 2.
  75547. * You will need to pass the name of the uniform as well as the value.
  75548. */
  75549. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  75550. /**
  75551. * Instantiates a new Uniform buffer objects.
  75552. *
  75553. * Handles blocks of uniform on the GPU.
  75554. *
  75555. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75556. *
  75557. * For more information, please refer to :
  75558. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75559. * @param engine Define the engine the buffer is associated with
  75560. * @param data Define the data contained in the buffer
  75561. * @param dynamic Define if the buffer is updatable
  75562. */
  75563. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  75564. /**
  75565. * Indicates if the buffer is using the WebGL2 UBO implementation,
  75566. * or just falling back on setUniformXXX calls.
  75567. */
  75568. readonly useUbo: boolean;
  75569. /**
  75570. * Indicates if the WebGL underlying uniform buffer is in sync
  75571. * with the javascript cache data.
  75572. */
  75573. readonly isSync: boolean;
  75574. /**
  75575. * Indicates if the WebGL underlying uniform buffer is dynamic.
  75576. * Also, a dynamic UniformBuffer will disable cache verification and always
  75577. * update the underlying WebGL uniform buffer to the GPU.
  75578. * @returns if Dynamic, otherwise false
  75579. */
  75580. isDynamic(): boolean;
  75581. /**
  75582. * The data cache on JS side.
  75583. * @returns the underlying data as a float array
  75584. */
  75585. getData(): Float32Array;
  75586. /**
  75587. * The underlying WebGL Uniform buffer.
  75588. * @returns the webgl buffer
  75589. */
  75590. getBuffer(): Nullable<DataBuffer>;
  75591. /**
  75592. * std140 layout specifies how to align data within an UBO structure.
  75593. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  75594. * for specs.
  75595. */
  75596. private _fillAlignment;
  75597. /**
  75598. * Adds an uniform in the buffer.
  75599. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  75600. * for the layout to be correct !
  75601. * @param name Name of the uniform, as used in the uniform block in the shader.
  75602. * @param size Data size, or data directly.
  75603. */
  75604. addUniform(name: string, size: number | number[]): void;
  75605. /**
  75606. * Adds a Matrix 4x4 to the uniform buffer.
  75607. * @param name Name of the uniform, as used in the uniform block in the shader.
  75608. * @param mat A 4x4 matrix.
  75609. */
  75610. addMatrix(name: string, mat: Matrix): void;
  75611. /**
  75612. * Adds a vec2 to the uniform buffer.
  75613. * @param name Name of the uniform, as used in the uniform block in the shader.
  75614. * @param x Define the x component value of the vec2
  75615. * @param y Define the y component value of the vec2
  75616. */
  75617. addFloat2(name: string, x: number, y: number): void;
  75618. /**
  75619. * Adds a vec3 to the uniform buffer.
  75620. * @param name Name of the uniform, as used in the uniform block in the shader.
  75621. * @param x Define the x component value of the vec3
  75622. * @param y Define the y component value of the vec3
  75623. * @param z Define the z component value of the vec3
  75624. */
  75625. addFloat3(name: string, x: number, y: number, z: number): void;
  75626. /**
  75627. * Adds a vec3 to the uniform buffer.
  75628. * @param name Name of the uniform, as used in the uniform block in the shader.
  75629. * @param color Define the vec3 from a Color
  75630. */
  75631. addColor3(name: string, color: Color3): void;
  75632. /**
  75633. * Adds a vec4 to the uniform buffer.
  75634. * @param name Name of the uniform, as used in the uniform block in the shader.
  75635. * @param color Define the rgb components from a Color
  75636. * @param alpha Define the a component of the vec4
  75637. */
  75638. addColor4(name: string, color: Color3, alpha: number): void;
  75639. /**
  75640. * Adds a vec3 to the uniform buffer.
  75641. * @param name Name of the uniform, as used in the uniform block in the shader.
  75642. * @param vector Define the vec3 components from a Vector
  75643. */
  75644. addVector3(name: string, vector: Vector3): void;
  75645. /**
  75646. * Adds a Matrix 3x3 to the uniform buffer.
  75647. * @param name Name of the uniform, as used in the uniform block in the shader.
  75648. */
  75649. addMatrix3x3(name: string): void;
  75650. /**
  75651. * Adds a Matrix 2x2 to the uniform buffer.
  75652. * @param name Name of the uniform, as used in the uniform block in the shader.
  75653. */
  75654. addMatrix2x2(name: string): void;
  75655. /**
  75656. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  75657. */
  75658. create(): void;
  75659. /** @hidden */
  75660. _rebuild(): void;
  75661. /**
  75662. * Updates the WebGL Uniform Buffer on the GPU.
  75663. * If the `dynamic` flag is set to true, no cache comparison is done.
  75664. * Otherwise, the buffer will be updated only if the cache differs.
  75665. */
  75666. update(): void;
  75667. /**
  75668. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  75669. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75670. * @param data Define the flattened data
  75671. * @param size Define the size of the data.
  75672. */
  75673. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  75674. private _valueCache;
  75675. private _cacheMatrix;
  75676. private _updateMatrix3x3ForUniform;
  75677. private _updateMatrix3x3ForEffect;
  75678. private _updateMatrix2x2ForEffect;
  75679. private _updateMatrix2x2ForUniform;
  75680. private _updateFloatForEffect;
  75681. private _updateFloatForUniform;
  75682. private _updateFloat2ForEffect;
  75683. private _updateFloat2ForUniform;
  75684. private _updateFloat3ForEffect;
  75685. private _updateFloat3ForUniform;
  75686. private _updateFloat4ForEffect;
  75687. private _updateFloat4ForUniform;
  75688. private _updateMatrixForEffect;
  75689. private _updateMatrixForUniform;
  75690. private _updateVector3ForEffect;
  75691. private _updateVector3ForUniform;
  75692. private _updateVector4ForEffect;
  75693. private _updateVector4ForUniform;
  75694. private _updateColor3ForEffect;
  75695. private _updateColor3ForUniform;
  75696. private _updateColor4ForEffect;
  75697. private _updateColor4ForUniform;
  75698. /**
  75699. * Sets a sampler uniform on the effect.
  75700. * @param name Define the name of the sampler.
  75701. * @param texture Define the texture to set in the sampler
  75702. */
  75703. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  75704. /**
  75705. * Directly updates the value of the uniform in the cache AND on the GPU.
  75706. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75707. * @param data Define the flattened data
  75708. */
  75709. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  75710. /**
  75711. * Binds this uniform buffer to an effect.
  75712. * @param effect Define the effect to bind the buffer to
  75713. * @param name Name of the uniform block in the shader.
  75714. */
  75715. bindToEffect(effect: Effect, name: string): void;
  75716. /**
  75717. * Disposes the uniform buffer.
  75718. */
  75719. dispose(): void;
  75720. }
  75721. }
  75722. declare module BABYLON {
  75723. /**
  75724. * Enum that determines the text-wrapping mode to use.
  75725. */
  75726. export enum InspectableType {
  75727. /**
  75728. * Checkbox for booleans
  75729. */
  75730. Checkbox = 0,
  75731. /**
  75732. * Sliders for numbers
  75733. */
  75734. Slider = 1,
  75735. /**
  75736. * Vector3
  75737. */
  75738. Vector3 = 2,
  75739. /**
  75740. * Quaternions
  75741. */
  75742. Quaternion = 3,
  75743. /**
  75744. * Color3
  75745. */
  75746. Color3 = 4,
  75747. /**
  75748. * String
  75749. */
  75750. String = 5
  75751. }
  75752. /**
  75753. * Interface used to define custom inspectable properties.
  75754. * This interface is used by the inspector to display custom property grids
  75755. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75756. */
  75757. export interface IInspectable {
  75758. /**
  75759. * Gets the label to display
  75760. */
  75761. label: string;
  75762. /**
  75763. * Gets the name of the property to edit
  75764. */
  75765. propertyName: string;
  75766. /**
  75767. * Gets the type of the editor to use
  75768. */
  75769. type: InspectableType;
  75770. /**
  75771. * Gets the minimum value of the property when using in "slider" mode
  75772. */
  75773. min?: number;
  75774. /**
  75775. * Gets the maximum value of the property when using in "slider" mode
  75776. */
  75777. max?: number;
  75778. /**
  75779. * Gets the setp to use when using in "slider" mode
  75780. */
  75781. step?: number;
  75782. }
  75783. }
  75784. declare module BABYLON {
  75785. /**
  75786. * Class used to provide helper for timing
  75787. */
  75788. export class TimingTools {
  75789. /**
  75790. * Polyfill for setImmediate
  75791. * @param action defines the action to execute after the current execution block
  75792. */
  75793. static SetImmediate(action: () => void): void;
  75794. }
  75795. }
  75796. declare module BABYLON {
  75797. /**
  75798. * Class used to enable instatition of objects by class name
  75799. */
  75800. export class InstantiationTools {
  75801. /**
  75802. * Use this object to register external classes like custom textures or material
  75803. * to allow the laoders to instantiate them
  75804. */
  75805. static RegisteredExternalClasses: {
  75806. [key: string]: Object;
  75807. };
  75808. /**
  75809. * Tries to instantiate a new object from a given class name
  75810. * @param className defines the class name to instantiate
  75811. * @returns the new object or null if the system was not able to do the instantiation
  75812. */
  75813. static Instantiate(className: string): any;
  75814. }
  75815. }
  75816. declare module BABYLON {
  75817. /**
  75818. * Define options used to create a depth texture
  75819. */
  75820. export class DepthTextureCreationOptions {
  75821. /** Specifies whether or not a stencil should be allocated in the texture */
  75822. generateStencil?: boolean;
  75823. /** Specifies whether or not bilinear filtering is enable on the texture */
  75824. bilinearFiltering?: boolean;
  75825. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  75826. comparisonFunction?: number;
  75827. /** Specifies if the created texture is a cube texture */
  75828. isCube?: boolean;
  75829. }
  75830. }
  75831. declare module BABYLON {
  75832. interface ThinEngine {
  75833. /**
  75834. * Creates a depth stencil cube texture.
  75835. * This is only available in WebGL 2.
  75836. * @param size The size of face edge in the cube texture.
  75837. * @param options The options defining the cube texture.
  75838. * @returns The cube texture
  75839. */
  75840. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  75841. /**
  75842. * Creates a cube texture
  75843. * @param rootUrl defines the url where the files to load is located
  75844. * @param scene defines the current scene
  75845. * @param files defines the list of files to load (1 per face)
  75846. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75847. * @param onLoad defines an optional callback raised when the texture is loaded
  75848. * @param onError defines an optional callback raised if there is an issue to load the texture
  75849. * @param format defines the format of the data
  75850. * @param forcedExtension defines the extension to use to pick the right loader
  75851. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75852. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75853. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75854. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  75855. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  75856. * @returns the cube texture as an InternalTexture
  75857. */
  75858. 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;
  75859. /**
  75860. * Creates a cube texture
  75861. * @param rootUrl defines the url where the files to load is located
  75862. * @param scene defines the current scene
  75863. * @param files defines the list of files to load (1 per face)
  75864. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75865. * @param onLoad defines an optional callback raised when the texture is loaded
  75866. * @param onError defines an optional callback raised if there is an issue to load the texture
  75867. * @param format defines the format of the data
  75868. * @param forcedExtension defines the extension to use to pick the right loader
  75869. * @returns the cube texture as an InternalTexture
  75870. */
  75871. 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;
  75872. /**
  75873. * Creates a cube texture
  75874. * @param rootUrl defines the url where the files to load is located
  75875. * @param scene defines the current scene
  75876. * @param files defines the list of files to load (1 per face)
  75877. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75878. * @param onLoad defines an optional callback raised when the texture is loaded
  75879. * @param onError defines an optional callback raised if there is an issue to load the texture
  75880. * @param format defines the format of the data
  75881. * @param forcedExtension defines the extension to use to pick the right loader
  75882. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75883. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75884. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75885. * @returns the cube texture as an InternalTexture
  75886. */
  75887. 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;
  75888. /** @hidden */
  75889. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  75890. /** @hidden */
  75891. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  75892. /** @hidden */
  75893. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75894. /** @hidden */
  75895. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75896. /**
  75897. * @hidden
  75898. */
  75899. _setCubeMapTextureParams(loadMipmap: boolean): void;
  75900. }
  75901. }
  75902. declare module BABYLON {
  75903. /**
  75904. * Class for creating a cube texture
  75905. */
  75906. export class CubeTexture extends BaseTexture {
  75907. private _delayedOnLoad;
  75908. /**
  75909. * The url of the texture
  75910. */
  75911. url: string;
  75912. /**
  75913. * Gets or sets the center of the bounding box associated with the cube texture.
  75914. * It must define where the camera used to render the texture was set
  75915. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75916. */
  75917. boundingBoxPosition: Vector3;
  75918. private _boundingBoxSize;
  75919. /**
  75920. * Gets or sets the size of the bounding box associated with the cube texture
  75921. * When defined, the cubemap will switch to local mode
  75922. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75923. * @example https://www.babylonjs-playground.com/#RNASML
  75924. */
  75925. /**
  75926. * Returns the bounding box size
  75927. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75928. */
  75929. boundingBoxSize: Vector3;
  75930. protected _rotationY: number;
  75931. /**
  75932. * Sets texture matrix rotation angle around Y axis in radians.
  75933. */
  75934. /**
  75935. * Gets texture matrix rotation angle around Y axis radians.
  75936. */
  75937. rotationY: number;
  75938. /**
  75939. * Are mip maps generated for this texture or not.
  75940. */
  75941. readonly noMipmap: boolean;
  75942. private _noMipmap;
  75943. private _files;
  75944. protected _forcedExtension: Nullable<string>;
  75945. private _extensions;
  75946. private _textureMatrix;
  75947. private _format;
  75948. private _createPolynomials;
  75949. /** @hidden */
  75950. _prefiltered: boolean;
  75951. /**
  75952. * Creates a cube texture from an array of image urls
  75953. * @param files defines an array of image urls
  75954. * @param scene defines the hosting scene
  75955. * @param noMipmap specifies if mip maps are not used
  75956. * @returns a cube texture
  75957. */
  75958. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  75959. /**
  75960. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  75961. * @param url defines the url of the prefiltered texture
  75962. * @param scene defines the scene the texture is attached to
  75963. * @param forcedExtension defines the extension of the file if different from the url
  75964. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75965. * @return the prefiltered texture
  75966. */
  75967. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  75968. /**
  75969. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  75970. * as prefiltered data.
  75971. * @param rootUrl defines the url of the texture or the root name of the six images
  75972. * @param scene defines the scene the texture is attached to
  75973. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  75974. * @param noMipmap defines if mipmaps should be created or not
  75975. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  75976. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  75977. * @param onError defines a callback triggered in case of error during load
  75978. * @param format defines the internal format to use for the texture once loaded
  75979. * @param prefiltered defines whether or not the texture is created from prefiltered data
  75980. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  75981. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75982. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75983. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75984. * @return the cube texture
  75985. */
  75986. 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);
  75987. /**
  75988. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  75989. */
  75990. readonly isPrefiltered: boolean;
  75991. /**
  75992. * Get the current class name of the texture useful for serialization or dynamic coding.
  75993. * @returns "CubeTexture"
  75994. */
  75995. getClassName(): string;
  75996. /**
  75997. * Update the url (and optional buffer) of this texture if url was null during construction.
  75998. * @param url the url of the texture
  75999. * @param forcedExtension defines the extension to use
  76000. * @param onLoad callback called when the texture is loaded (defaults to null)
  76001. */
  76002. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  76003. /**
  76004. * Delays loading of the cube texture
  76005. * @param forcedExtension defines the extension to use
  76006. */
  76007. delayLoad(forcedExtension?: string): void;
  76008. /**
  76009. * Returns the reflection texture matrix
  76010. * @returns the reflection texture matrix
  76011. */
  76012. getReflectionTextureMatrix(): Matrix;
  76013. /**
  76014. * Sets the reflection texture matrix
  76015. * @param value Reflection texture matrix
  76016. */
  76017. setReflectionTextureMatrix(value: Matrix): void;
  76018. /**
  76019. * Parses text to create a cube texture
  76020. * @param parsedTexture define the serialized text to read from
  76021. * @param scene defines the hosting scene
  76022. * @param rootUrl defines the root url of the cube texture
  76023. * @returns a cube texture
  76024. */
  76025. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  76026. /**
  76027. * Makes a clone, or deep copy, of the cube texture
  76028. * @returns a new cube texture
  76029. */
  76030. clone(): CubeTexture;
  76031. }
  76032. }
  76033. declare module BABYLON {
  76034. /**
  76035. * Manages the defines for the Material
  76036. */
  76037. export class MaterialDefines {
  76038. /** @hidden */
  76039. protected _keys: string[];
  76040. private _isDirty;
  76041. /** @hidden */
  76042. _renderId: number;
  76043. /** @hidden */
  76044. _areLightsDirty: boolean;
  76045. /** @hidden */
  76046. _areLightsDisposed: boolean;
  76047. /** @hidden */
  76048. _areAttributesDirty: boolean;
  76049. /** @hidden */
  76050. _areTexturesDirty: boolean;
  76051. /** @hidden */
  76052. _areFresnelDirty: boolean;
  76053. /** @hidden */
  76054. _areMiscDirty: boolean;
  76055. /** @hidden */
  76056. _areImageProcessingDirty: boolean;
  76057. /** @hidden */
  76058. _normals: boolean;
  76059. /** @hidden */
  76060. _uvs: boolean;
  76061. /** @hidden */
  76062. _needNormals: boolean;
  76063. /** @hidden */
  76064. _needUVs: boolean;
  76065. [id: string]: any;
  76066. /**
  76067. * Specifies if the material needs to be re-calculated
  76068. */
  76069. readonly isDirty: boolean;
  76070. /**
  76071. * Marks the material to indicate that it has been re-calculated
  76072. */
  76073. markAsProcessed(): void;
  76074. /**
  76075. * Marks the material to indicate that it needs to be re-calculated
  76076. */
  76077. markAsUnprocessed(): void;
  76078. /**
  76079. * Marks the material to indicate all of its defines need to be re-calculated
  76080. */
  76081. markAllAsDirty(): void;
  76082. /**
  76083. * Marks the material to indicate that image processing needs to be re-calculated
  76084. */
  76085. markAsImageProcessingDirty(): void;
  76086. /**
  76087. * Marks the material to indicate the lights need to be re-calculated
  76088. * @param disposed Defines whether the light is dirty due to dispose or not
  76089. */
  76090. markAsLightDirty(disposed?: boolean): void;
  76091. /**
  76092. * Marks the attribute state as changed
  76093. */
  76094. markAsAttributesDirty(): void;
  76095. /**
  76096. * Marks the texture state as changed
  76097. */
  76098. markAsTexturesDirty(): void;
  76099. /**
  76100. * Marks the fresnel state as changed
  76101. */
  76102. markAsFresnelDirty(): void;
  76103. /**
  76104. * Marks the misc state as changed
  76105. */
  76106. markAsMiscDirty(): void;
  76107. /**
  76108. * Rebuilds the material defines
  76109. */
  76110. rebuild(): void;
  76111. /**
  76112. * Specifies if two material defines are equal
  76113. * @param other - A material define instance to compare to
  76114. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  76115. */
  76116. isEqual(other: MaterialDefines): boolean;
  76117. /**
  76118. * Clones this instance's defines to another instance
  76119. * @param other - material defines to clone values to
  76120. */
  76121. cloneTo(other: MaterialDefines): void;
  76122. /**
  76123. * Resets the material define values
  76124. */
  76125. reset(): void;
  76126. /**
  76127. * Converts the material define values to a string
  76128. * @returns - String of material define information
  76129. */
  76130. toString(): string;
  76131. }
  76132. }
  76133. declare module BABYLON {
  76134. /**
  76135. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  76136. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  76137. * 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;
  76138. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  76139. */
  76140. export class ColorCurves {
  76141. private _dirty;
  76142. private _tempColor;
  76143. private _globalCurve;
  76144. private _highlightsCurve;
  76145. private _midtonesCurve;
  76146. private _shadowsCurve;
  76147. private _positiveCurve;
  76148. private _negativeCurve;
  76149. private _globalHue;
  76150. private _globalDensity;
  76151. private _globalSaturation;
  76152. private _globalExposure;
  76153. /**
  76154. * Gets the global Hue value.
  76155. * 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).
  76156. */
  76157. /**
  76158. * Sets the global Hue value.
  76159. * 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).
  76160. */
  76161. globalHue: number;
  76162. /**
  76163. * Gets the global 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. /**
  76168. * Sets the global Density value.
  76169. * 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.
  76170. * Values less than zero provide a filter of opposite hue.
  76171. */
  76172. globalDensity: number;
  76173. /**
  76174. * Gets the global Saturation value.
  76175. * 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.
  76176. */
  76177. /**
  76178. * Sets the global Saturation 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 saturation and negative values decrease saturation.
  76180. */
  76181. globalSaturation: number;
  76182. /**
  76183. * Gets the global Exposure value.
  76184. * 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.
  76185. */
  76186. /**
  76187. * Sets the global Exposure value.
  76188. * 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.
  76189. */
  76190. globalExposure: number;
  76191. private _highlightsHue;
  76192. private _highlightsDensity;
  76193. private _highlightsSaturation;
  76194. private _highlightsExposure;
  76195. /**
  76196. * Gets the highlights Hue value.
  76197. * 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).
  76198. */
  76199. /**
  76200. * Sets the highlights Hue value.
  76201. * 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).
  76202. */
  76203. highlightsHue: number;
  76204. /**
  76205. * Gets the highlights Density value.
  76206. * 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.
  76207. * Values less than zero provide a filter of opposite hue.
  76208. */
  76209. /**
  76210. * Sets the highlights Density value.
  76211. * 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.
  76212. * Values less than zero provide a filter of opposite hue.
  76213. */
  76214. highlightsDensity: number;
  76215. /**
  76216. * Gets the highlights Saturation value.
  76217. * 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.
  76218. */
  76219. /**
  76220. * Sets the highlights Saturation value.
  76221. * 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.
  76222. */
  76223. highlightsSaturation: number;
  76224. /**
  76225. * Gets the highlights Exposure value.
  76226. * 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.
  76227. */
  76228. /**
  76229. * Sets the highlights Exposure value.
  76230. * 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.
  76231. */
  76232. highlightsExposure: number;
  76233. private _midtonesHue;
  76234. private _midtonesDensity;
  76235. private _midtonesSaturation;
  76236. private _midtonesExposure;
  76237. /**
  76238. * Gets the midtones Hue value.
  76239. * 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).
  76240. */
  76241. /**
  76242. * Sets the midtones Hue value.
  76243. * 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).
  76244. */
  76245. midtonesHue: number;
  76246. /**
  76247. * Gets the midtones Density value.
  76248. * 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.
  76249. * Values less than zero provide a filter of opposite hue.
  76250. */
  76251. /**
  76252. * Sets the midtones Density value.
  76253. * 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.
  76254. * Values less than zero provide a filter of opposite hue.
  76255. */
  76256. midtonesDensity: number;
  76257. /**
  76258. * Gets the midtones Saturation value.
  76259. * 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.
  76260. */
  76261. /**
  76262. * Sets the midtones Saturation value.
  76263. * 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.
  76264. */
  76265. midtonesSaturation: number;
  76266. /**
  76267. * Gets the midtones Exposure value.
  76268. * 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.
  76269. */
  76270. /**
  76271. * Sets the midtones Exposure value.
  76272. * 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.
  76273. */
  76274. midtonesExposure: number;
  76275. private _shadowsHue;
  76276. private _shadowsDensity;
  76277. private _shadowsSaturation;
  76278. private _shadowsExposure;
  76279. /**
  76280. * Gets the shadows Hue value.
  76281. * 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).
  76282. */
  76283. /**
  76284. * Sets the shadows Hue value.
  76285. * 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).
  76286. */
  76287. shadowsHue: number;
  76288. /**
  76289. * Gets the shadows Density value.
  76290. * 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.
  76291. * Values less than zero provide a filter of opposite hue.
  76292. */
  76293. /**
  76294. * Sets the shadows Density value.
  76295. * 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.
  76296. * Values less than zero provide a filter of opposite hue.
  76297. */
  76298. shadowsDensity: number;
  76299. /**
  76300. * Gets the shadows Saturation value.
  76301. * 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.
  76302. */
  76303. /**
  76304. * Sets the shadows Saturation value.
  76305. * 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.
  76306. */
  76307. shadowsSaturation: number;
  76308. /**
  76309. * Gets the shadows Exposure value.
  76310. * 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.
  76311. */
  76312. /**
  76313. * Sets the shadows Exposure value.
  76314. * 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.
  76315. */
  76316. shadowsExposure: number;
  76317. /**
  76318. * Returns the class name
  76319. * @returns The class name
  76320. */
  76321. getClassName(): string;
  76322. /**
  76323. * Binds the color curves to the shader.
  76324. * @param colorCurves The color curve to bind
  76325. * @param effect The effect to bind to
  76326. * @param positiveUniform The positive uniform shader parameter
  76327. * @param neutralUniform The neutral uniform shader parameter
  76328. * @param negativeUniform The negative uniform shader parameter
  76329. */
  76330. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  76331. /**
  76332. * Prepare the list of uniforms associated with the ColorCurves effects.
  76333. * @param uniformsList The list of uniforms used in the effect
  76334. */
  76335. static PrepareUniforms(uniformsList: string[]): void;
  76336. /**
  76337. * Returns color grading data based on a hue, density, saturation and exposure value.
  76338. * @param filterHue The hue of the color filter.
  76339. * @param filterDensity The density of the color filter.
  76340. * @param saturation The saturation.
  76341. * @param exposure The exposure.
  76342. * @param result The result data container.
  76343. */
  76344. private getColorGradingDataToRef;
  76345. /**
  76346. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  76347. * @param value The input slider value in range [-100,100].
  76348. * @returns Adjusted value.
  76349. */
  76350. private static applyColorGradingSliderNonlinear;
  76351. /**
  76352. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  76353. * @param hue The hue (H) input.
  76354. * @param saturation The saturation (S) input.
  76355. * @param brightness The brightness (B) input.
  76356. * @result An RGBA color represented as Vector4.
  76357. */
  76358. private static fromHSBToRef;
  76359. /**
  76360. * Returns a value clamped between min and max
  76361. * @param value The value to clamp
  76362. * @param min The minimum of value
  76363. * @param max The maximum of value
  76364. * @returns The clamped value.
  76365. */
  76366. private static clamp;
  76367. /**
  76368. * Clones the current color curve instance.
  76369. * @return The cloned curves
  76370. */
  76371. clone(): ColorCurves;
  76372. /**
  76373. * Serializes the current color curve instance to a json representation.
  76374. * @return a JSON representation
  76375. */
  76376. serialize(): any;
  76377. /**
  76378. * Parses the color curve from a json representation.
  76379. * @param source the JSON source to parse
  76380. * @return The parsed curves
  76381. */
  76382. static Parse(source: any): ColorCurves;
  76383. }
  76384. }
  76385. declare module BABYLON {
  76386. /**
  76387. * Interface to follow in your material defines to integrate easily the
  76388. * Image proccessing functions.
  76389. * @hidden
  76390. */
  76391. export interface IImageProcessingConfigurationDefines {
  76392. IMAGEPROCESSING: boolean;
  76393. VIGNETTE: boolean;
  76394. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76395. VIGNETTEBLENDMODEOPAQUE: boolean;
  76396. TONEMAPPING: boolean;
  76397. TONEMAPPING_ACES: boolean;
  76398. CONTRAST: boolean;
  76399. EXPOSURE: boolean;
  76400. COLORCURVES: boolean;
  76401. COLORGRADING: boolean;
  76402. COLORGRADING3D: boolean;
  76403. SAMPLER3DGREENDEPTH: boolean;
  76404. SAMPLER3DBGRMAP: boolean;
  76405. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76406. }
  76407. /**
  76408. * @hidden
  76409. */
  76410. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  76411. IMAGEPROCESSING: boolean;
  76412. VIGNETTE: boolean;
  76413. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76414. VIGNETTEBLENDMODEOPAQUE: boolean;
  76415. TONEMAPPING: boolean;
  76416. TONEMAPPING_ACES: boolean;
  76417. CONTRAST: boolean;
  76418. COLORCURVES: boolean;
  76419. COLORGRADING: boolean;
  76420. COLORGRADING3D: boolean;
  76421. SAMPLER3DGREENDEPTH: boolean;
  76422. SAMPLER3DBGRMAP: boolean;
  76423. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76424. EXPOSURE: boolean;
  76425. constructor();
  76426. }
  76427. /**
  76428. * This groups together the common properties used for image processing either in direct forward pass
  76429. * or through post processing effect depending on the use of the image processing pipeline in your scene
  76430. * or not.
  76431. */
  76432. export class ImageProcessingConfiguration {
  76433. /**
  76434. * Default tone mapping applied in BabylonJS.
  76435. */
  76436. static readonly TONEMAPPING_STANDARD: number;
  76437. /**
  76438. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  76439. * to other engines rendering to increase portability.
  76440. */
  76441. static readonly TONEMAPPING_ACES: number;
  76442. /**
  76443. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  76444. */
  76445. colorCurves: Nullable<ColorCurves>;
  76446. private _colorCurvesEnabled;
  76447. /**
  76448. * Gets wether the color curves effect is enabled.
  76449. */
  76450. /**
  76451. * Sets wether the color curves effect is enabled.
  76452. */
  76453. colorCurvesEnabled: boolean;
  76454. private _colorGradingTexture;
  76455. /**
  76456. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76457. */
  76458. /**
  76459. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76460. */
  76461. colorGradingTexture: Nullable<BaseTexture>;
  76462. private _colorGradingEnabled;
  76463. /**
  76464. * Gets wether the color grading effect is enabled.
  76465. */
  76466. /**
  76467. * Sets wether the color grading effect is enabled.
  76468. */
  76469. colorGradingEnabled: boolean;
  76470. private _colorGradingWithGreenDepth;
  76471. /**
  76472. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  76473. */
  76474. /**
  76475. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  76476. */
  76477. colorGradingWithGreenDepth: boolean;
  76478. private _colorGradingBGR;
  76479. /**
  76480. * Gets wether the color grading texture contains BGR values.
  76481. */
  76482. /**
  76483. * Sets wether the color grading texture contains BGR values.
  76484. */
  76485. colorGradingBGR: boolean;
  76486. /** @hidden */
  76487. _exposure: number;
  76488. /**
  76489. * Gets the Exposure used in the effect.
  76490. */
  76491. /**
  76492. * Sets the Exposure used in the effect.
  76493. */
  76494. exposure: number;
  76495. private _toneMappingEnabled;
  76496. /**
  76497. * Gets wether the tone mapping effect is enabled.
  76498. */
  76499. /**
  76500. * Sets wether the tone mapping effect is enabled.
  76501. */
  76502. toneMappingEnabled: boolean;
  76503. private _toneMappingType;
  76504. /**
  76505. * Gets the type of tone mapping effect.
  76506. */
  76507. /**
  76508. * Sets the type of tone mapping effect used in BabylonJS.
  76509. */
  76510. toneMappingType: number;
  76511. protected _contrast: number;
  76512. /**
  76513. * Gets the contrast used in the effect.
  76514. */
  76515. /**
  76516. * Sets the contrast used in the effect.
  76517. */
  76518. contrast: number;
  76519. /**
  76520. * Vignette stretch size.
  76521. */
  76522. vignetteStretch: number;
  76523. /**
  76524. * Vignette centre X Offset.
  76525. */
  76526. vignetteCentreX: number;
  76527. /**
  76528. * Vignette centre Y Offset.
  76529. */
  76530. vignetteCentreY: number;
  76531. /**
  76532. * Vignette weight or intensity of the vignette effect.
  76533. */
  76534. vignetteWeight: number;
  76535. /**
  76536. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  76537. * if vignetteEnabled is set to true.
  76538. */
  76539. vignetteColor: Color4;
  76540. /**
  76541. * Camera field of view used by the Vignette effect.
  76542. */
  76543. vignetteCameraFov: number;
  76544. private _vignetteBlendMode;
  76545. /**
  76546. * Gets the vignette blend mode allowing different kind of effect.
  76547. */
  76548. /**
  76549. * Sets the vignette blend mode allowing different kind of effect.
  76550. */
  76551. vignetteBlendMode: number;
  76552. private _vignetteEnabled;
  76553. /**
  76554. * Gets wether the vignette effect is enabled.
  76555. */
  76556. /**
  76557. * Sets wether the vignette effect is enabled.
  76558. */
  76559. vignetteEnabled: boolean;
  76560. private _applyByPostProcess;
  76561. /**
  76562. * Gets wether the image processing is applied through a post process or not.
  76563. */
  76564. /**
  76565. * Sets wether the image processing is applied through a post process or not.
  76566. */
  76567. applyByPostProcess: boolean;
  76568. private _isEnabled;
  76569. /**
  76570. * Gets wether the image processing is enabled or not.
  76571. */
  76572. /**
  76573. * Sets wether the image processing is enabled or not.
  76574. */
  76575. isEnabled: boolean;
  76576. /**
  76577. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  76578. */
  76579. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  76580. /**
  76581. * Method called each time the image processing information changes requires to recompile the effect.
  76582. */
  76583. protected _updateParameters(): void;
  76584. /**
  76585. * Gets the current class name.
  76586. * @return "ImageProcessingConfiguration"
  76587. */
  76588. getClassName(): string;
  76589. /**
  76590. * Prepare the list of uniforms associated with the Image Processing effects.
  76591. * @param uniforms The list of uniforms used in the effect
  76592. * @param defines the list of defines currently in use
  76593. */
  76594. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  76595. /**
  76596. * Prepare the list of samplers associated with the Image Processing effects.
  76597. * @param samplersList The list of uniforms used in the effect
  76598. * @param defines the list of defines currently in use
  76599. */
  76600. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  76601. /**
  76602. * Prepare the list of defines associated to the shader.
  76603. * @param defines the list of defines to complete
  76604. * @param forPostProcess Define if we are currently in post process mode or not
  76605. */
  76606. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  76607. /**
  76608. * Returns true if all the image processing information are ready.
  76609. * @returns True if ready, otherwise, false
  76610. */
  76611. isReady(): boolean;
  76612. /**
  76613. * Binds the image processing to the shader.
  76614. * @param effect The effect to bind to
  76615. * @param overrideAspectRatio Override the aspect ratio of the effect
  76616. */
  76617. bind(effect: Effect, overrideAspectRatio?: number): void;
  76618. /**
  76619. * Clones the current image processing instance.
  76620. * @return The cloned image processing
  76621. */
  76622. clone(): ImageProcessingConfiguration;
  76623. /**
  76624. * Serializes the current image processing instance to a json representation.
  76625. * @return a JSON representation
  76626. */
  76627. serialize(): any;
  76628. /**
  76629. * Parses the image processing from a json representation.
  76630. * @param source the JSON source to parse
  76631. * @return The parsed image processing
  76632. */
  76633. static Parse(source: any): ImageProcessingConfiguration;
  76634. private static _VIGNETTEMODE_MULTIPLY;
  76635. private static _VIGNETTEMODE_OPAQUE;
  76636. /**
  76637. * Used to apply the vignette as a mix with the pixel color.
  76638. */
  76639. static readonly VIGNETTEMODE_MULTIPLY: number;
  76640. /**
  76641. * Used to apply the vignette as a replacement of the pixel color.
  76642. */
  76643. static readonly VIGNETTEMODE_OPAQUE: number;
  76644. }
  76645. }
  76646. declare module BABYLON {
  76647. /** @hidden */
  76648. export var postprocessVertexShader: {
  76649. name: string;
  76650. shader: string;
  76651. };
  76652. }
  76653. declare module BABYLON {
  76654. interface ThinEngine {
  76655. /**
  76656. * Creates a new render target texture
  76657. * @param size defines the size of the texture
  76658. * @param options defines the options used to create the texture
  76659. * @returns a new render target texture stored in an InternalTexture
  76660. */
  76661. createRenderTargetTexture(size: number | {
  76662. width: number;
  76663. height: number;
  76664. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  76665. /**
  76666. * Creates a depth stencil texture.
  76667. * This is only available in WebGL 2 or with the depth texture extension available.
  76668. * @param size The size of face edge in the texture.
  76669. * @param options The options defining the texture.
  76670. * @returns The texture
  76671. */
  76672. createDepthStencilTexture(size: number | {
  76673. width: number;
  76674. height: number;
  76675. }, options: DepthTextureCreationOptions): InternalTexture;
  76676. /** @hidden */
  76677. _createDepthStencilTexture(size: number | {
  76678. width: number;
  76679. height: number;
  76680. }, options: DepthTextureCreationOptions): InternalTexture;
  76681. }
  76682. }
  76683. declare module BABYLON {
  76684. /** Defines supported spaces */
  76685. export enum Space {
  76686. /** Local (object) space */
  76687. LOCAL = 0,
  76688. /** World space */
  76689. WORLD = 1,
  76690. /** Bone space */
  76691. BONE = 2
  76692. }
  76693. /** Defines the 3 main axes */
  76694. export class Axis {
  76695. /** X axis */
  76696. static X: Vector3;
  76697. /** Y axis */
  76698. static Y: Vector3;
  76699. /** Z axis */
  76700. static Z: Vector3;
  76701. }
  76702. }
  76703. declare module BABYLON {
  76704. /**
  76705. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  76706. * This is the base of the follow, arc rotate cameras and Free camera
  76707. * @see http://doc.babylonjs.com/features/cameras
  76708. */
  76709. export class TargetCamera extends Camera {
  76710. private static _RigCamTransformMatrix;
  76711. private static _TargetTransformMatrix;
  76712. private static _TargetFocalPoint;
  76713. /**
  76714. * Define the current direction the camera is moving to
  76715. */
  76716. cameraDirection: Vector3;
  76717. /**
  76718. * Define the current rotation the camera is rotating to
  76719. */
  76720. cameraRotation: Vector2;
  76721. /**
  76722. * When set, the up vector of the camera will be updated by the rotation of the camera
  76723. */
  76724. updateUpVectorFromRotation: boolean;
  76725. private _tmpQuaternion;
  76726. /**
  76727. * Define the current rotation of the camera
  76728. */
  76729. rotation: Vector3;
  76730. /**
  76731. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  76732. */
  76733. rotationQuaternion: Quaternion;
  76734. /**
  76735. * Define the current speed of the camera
  76736. */
  76737. speed: number;
  76738. /**
  76739. * Add constraint to the camera to prevent it to move freely in all directions and
  76740. * around all axis.
  76741. */
  76742. noRotationConstraint: boolean;
  76743. /**
  76744. * Define the current target of the camera as an object or a position.
  76745. */
  76746. lockedTarget: any;
  76747. /** @hidden */
  76748. _currentTarget: Vector3;
  76749. /** @hidden */
  76750. _initialFocalDistance: number;
  76751. /** @hidden */
  76752. _viewMatrix: Matrix;
  76753. /** @hidden */
  76754. _camMatrix: Matrix;
  76755. /** @hidden */
  76756. _cameraTransformMatrix: Matrix;
  76757. /** @hidden */
  76758. _cameraRotationMatrix: Matrix;
  76759. /** @hidden */
  76760. _referencePoint: Vector3;
  76761. /** @hidden */
  76762. _transformedReferencePoint: Vector3;
  76763. protected _globalCurrentTarget: Vector3;
  76764. protected _globalCurrentUpVector: Vector3;
  76765. /** @hidden */
  76766. _reset: () => void;
  76767. private _defaultUp;
  76768. /**
  76769. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  76770. * This is the base of the follow, arc rotate cameras and Free camera
  76771. * @see http://doc.babylonjs.com/features/cameras
  76772. * @param name Defines the name of the camera in the scene
  76773. * @param position Defines the start position of the camera in the scene
  76774. * @param scene Defines the scene the camera belongs to
  76775. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76776. */
  76777. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76778. /**
  76779. * Gets the position in front of the camera at a given distance.
  76780. * @param distance The distance from the camera we want the position to be
  76781. * @returns the position
  76782. */
  76783. getFrontPosition(distance: number): Vector3;
  76784. /** @hidden */
  76785. _getLockedTargetPosition(): Nullable<Vector3>;
  76786. private _storedPosition;
  76787. private _storedRotation;
  76788. private _storedRotationQuaternion;
  76789. /**
  76790. * Store current camera state of the camera (fov, position, rotation, etc..)
  76791. * @returns the camera
  76792. */
  76793. storeState(): Camera;
  76794. /**
  76795. * Restored camera state. You must call storeState() first
  76796. * @returns whether it was successful or not
  76797. * @hidden
  76798. */
  76799. _restoreStateValues(): boolean;
  76800. /** @hidden */
  76801. _initCache(): void;
  76802. /** @hidden */
  76803. _updateCache(ignoreParentClass?: boolean): void;
  76804. /** @hidden */
  76805. _isSynchronizedViewMatrix(): boolean;
  76806. /** @hidden */
  76807. _computeLocalCameraSpeed(): number;
  76808. /**
  76809. * Defines the target the camera should look at.
  76810. * @param target Defines the new target as a Vector or a mesh
  76811. */
  76812. setTarget(target: Vector3): void;
  76813. /**
  76814. * Return the current target position of the camera. This value is expressed in local space.
  76815. * @returns the target position
  76816. */
  76817. getTarget(): Vector3;
  76818. /** @hidden */
  76819. _decideIfNeedsToMove(): boolean;
  76820. /** @hidden */
  76821. _updatePosition(): void;
  76822. /** @hidden */
  76823. _checkInputs(): void;
  76824. protected _updateCameraRotationMatrix(): void;
  76825. /**
  76826. * 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)
  76827. * @returns the current camera
  76828. */
  76829. private _rotateUpVectorWithCameraRotationMatrix;
  76830. private _cachedRotationZ;
  76831. private _cachedQuaternionRotationZ;
  76832. /** @hidden */
  76833. _getViewMatrix(): Matrix;
  76834. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  76835. /**
  76836. * @hidden
  76837. */
  76838. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  76839. /**
  76840. * @hidden
  76841. */
  76842. _updateRigCameras(): void;
  76843. private _getRigCamPositionAndTarget;
  76844. /**
  76845. * Gets the current object class name.
  76846. * @return the class name
  76847. */
  76848. getClassName(): string;
  76849. }
  76850. }
  76851. declare module BABYLON {
  76852. /**
  76853. * Gather the list of keyboard event types as constants.
  76854. */
  76855. export class KeyboardEventTypes {
  76856. /**
  76857. * The keydown event is fired when a key becomes active (pressed).
  76858. */
  76859. static readonly KEYDOWN: number;
  76860. /**
  76861. * The keyup event is fired when a key has been released.
  76862. */
  76863. static readonly KEYUP: number;
  76864. }
  76865. /**
  76866. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76867. */
  76868. export class KeyboardInfo {
  76869. /**
  76870. * Defines the type of event (KeyboardEventTypes)
  76871. */
  76872. type: number;
  76873. /**
  76874. * Defines the related dom event
  76875. */
  76876. event: KeyboardEvent;
  76877. /**
  76878. * Instantiates a new keyboard info.
  76879. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76880. * @param type Defines the type of event (KeyboardEventTypes)
  76881. * @param event Defines the related dom event
  76882. */
  76883. constructor(
  76884. /**
  76885. * Defines the type of event (KeyboardEventTypes)
  76886. */
  76887. type: number,
  76888. /**
  76889. * Defines the related dom event
  76890. */
  76891. event: KeyboardEvent);
  76892. }
  76893. /**
  76894. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76895. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  76896. */
  76897. export class KeyboardInfoPre extends KeyboardInfo {
  76898. /**
  76899. * Defines the type of event (KeyboardEventTypes)
  76900. */
  76901. type: number;
  76902. /**
  76903. * Defines the related dom event
  76904. */
  76905. event: KeyboardEvent;
  76906. /**
  76907. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  76908. */
  76909. skipOnPointerObservable: boolean;
  76910. /**
  76911. * Instantiates a new keyboard pre info.
  76912. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76913. * @param type Defines the type of event (KeyboardEventTypes)
  76914. * @param event Defines the related dom event
  76915. */
  76916. constructor(
  76917. /**
  76918. * Defines the type of event (KeyboardEventTypes)
  76919. */
  76920. type: number,
  76921. /**
  76922. * Defines the related dom event
  76923. */
  76924. event: KeyboardEvent);
  76925. }
  76926. }
  76927. declare module BABYLON {
  76928. /**
  76929. * Manage the keyboard inputs to control the movement of a free camera.
  76930. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76931. */
  76932. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  76933. /**
  76934. * Defines the camera the input is attached to.
  76935. */
  76936. camera: FreeCamera;
  76937. /**
  76938. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  76939. */
  76940. keysUp: number[];
  76941. /**
  76942. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  76943. */
  76944. keysDown: number[];
  76945. /**
  76946. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  76947. */
  76948. keysLeft: number[];
  76949. /**
  76950. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  76951. */
  76952. keysRight: number[];
  76953. private _keys;
  76954. private _onCanvasBlurObserver;
  76955. private _onKeyboardObserver;
  76956. private _engine;
  76957. private _scene;
  76958. /**
  76959. * Attach the input controls to a specific dom element to get the input from.
  76960. * @param element Defines the element the controls should be listened from
  76961. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76962. */
  76963. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76964. /**
  76965. * Detach the current controls from the specified dom element.
  76966. * @param element Defines the element to stop listening the inputs from
  76967. */
  76968. detachControl(element: Nullable<HTMLElement>): void;
  76969. /**
  76970. * Update the current camera state depending on the inputs that have been used this frame.
  76971. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76972. */
  76973. checkInputs(): void;
  76974. /**
  76975. * Gets the class name of the current intput.
  76976. * @returns the class name
  76977. */
  76978. getClassName(): string;
  76979. /** @hidden */
  76980. _onLostFocus(): void;
  76981. /**
  76982. * Get the friendly name associated with the input class.
  76983. * @returns the input friendly name
  76984. */
  76985. getSimpleName(): string;
  76986. }
  76987. }
  76988. declare module BABYLON {
  76989. /**
  76990. * Interface describing all the common properties and methods a shadow light needs to implement.
  76991. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  76992. * as well as binding the different shadow properties to the effects.
  76993. */
  76994. export interface IShadowLight extends Light {
  76995. /**
  76996. * The light id in the scene (used in scene.findLighById for instance)
  76997. */
  76998. id: string;
  76999. /**
  77000. * The position the shdow will be casted from.
  77001. */
  77002. position: Vector3;
  77003. /**
  77004. * In 2d mode (needCube being false), the direction used to cast the shadow.
  77005. */
  77006. direction: Vector3;
  77007. /**
  77008. * The transformed position. Position of the light in world space taking parenting in account.
  77009. */
  77010. transformedPosition: Vector3;
  77011. /**
  77012. * The transformed direction. Direction of the light in world space taking parenting in account.
  77013. */
  77014. transformedDirection: Vector3;
  77015. /**
  77016. * The friendly name of the light in the scene.
  77017. */
  77018. name: string;
  77019. /**
  77020. * Defines the shadow projection clipping minimum z value.
  77021. */
  77022. shadowMinZ: number;
  77023. /**
  77024. * Defines the shadow projection clipping maximum z value.
  77025. */
  77026. shadowMaxZ: number;
  77027. /**
  77028. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  77029. * @returns true if the information has been computed, false if it does not need to (no parenting)
  77030. */
  77031. computeTransformedInformation(): boolean;
  77032. /**
  77033. * Gets the scene the light belongs to.
  77034. * @returns The scene
  77035. */
  77036. getScene(): Scene;
  77037. /**
  77038. * Callback defining a custom Projection Matrix Builder.
  77039. * This can be used to override the default projection matrix computation.
  77040. */
  77041. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  77042. /**
  77043. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  77044. * @param matrix The materix to updated with the projection information
  77045. * @param viewMatrix The transform matrix of the light
  77046. * @param renderList The list of mesh to render in the map
  77047. * @returns The current light
  77048. */
  77049. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77050. /**
  77051. * Gets the current depth scale used in ESM.
  77052. * @returns The scale
  77053. */
  77054. getDepthScale(): number;
  77055. /**
  77056. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77057. * @returns true if a cube texture needs to be use
  77058. */
  77059. needCube(): boolean;
  77060. /**
  77061. * Detects if the projection matrix requires to be recomputed this frame.
  77062. * @returns true if it requires to be recomputed otherwise, false.
  77063. */
  77064. needProjectionMatrixCompute(): boolean;
  77065. /**
  77066. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77067. */
  77068. forceProjectionMatrixCompute(): void;
  77069. /**
  77070. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  77071. * @param faceIndex The index of the face we are computed the direction to generate shadow
  77072. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  77073. */
  77074. getShadowDirection(faceIndex?: number): Vector3;
  77075. /**
  77076. * Gets the minZ used for shadow according to both the scene and the light.
  77077. * @param activeCamera The camera we are returning the min for
  77078. * @returns the depth min z
  77079. */
  77080. getDepthMinZ(activeCamera: Camera): number;
  77081. /**
  77082. * Gets the maxZ used for shadow according to both the scene and the light.
  77083. * @param activeCamera The camera we are returning the max for
  77084. * @returns the depth max z
  77085. */
  77086. getDepthMaxZ(activeCamera: Camera): number;
  77087. }
  77088. /**
  77089. * Base implementation IShadowLight
  77090. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  77091. */
  77092. export abstract class ShadowLight extends Light implements IShadowLight {
  77093. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  77094. protected _position: Vector3;
  77095. protected _setPosition(value: Vector3): void;
  77096. /**
  77097. * Sets the position the shadow will be casted from. Also use as the light position for both
  77098. * point and spot lights.
  77099. */
  77100. /**
  77101. * Sets the position the shadow will be casted from. Also use as the light position for both
  77102. * point and spot lights.
  77103. */
  77104. position: Vector3;
  77105. protected _direction: Vector3;
  77106. protected _setDirection(value: Vector3): void;
  77107. /**
  77108. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  77109. * Also use as the light direction on spot and directional lights.
  77110. */
  77111. /**
  77112. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  77113. * Also use as the light direction on spot and directional lights.
  77114. */
  77115. direction: Vector3;
  77116. private _shadowMinZ;
  77117. /**
  77118. * Gets the shadow projection clipping minimum z value.
  77119. */
  77120. /**
  77121. * Sets the shadow projection clipping minimum z value.
  77122. */
  77123. shadowMinZ: number;
  77124. private _shadowMaxZ;
  77125. /**
  77126. * Sets the shadow projection clipping maximum z value.
  77127. */
  77128. /**
  77129. * Gets the shadow projection clipping maximum z value.
  77130. */
  77131. shadowMaxZ: number;
  77132. /**
  77133. * Callback defining a custom Projection Matrix Builder.
  77134. * This can be used to override the default projection matrix computation.
  77135. */
  77136. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  77137. /**
  77138. * The transformed position. Position of the light in world space taking parenting in account.
  77139. */
  77140. transformedPosition: Vector3;
  77141. /**
  77142. * The transformed direction. Direction of the light in world space taking parenting in account.
  77143. */
  77144. transformedDirection: Vector3;
  77145. private _needProjectionMatrixCompute;
  77146. /**
  77147. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  77148. * @returns true if the information has been computed, false if it does not need to (no parenting)
  77149. */
  77150. computeTransformedInformation(): boolean;
  77151. /**
  77152. * Return the depth scale used for the shadow map.
  77153. * @returns the depth scale.
  77154. */
  77155. getDepthScale(): number;
  77156. /**
  77157. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  77158. * @param faceIndex The index of the face we are computed the direction to generate shadow
  77159. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  77160. */
  77161. getShadowDirection(faceIndex?: number): Vector3;
  77162. /**
  77163. * Returns the ShadowLight absolute position in the World.
  77164. * @returns the position vector in world space
  77165. */
  77166. getAbsolutePosition(): Vector3;
  77167. /**
  77168. * Sets the ShadowLight direction toward the passed target.
  77169. * @param target The point to target in local space
  77170. * @returns the updated ShadowLight direction
  77171. */
  77172. setDirectionToTarget(target: Vector3): Vector3;
  77173. /**
  77174. * Returns the light rotation in euler definition.
  77175. * @returns the x y z rotation in local space.
  77176. */
  77177. getRotation(): Vector3;
  77178. /**
  77179. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77180. * @returns true if a cube texture needs to be use
  77181. */
  77182. needCube(): boolean;
  77183. /**
  77184. * Detects if the projection matrix requires to be recomputed this frame.
  77185. * @returns true if it requires to be recomputed otherwise, false.
  77186. */
  77187. needProjectionMatrixCompute(): boolean;
  77188. /**
  77189. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77190. */
  77191. forceProjectionMatrixCompute(): void;
  77192. /** @hidden */
  77193. _initCache(): void;
  77194. /** @hidden */
  77195. _isSynchronized(): boolean;
  77196. /**
  77197. * Computes the world matrix of the node
  77198. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  77199. * @returns the world matrix
  77200. */
  77201. computeWorldMatrix(force?: boolean): Matrix;
  77202. /**
  77203. * Gets the minZ used for shadow according to both the scene and the light.
  77204. * @param activeCamera The camera we are returning the min for
  77205. * @returns the depth min z
  77206. */
  77207. getDepthMinZ(activeCamera: Camera): number;
  77208. /**
  77209. * Gets the maxZ used for shadow according to both the scene and the light.
  77210. * @param activeCamera The camera we are returning the max for
  77211. * @returns the depth max z
  77212. */
  77213. getDepthMaxZ(activeCamera: Camera): number;
  77214. /**
  77215. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  77216. * @param matrix The materix to updated with the projection information
  77217. * @param viewMatrix The transform matrix of the light
  77218. * @param renderList The list of mesh to render in the map
  77219. * @returns The current light
  77220. */
  77221. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77222. }
  77223. }
  77224. declare module BABYLON {
  77225. /**
  77226. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  77227. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  77228. */
  77229. export class EffectFallbacks implements IEffectFallbacks {
  77230. private _defines;
  77231. private _currentRank;
  77232. private _maxRank;
  77233. private _mesh;
  77234. /**
  77235. * Removes the fallback from the bound mesh.
  77236. */
  77237. unBindMesh(): void;
  77238. /**
  77239. * Adds a fallback on the specified property.
  77240. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77241. * @param define The name of the define in the shader
  77242. */
  77243. addFallback(rank: number, define: string): void;
  77244. /**
  77245. * Sets the mesh to use CPU skinning when needing to fallback.
  77246. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77247. * @param mesh The mesh to use the fallbacks.
  77248. */
  77249. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  77250. /**
  77251. * Checks to see if more fallbacks are still availible.
  77252. */
  77253. readonly hasMoreFallbacks: boolean;
  77254. /**
  77255. * Removes the defines that should be removed when falling back.
  77256. * @param currentDefines defines the current define statements for the shader.
  77257. * @param effect defines the current effect we try to compile
  77258. * @returns The resulting defines with defines of the current rank removed.
  77259. */
  77260. reduce(currentDefines: string, effect: Effect): string;
  77261. }
  77262. }
  77263. declare module BABYLON {
  77264. /**
  77265. * "Static Class" containing the most commonly used helper while dealing with material for
  77266. * rendering purpose.
  77267. *
  77268. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  77269. *
  77270. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  77271. */
  77272. export class MaterialHelper {
  77273. /**
  77274. * Bind the current view position to an effect.
  77275. * @param effect The effect to be bound
  77276. * @param scene The scene the eyes position is used from
  77277. */
  77278. static BindEyePosition(effect: Effect, scene: Scene): void;
  77279. /**
  77280. * Helps preparing the defines values about the UVs in used in the effect.
  77281. * UVs are shared as much as we can accross channels in the shaders.
  77282. * @param texture The texture we are preparing the UVs for
  77283. * @param defines The defines to update
  77284. * @param key The channel key "diffuse", "specular"... used in the shader
  77285. */
  77286. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  77287. /**
  77288. * Binds a texture matrix value to its corrsponding uniform
  77289. * @param texture The texture to bind the matrix for
  77290. * @param uniformBuffer The uniform buffer receivin the data
  77291. * @param key The channel key "diffuse", "specular"... used in the shader
  77292. */
  77293. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  77294. /**
  77295. * Gets the current status of the fog (should it be enabled?)
  77296. * @param mesh defines the mesh to evaluate for fog support
  77297. * @param scene defines the hosting scene
  77298. * @returns true if fog must be enabled
  77299. */
  77300. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  77301. /**
  77302. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  77303. * @param mesh defines the current mesh
  77304. * @param scene defines the current scene
  77305. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  77306. * @param pointsCloud defines if point cloud rendering has to be turned on
  77307. * @param fogEnabled defines if fog has to be turned on
  77308. * @param alphaTest defines if alpha testing has to be turned on
  77309. * @param defines defines the current list of defines
  77310. */
  77311. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  77312. /**
  77313. * Helper used to prepare the list of defines associated with frame values for shader compilation
  77314. * @param scene defines the current scene
  77315. * @param engine defines the current engine
  77316. * @param defines specifies the list of active defines
  77317. * @param useInstances defines if instances have to be turned on
  77318. * @param useClipPlane defines if clip plane have to be turned on
  77319. */
  77320. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  77321. /**
  77322. * Prepares the defines for bones
  77323. * @param mesh The mesh containing the geometry data we will draw
  77324. * @param defines The defines to update
  77325. */
  77326. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  77327. /**
  77328. * Prepares the defines for morph targets
  77329. * @param mesh The mesh containing the geometry data we will draw
  77330. * @param defines The defines to update
  77331. */
  77332. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  77333. /**
  77334. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  77335. * @param mesh The mesh containing the geometry data we will draw
  77336. * @param defines The defines to update
  77337. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  77338. * @param useBones Precise whether bones should be used or not (override mesh info)
  77339. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  77340. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  77341. * @returns false if defines are considered not dirty and have not been checked
  77342. */
  77343. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  77344. /**
  77345. * Prepares the defines related to multiview
  77346. * @param scene The scene we are intending to draw
  77347. * @param defines The defines to update
  77348. */
  77349. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  77350. /**
  77351. * Prepares the defines related to the light information passed in parameter
  77352. * @param scene The scene we are intending to draw
  77353. * @param mesh The mesh the effect is compiling for
  77354. * @param light The light the effect is compiling for
  77355. * @param lightIndex The index of the light
  77356. * @param defines The defines to update
  77357. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77358. * @param state Defines the current state regarding what is needed (normals, etc...)
  77359. */
  77360. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  77361. needNormals: boolean;
  77362. needRebuild: boolean;
  77363. shadowEnabled: boolean;
  77364. specularEnabled: boolean;
  77365. lightmapMode: boolean;
  77366. }): void;
  77367. /**
  77368. * Prepares the defines related to the light information passed in parameter
  77369. * @param scene The scene we are intending to draw
  77370. * @param mesh The mesh the effect is compiling for
  77371. * @param defines The defines to update
  77372. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77373. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  77374. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  77375. * @returns true if normals will be required for the rest of the effect
  77376. */
  77377. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  77378. /**
  77379. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  77380. * @param lightIndex defines the light index
  77381. * @param uniformsList The uniform list
  77382. * @param samplersList The sampler list
  77383. * @param projectedLightTexture defines if projected texture must be used
  77384. * @param uniformBuffersList defines an optional list of uniform buffers
  77385. */
  77386. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  77387. /**
  77388. * Prepares the uniforms and samplers list to be used in the effect
  77389. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  77390. * @param samplersList The sampler list
  77391. * @param defines The defines helping in the list generation
  77392. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  77393. */
  77394. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  77395. /**
  77396. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  77397. * @param defines The defines to update while falling back
  77398. * @param fallbacks The authorized effect fallbacks
  77399. * @param maxSimultaneousLights The maximum number of lights allowed
  77400. * @param rank the current rank of the Effect
  77401. * @returns The newly affected rank
  77402. */
  77403. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  77404. private static _TmpMorphInfluencers;
  77405. /**
  77406. * Prepares the list of attributes required for morph targets according to the effect defines.
  77407. * @param attribs The current list of supported attribs
  77408. * @param mesh The mesh to prepare the morph targets attributes for
  77409. * @param influencers The number of influencers
  77410. */
  77411. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  77412. /**
  77413. * Prepares the list of attributes required for morph targets according to the effect defines.
  77414. * @param attribs The current list of supported attribs
  77415. * @param mesh The mesh to prepare the morph targets attributes for
  77416. * @param defines The current Defines of the effect
  77417. */
  77418. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  77419. /**
  77420. * Prepares the list of attributes required for bones according to the effect defines.
  77421. * @param attribs The current list of supported attribs
  77422. * @param mesh The mesh to prepare the bones attributes for
  77423. * @param defines The current Defines of the effect
  77424. * @param fallbacks The current efffect fallback strategy
  77425. */
  77426. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  77427. /**
  77428. * Check and prepare the list of attributes required for instances according to the effect defines.
  77429. * @param attribs The current list of supported attribs
  77430. * @param defines The current MaterialDefines of the effect
  77431. */
  77432. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  77433. /**
  77434. * Add the list of attributes required for instances to the attribs array.
  77435. * @param attribs The current list of supported attribs
  77436. */
  77437. static PushAttributesForInstances(attribs: string[]): void;
  77438. /**
  77439. * Binds the light information to the effect.
  77440. * @param light The light containing the generator
  77441. * @param effect The effect we are binding the data to
  77442. * @param lightIndex The light index in the effect used to render
  77443. */
  77444. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  77445. /**
  77446. * Binds the lights information from the scene to the effect for the given mesh.
  77447. * @param light Light to bind
  77448. * @param lightIndex Light index
  77449. * @param scene The scene where the light belongs to
  77450. * @param effect The effect we are binding the data to
  77451. * @param useSpecular Defines if specular is supported
  77452. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77453. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77454. */
  77455. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77456. /**
  77457. * Binds the lights information from the scene to the effect for the given mesh.
  77458. * @param scene The scene the lights belongs to
  77459. * @param mesh The mesh we are binding the information to render
  77460. * @param effect The effect we are binding the data to
  77461. * @param defines The generated defines for the effect
  77462. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  77463. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77464. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77465. */
  77466. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77467. private static _tempFogColor;
  77468. /**
  77469. * Binds the fog information from the scene to the effect for the given mesh.
  77470. * @param scene The scene the lights belongs to
  77471. * @param mesh The mesh we are binding the information to render
  77472. * @param effect The effect we are binding the data to
  77473. * @param linearSpace Defines if the fog effect is applied in linear space
  77474. */
  77475. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  77476. /**
  77477. * Binds the bones information from the mesh to the effect.
  77478. * @param mesh The mesh we are binding the information to render
  77479. * @param effect The effect we are binding the data to
  77480. */
  77481. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  77482. /**
  77483. * Binds the morph targets information from the mesh to the effect.
  77484. * @param abstractMesh The mesh we are binding the information to render
  77485. * @param effect The effect we are binding the data to
  77486. */
  77487. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  77488. /**
  77489. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  77490. * @param defines The generated defines used in the effect
  77491. * @param effect The effect we are binding the data to
  77492. * @param scene The scene we are willing to render with logarithmic scale for
  77493. */
  77494. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  77495. /**
  77496. * Binds the clip plane information from the scene to the effect.
  77497. * @param scene The scene the clip plane information are extracted from
  77498. * @param effect The effect we are binding the data to
  77499. */
  77500. static BindClipPlane(effect: Effect, scene: Scene): void;
  77501. }
  77502. }
  77503. declare module BABYLON {
  77504. /** @hidden */
  77505. export var packingFunctions: {
  77506. name: string;
  77507. shader: string;
  77508. };
  77509. }
  77510. declare module BABYLON {
  77511. /** @hidden */
  77512. export var shadowMapPixelShader: {
  77513. name: string;
  77514. shader: string;
  77515. };
  77516. }
  77517. declare module BABYLON {
  77518. /** @hidden */
  77519. export var bonesDeclaration: {
  77520. name: string;
  77521. shader: string;
  77522. };
  77523. }
  77524. declare module BABYLON {
  77525. /** @hidden */
  77526. export var morphTargetsVertexGlobalDeclaration: {
  77527. name: string;
  77528. shader: string;
  77529. };
  77530. }
  77531. declare module BABYLON {
  77532. /** @hidden */
  77533. export var morphTargetsVertexDeclaration: {
  77534. name: string;
  77535. shader: string;
  77536. };
  77537. }
  77538. declare module BABYLON {
  77539. /** @hidden */
  77540. export var instancesDeclaration: {
  77541. name: string;
  77542. shader: string;
  77543. };
  77544. }
  77545. declare module BABYLON {
  77546. /** @hidden */
  77547. export var helperFunctions: {
  77548. name: string;
  77549. shader: string;
  77550. };
  77551. }
  77552. declare module BABYLON {
  77553. /** @hidden */
  77554. export var morphTargetsVertex: {
  77555. name: string;
  77556. shader: string;
  77557. };
  77558. }
  77559. declare module BABYLON {
  77560. /** @hidden */
  77561. export var instancesVertex: {
  77562. name: string;
  77563. shader: string;
  77564. };
  77565. }
  77566. declare module BABYLON {
  77567. /** @hidden */
  77568. export var bonesVertex: {
  77569. name: string;
  77570. shader: string;
  77571. };
  77572. }
  77573. declare module BABYLON {
  77574. /** @hidden */
  77575. export var shadowMapVertexShader: {
  77576. name: string;
  77577. shader: string;
  77578. };
  77579. }
  77580. declare module BABYLON {
  77581. /** @hidden */
  77582. export var depthBoxBlurPixelShader: {
  77583. name: string;
  77584. shader: string;
  77585. };
  77586. }
  77587. declare module BABYLON {
  77588. /**
  77589. * Defines the options associated with the creation of a custom shader for a shadow generator.
  77590. */
  77591. export interface ICustomShaderOptions {
  77592. /**
  77593. * Gets or sets the custom shader name to use
  77594. */
  77595. shaderName: string;
  77596. /**
  77597. * The list of attribute names used in the shader
  77598. */
  77599. attributes?: string[];
  77600. /**
  77601. * The list of unifrom names used in the shader
  77602. */
  77603. uniforms?: string[];
  77604. /**
  77605. * The list of sampler names used in the shader
  77606. */
  77607. samplers?: string[];
  77608. /**
  77609. * The list of defines used in the shader
  77610. */
  77611. defines?: string[];
  77612. }
  77613. /**
  77614. * Interface to implement to create a shadow generator compatible with BJS.
  77615. */
  77616. export interface IShadowGenerator {
  77617. /**
  77618. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77619. * @returns The render target texture if present otherwise, null
  77620. */
  77621. getShadowMap(): Nullable<RenderTargetTexture>;
  77622. /**
  77623. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77624. * @returns The render target texture if the shadow map is present otherwise, null
  77625. */
  77626. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77627. /**
  77628. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77629. * @param subMesh The submesh we want to render in the shadow map
  77630. * @param useInstances Defines wether will draw in the map using instances
  77631. * @returns true if ready otherwise, false
  77632. */
  77633. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77634. /**
  77635. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77636. * @param defines Defines of the material we want to update
  77637. * @param lightIndex Index of the light in the enabled light list of the material
  77638. */
  77639. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  77640. /**
  77641. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77642. * defined in the generator but impacting the effect).
  77643. * It implies the unifroms available on the materials are the standard BJS ones.
  77644. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77645. * @param effect The effect we are binfing the information for
  77646. */
  77647. bindShadowLight(lightIndex: string, effect: Effect): void;
  77648. /**
  77649. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77650. * (eq to shadow prjection matrix * light transform matrix)
  77651. * @returns The transform matrix used to create the shadow map
  77652. */
  77653. getTransformMatrix(): Matrix;
  77654. /**
  77655. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77656. * Cube and 2D textures for instance.
  77657. */
  77658. recreateShadowMap(): void;
  77659. /**
  77660. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77661. * @param onCompiled Callback triggered at the and of the effects compilation
  77662. * @param options Sets of optional options forcing the compilation with different modes
  77663. */
  77664. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77665. useInstances: boolean;
  77666. }>): void;
  77667. /**
  77668. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77669. * @param options Sets of optional options forcing the compilation with different modes
  77670. * @returns A promise that resolves when the compilation completes
  77671. */
  77672. forceCompilationAsync(options?: Partial<{
  77673. useInstances: boolean;
  77674. }>): Promise<void>;
  77675. /**
  77676. * Serializes the shadow generator setup to a json object.
  77677. * @returns The serialized JSON object
  77678. */
  77679. serialize(): any;
  77680. /**
  77681. * Disposes the Shadow map and related Textures and effects.
  77682. */
  77683. dispose(): void;
  77684. }
  77685. /**
  77686. * Default implementation IShadowGenerator.
  77687. * This is the main object responsible of generating shadows in the framework.
  77688. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  77689. */
  77690. export class ShadowGenerator implements IShadowGenerator {
  77691. /**
  77692. * Shadow generator mode None: no filtering applied.
  77693. */
  77694. static readonly FILTER_NONE: number;
  77695. /**
  77696. * Shadow generator mode ESM: Exponential Shadow Mapping.
  77697. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77698. */
  77699. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  77700. /**
  77701. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  77702. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  77703. */
  77704. static readonly FILTER_POISSONSAMPLING: number;
  77705. /**
  77706. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  77707. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77708. */
  77709. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  77710. /**
  77711. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  77712. * edge artifacts on steep falloff.
  77713. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77714. */
  77715. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  77716. /**
  77717. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  77718. * edge artifacts on steep falloff.
  77719. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77720. */
  77721. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  77722. /**
  77723. * Shadow generator mode PCF: Percentage Closer Filtering
  77724. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77725. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  77726. */
  77727. static readonly FILTER_PCF: number;
  77728. /**
  77729. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  77730. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77731. * Contact Hardening
  77732. */
  77733. static readonly FILTER_PCSS: number;
  77734. /**
  77735. * Reserved for PCF and PCSS
  77736. * Highest Quality.
  77737. *
  77738. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  77739. *
  77740. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  77741. */
  77742. static readonly QUALITY_HIGH: number;
  77743. /**
  77744. * Reserved for PCF and PCSS
  77745. * Good tradeoff for quality/perf cross devices
  77746. *
  77747. * Execute PCF on a 3*3 kernel.
  77748. *
  77749. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  77750. */
  77751. static readonly QUALITY_MEDIUM: number;
  77752. /**
  77753. * Reserved for PCF and PCSS
  77754. * The lowest quality but the fastest.
  77755. *
  77756. * Execute PCF on a 1*1 kernel.
  77757. *
  77758. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  77759. */
  77760. static readonly QUALITY_LOW: number;
  77761. /** Gets or sets the custom shader name to use */
  77762. customShaderOptions: ICustomShaderOptions;
  77763. /**
  77764. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  77765. */
  77766. onBeforeShadowMapRenderObservable: Observable<Effect>;
  77767. /**
  77768. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  77769. */
  77770. onAfterShadowMapRenderObservable: Observable<Effect>;
  77771. /**
  77772. * Observable triggered before a mesh is rendered in the shadow map.
  77773. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  77774. */
  77775. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  77776. /**
  77777. * Observable triggered after a mesh is rendered in the shadow map.
  77778. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  77779. */
  77780. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  77781. private _bias;
  77782. /**
  77783. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  77784. */
  77785. /**
  77786. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  77787. */
  77788. bias: number;
  77789. private _normalBias;
  77790. /**
  77791. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77792. */
  77793. /**
  77794. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77795. */
  77796. normalBias: number;
  77797. private _blurBoxOffset;
  77798. /**
  77799. * Gets the blur box offset: offset applied during the blur pass.
  77800. * Only useful if useKernelBlur = false
  77801. */
  77802. /**
  77803. * Sets the blur box offset: offset applied during the blur pass.
  77804. * Only useful if useKernelBlur = false
  77805. */
  77806. blurBoxOffset: number;
  77807. private _blurScale;
  77808. /**
  77809. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  77810. * 2 means half of the size.
  77811. */
  77812. /**
  77813. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  77814. * 2 means half of the size.
  77815. */
  77816. blurScale: number;
  77817. private _blurKernel;
  77818. /**
  77819. * Gets the blur kernel: kernel size of the blur pass.
  77820. * Only useful if useKernelBlur = true
  77821. */
  77822. /**
  77823. * Sets the blur kernel: kernel size of the blur pass.
  77824. * Only useful if useKernelBlur = true
  77825. */
  77826. blurKernel: number;
  77827. private _useKernelBlur;
  77828. /**
  77829. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  77830. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77831. */
  77832. /**
  77833. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  77834. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77835. */
  77836. useKernelBlur: boolean;
  77837. private _depthScale;
  77838. /**
  77839. * Gets the depth scale used in ESM mode.
  77840. */
  77841. /**
  77842. * Sets the depth scale used in ESM mode.
  77843. * This can override the scale stored on the light.
  77844. */
  77845. depthScale: number;
  77846. private _filter;
  77847. /**
  77848. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  77849. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77850. */
  77851. /**
  77852. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  77853. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77854. */
  77855. filter: number;
  77856. /**
  77857. * Gets if the current filter is set to Poisson Sampling.
  77858. */
  77859. /**
  77860. * Sets the current filter to Poisson Sampling.
  77861. */
  77862. usePoissonSampling: boolean;
  77863. /**
  77864. * Gets if the current filter is set to ESM.
  77865. */
  77866. /**
  77867. * Sets the current filter is to ESM.
  77868. */
  77869. useExponentialShadowMap: boolean;
  77870. /**
  77871. * Gets if the current filter is set to filtered ESM.
  77872. */
  77873. /**
  77874. * Gets if the current filter is set to filtered ESM.
  77875. */
  77876. useBlurExponentialShadowMap: boolean;
  77877. /**
  77878. * Gets if the current filter is set to "close ESM" (using the inverse of the
  77879. * exponential to prevent steep falloff artifacts).
  77880. */
  77881. /**
  77882. * Sets the current filter to "close ESM" (using the inverse of the
  77883. * exponential to prevent steep falloff artifacts).
  77884. */
  77885. useCloseExponentialShadowMap: boolean;
  77886. /**
  77887. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  77888. * exponential to prevent steep falloff artifacts).
  77889. */
  77890. /**
  77891. * Sets the current filter to filtered "close ESM" (using the inverse of the
  77892. * exponential to prevent steep falloff artifacts).
  77893. */
  77894. useBlurCloseExponentialShadowMap: boolean;
  77895. /**
  77896. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  77897. */
  77898. /**
  77899. * Sets the current filter to "PCF" (percentage closer filtering).
  77900. */
  77901. usePercentageCloserFiltering: boolean;
  77902. private _filteringQuality;
  77903. /**
  77904. * Gets the PCF or PCSS Quality.
  77905. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77906. */
  77907. /**
  77908. * Sets the PCF or PCSS Quality.
  77909. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77910. */
  77911. filteringQuality: number;
  77912. /**
  77913. * Gets if the current filter is set to "PCSS" (contact hardening).
  77914. */
  77915. /**
  77916. * Sets the current filter to "PCSS" (contact hardening).
  77917. */
  77918. useContactHardeningShadow: boolean;
  77919. private _contactHardeningLightSizeUVRatio;
  77920. /**
  77921. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77922. * Using a ratio helps keeping shape stability independently of the map size.
  77923. *
  77924. * It does not account for the light projection as it was having too much
  77925. * instability during the light setup or during light position changes.
  77926. *
  77927. * Only valid if useContactHardeningShadow is true.
  77928. */
  77929. /**
  77930. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77931. * Using a ratio helps keeping shape stability independently of the map size.
  77932. *
  77933. * It does not account for the light projection as it was having too much
  77934. * instability during the light setup or during light position changes.
  77935. *
  77936. * Only valid if useContactHardeningShadow is true.
  77937. */
  77938. contactHardeningLightSizeUVRatio: number;
  77939. private _darkness;
  77940. /** Gets or sets the actual darkness of a shadow */
  77941. darkness: number;
  77942. /**
  77943. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  77944. * 0 means strongest and 1 would means no shadow.
  77945. * @returns the darkness.
  77946. */
  77947. getDarkness(): number;
  77948. /**
  77949. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  77950. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  77951. * @returns the shadow generator allowing fluent coding.
  77952. */
  77953. setDarkness(darkness: number): ShadowGenerator;
  77954. private _transparencyShadow;
  77955. /** Gets or sets the ability to have transparent shadow */
  77956. transparencyShadow: boolean;
  77957. /**
  77958. * Sets the ability to have transparent shadow (boolean).
  77959. * @param transparent True if transparent else False
  77960. * @returns the shadow generator allowing fluent coding
  77961. */
  77962. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  77963. private _shadowMap;
  77964. private _shadowMap2;
  77965. /**
  77966. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77967. * @returns The render target texture if present otherwise, null
  77968. */
  77969. getShadowMap(): Nullable<RenderTargetTexture>;
  77970. /**
  77971. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77972. * @returns The render target texture if the shadow map is present otherwise, null
  77973. */
  77974. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77975. /**
  77976. * Gets the class name of that object
  77977. * @returns "ShadowGenerator"
  77978. */
  77979. getClassName(): string;
  77980. /**
  77981. * Helper function to add a mesh and its descendants to the list of shadow casters.
  77982. * @param mesh Mesh to add
  77983. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  77984. * @returns the Shadow Generator itself
  77985. */
  77986. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77987. /**
  77988. * Helper function to remove a mesh and its descendants from the list of shadow casters
  77989. * @param mesh Mesh to remove
  77990. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  77991. * @returns the Shadow Generator itself
  77992. */
  77993. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77994. /**
  77995. * Controls the extent to which the shadows fade out at the edge of the frustum
  77996. * Used only by directionals and spots
  77997. */
  77998. frustumEdgeFalloff: number;
  77999. private _light;
  78000. /**
  78001. * Returns the associated light object.
  78002. * @returns the light generating the shadow
  78003. */
  78004. getLight(): IShadowLight;
  78005. /**
  78006. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  78007. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  78008. * It might on the other hand introduce peter panning.
  78009. */
  78010. forceBackFacesOnly: boolean;
  78011. private _scene;
  78012. private _lightDirection;
  78013. private _effect;
  78014. private _viewMatrix;
  78015. private _projectionMatrix;
  78016. private _transformMatrix;
  78017. private _cachedPosition;
  78018. private _cachedDirection;
  78019. private _cachedDefines;
  78020. private _currentRenderID;
  78021. private _boxBlurPostprocess;
  78022. private _kernelBlurXPostprocess;
  78023. private _kernelBlurYPostprocess;
  78024. private _blurPostProcesses;
  78025. private _mapSize;
  78026. private _currentFaceIndex;
  78027. private _currentFaceIndexCache;
  78028. private _textureType;
  78029. private _defaultTextureMatrix;
  78030. private _storedUniqueId;
  78031. /** @hidden */
  78032. static _SceneComponentInitialization: (scene: Scene) => void;
  78033. /**
  78034. * Creates a ShadowGenerator object.
  78035. * A ShadowGenerator is the required tool to use the shadows.
  78036. * Each light casting shadows needs to use its own ShadowGenerator.
  78037. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  78038. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  78039. * @param light The light object generating the shadows.
  78040. * @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.
  78041. */
  78042. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  78043. private _initializeGenerator;
  78044. private _initializeShadowMap;
  78045. private _initializeBlurRTTAndPostProcesses;
  78046. private _renderForShadowMap;
  78047. private _renderSubMeshForShadowMap;
  78048. private _applyFilterValues;
  78049. /**
  78050. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78051. * @param onCompiled Callback triggered at the and of the effects compilation
  78052. * @param options Sets of optional options forcing the compilation with different modes
  78053. */
  78054. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  78055. useInstances: boolean;
  78056. }>): void;
  78057. /**
  78058. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78059. * @param options Sets of optional options forcing the compilation with different modes
  78060. * @returns A promise that resolves when the compilation completes
  78061. */
  78062. forceCompilationAsync(options?: Partial<{
  78063. useInstances: boolean;
  78064. }>): Promise<void>;
  78065. /**
  78066. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  78067. * @param subMesh The submesh we want to render in the shadow map
  78068. * @param useInstances Defines wether will draw in the map using instances
  78069. * @returns true if ready otherwise, false
  78070. */
  78071. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  78072. /**
  78073. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  78074. * @param defines Defines of the material we want to update
  78075. * @param lightIndex Index of the light in the enabled light list of the material
  78076. */
  78077. prepareDefines(defines: any, lightIndex: number): void;
  78078. /**
  78079. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  78080. * defined in the generator but impacting the effect).
  78081. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  78082. * @param effect The effect we are binfing the information for
  78083. */
  78084. bindShadowLight(lightIndex: string, effect: Effect): void;
  78085. /**
  78086. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  78087. * (eq to shadow prjection matrix * light transform matrix)
  78088. * @returns The transform matrix used to create the shadow map
  78089. */
  78090. getTransformMatrix(): Matrix;
  78091. /**
  78092. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  78093. * Cube and 2D textures for instance.
  78094. */
  78095. recreateShadowMap(): void;
  78096. private _disposeBlurPostProcesses;
  78097. private _disposeRTTandPostProcesses;
  78098. /**
  78099. * Disposes the ShadowGenerator.
  78100. * Returns nothing.
  78101. */
  78102. dispose(): void;
  78103. /**
  78104. * Serializes the shadow generator setup to a json object.
  78105. * @returns The serialized JSON object
  78106. */
  78107. serialize(): any;
  78108. /**
  78109. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  78110. * @param parsedShadowGenerator The JSON object to parse
  78111. * @param scene The scene to create the shadow map for
  78112. * @returns The parsed shadow generator
  78113. */
  78114. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  78115. }
  78116. }
  78117. declare module BABYLON {
  78118. /**
  78119. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  78120. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  78121. * 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.
  78122. */
  78123. export abstract class Light extends Node {
  78124. /**
  78125. * Falloff Default: light is falling off following the material specification:
  78126. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  78127. */
  78128. static readonly FALLOFF_DEFAULT: number;
  78129. /**
  78130. * Falloff Physical: light is falling off following the inverse squared distance law.
  78131. */
  78132. static readonly FALLOFF_PHYSICAL: number;
  78133. /**
  78134. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  78135. * to enhance interoperability with other engines.
  78136. */
  78137. static readonly FALLOFF_GLTF: number;
  78138. /**
  78139. * Falloff Standard: light is falling off like in the standard material
  78140. * to enhance interoperability with other materials.
  78141. */
  78142. static readonly FALLOFF_STANDARD: number;
  78143. /**
  78144. * If every light affecting the material is in this lightmapMode,
  78145. * material.lightmapTexture adds or multiplies
  78146. * (depends on material.useLightmapAsShadowmap)
  78147. * after every other light calculations.
  78148. */
  78149. static readonly LIGHTMAP_DEFAULT: number;
  78150. /**
  78151. * material.lightmapTexture as only diffuse lighting from this light
  78152. * adds only specular lighting from this light
  78153. * adds dynamic shadows
  78154. */
  78155. static readonly LIGHTMAP_SPECULAR: number;
  78156. /**
  78157. * material.lightmapTexture as only lighting
  78158. * no light calculation from this light
  78159. * only adds dynamic shadows from this light
  78160. */
  78161. static readonly LIGHTMAP_SHADOWSONLY: number;
  78162. /**
  78163. * Each light type uses the default quantity according to its type:
  78164. * point/spot lights use luminous intensity
  78165. * directional lights use illuminance
  78166. */
  78167. static readonly INTENSITYMODE_AUTOMATIC: number;
  78168. /**
  78169. * lumen (lm)
  78170. */
  78171. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  78172. /**
  78173. * candela (lm/sr)
  78174. */
  78175. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  78176. /**
  78177. * lux (lm/m^2)
  78178. */
  78179. static readonly INTENSITYMODE_ILLUMINANCE: number;
  78180. /**
  78181. * nit (cd/m^2)
  78182. */
  78183. static readonly INTENSITYMODE_LUMINANCE: number;
  78184. /**
  78185. * Light type const id of the point light.
  78186. */
  78187. static readonly LIGHTTYPEID_POINTLIGHT: number;
  78188. /**
  78189. * Light type const id of the directional light.
  78190. */
  78191. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  78192. /**
  78193. * Light type const id of the spot light.
  78194. */
  78195. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  78196. /**
  78197. * Light type const id of the hemispheric light.
  78198. */
  78199. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  78200. /**
  78201. * Diffuse gives the basic color to an object.
  78202. */
  78203. diffuse: Color3;
  78204. /**
  78205. * Specular produces a highlight color on an object.
  78206. * Note: This is note affecting PBR materials.
  78207. */
  78208. specular: Color3;
  78209. /**
  78210. * Defines the falloff type for this light. This lets overrriding how punctual light are
  78211. * falling off base on range or angle.
  78212. * This can be set to any values in Light.FALLOFF_x.
  78213. *
  78214. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  78215. * other types of materials.
  78216. */
  78217. falloffType: number;
  78218. /**
  78219. * Strength of the light.
  78220. * Note: By default it is define in the framework own unit.
  78221. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  78222. */
  78223. intensity: number;
  78224. private _range;
  78225. protected _inverseSquaredRange: number;
  78226. /**
  78227. * Defines how far from the source the light is impacting in scene units.
  78228. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78229. */
  78230. /**
  78231. * Defines how far from the source the light is impacting in scene units.
  78232. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78233. */
  78234. range: number;
  78235. /**
  78236. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  78237. * of light.
  78238. */
  78239. private _photometricScale;
  78240. private _intensityMode;
  78241. /**
  78242. * Gets the photometric scale used to interpret the intensity.
  78243. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78244. */
  78245. /**
  78246. * Sets the photometric scale used to interpret the intensity.
  78247. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78248. */
  78249. intensityMode: number;
  78250. private _radius;
  78251. /**
  78252. * Gets the light radius used by PBR Materials to simulate soft area lights.
  78253. */
  78254. /**
  78255. * sets the light radius used by PBR Materials to simulate soft area lights.
  78256. */
  78257. radius: number;
  78258. private _renderPriority;
  78259. /**
  78260. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  78261. * exceeding the number allowed of the materials.
  78262. */
  78263. renderPriority: number;
  78264. private _shadowEnabled;
  78265. /**
  78266. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78267. * the current shadow generator.
  78268. */
  78269. /**
  78270. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78271. * the current shadow generator.
  78272. */
  78273. shadowEnabled: boolean;
  78274. private _includedOnlyMeshes;
  78275. /**
  78276. * Gets the only meshes impacted by this light.
  78277. */
  78278. /**
  78279. * Sets the only meshes impacted by this light.
  78280. */
  78281. includedOnlyMeshes: AbstractMesh[];
  78282. private _excludedMeshes;
  78283. /**
  78284. * Gets the meshes not impacted by this light.
  78285. */
  78286. /**
  78287. * Sets the meshes not impacted by this light.
  78288. */
  78289. excludedMeshes: AbstractMesh[];
  78290. private _excludeWithLayerMask;
  78291. /**
  78292. * Gets the layer id use to find what meshes are not impacted by the light.
  78293. * Inactive if 0
  78294. */
  78295. /**
  78296. * Sets the layer id use to find what meshes are not impacted by the light.
  78297. * Inactive if 0
  78298. */
  78299. excludeWithLayerMask: number;
  78300. private _includeOnlyWithLayerMask;
  78301. /**
  78302. * Gets the layer id use to find what meshes are impacted by the light.
  78303. * Inactive if 0
  78304. */
  78305. /**
  78306. * Sets the layer id use to find what meshes are impacted by the light.
  78307. * Inactive if 0
  78308. */
  78309. includeOnlyWithLayerMask: number;
  78310. private _lightmapMode;
  78311. /**
  78312. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78313. */
  78314. /**
  78315. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78316. */
  78317. lightmapMode: number;
  78318. /**
  78319. * Shadow generator associted to the light.
  78320. * @hidden Internal use only.
  78321. */
  78322. _shadowGenerator: Nullable<IShadowGenerator>;
  78323. /**
  78324. * @hidden Internal use only.
  78325. */
  78326. _excludedMeshesIds: string[];
  78327. /**
  78328. * @hidden Internal use only.
  78329. */
  78330. _includedOnlyMeshesIds: string[];
  78331. /**
  78332. * The current light unifom buffer.
  78333. * @hidden Internal use only.
  78334. */
  78335. _uniformBuffer: UniformBuffer;
  78336. /** @hidden */
  78337. _renderId: number;
  78338. /**
  78339. * Creates a Light object in the scene.
  78340. * Documentation : https://doc.babylonjs.com/babylon101/lights
  78341. * @param name The firendly name of the light
  78342. * @param scene The scene the light belongs too
  78343. */
  78344. constructor(name: string, scene: Scene);
  78345. protected abstract _buildUniformLayout(): void;
  78346. /**
  78347. * Sets the passed Effect "effect" with the Light information.
  78348. * @param effect The effect to update
  78349. * @param lightIndex The index of the light in the effect to update
  78350. * @returns The light
  78351. */
  78352. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  78353. /**
  78354. * Sets the passed Effect "effect" with the Light information.
  78355. * @param effect The effect to update
  78356. * @param lightDataUniformName The uniform used to store light data (position or direction)
  78357. * @returns The light
  78358. */
  78359. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  78360. /**
  78361. * Returns the string "Light".
  78362. * @returns the class name
  78363. */
  78364. getClassName(): string;
  78365. /** @hidden */
  78366. readonly _isLight: boolean;
  78367. /**
  78368. * Converts the light information to a readable string for debug purpose.
  78369. * @param fullDetails Supports for multiple levels of logging within scene loading
  78370. * @returns the human readable light info
  78371. */
  78372. toString(fullDetails?: boolean): string;
  78373. /** @hidden */
  78374. protected _syncParentEnabledState(): void;
  78375. /**
  78376. * Set the enabled state of this node.
  78377. * @param value - the new enabled state
  78378. */
  78379. setEnabled(value: boolean): void;
  78380. /**
  78381. * Returns the Light associated shadow generator if any.
  78382. * @return the associated shadow generator.
  78383. */
  78384. getShadowGenerator(): Nullable<IShadowGenerator>;
  78385. /**
  78386. * Returns a Vector3, the absolute light position in the World.
  78387. * @returns the world space position of the light
  78388. */
  78389. getAbsolutePosition(): Vector3;
  78390. /**
  78391. * Specifies if the light will affect the passed mesh.
  78392. * @param mesh The mesh to test against the light
  78393. * @return true the mesh is affected otherwise, false.
  78394. */
  78395. canAffectMesh(mesh: AbstractMesh): boolean;
  78396. /**
  78397. * Sort function to order lights for rendering.
  78398. * @param a First Light object to compare to second.
  78399. * @param b Second Light object to compare first.
  78400. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  78401. */
  78402. static CompareLightsPriority(a: Light, b: Light): number;
  78403. /**
  78404. * Releases resources associated with this node.
  78405. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78406. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78407. */
  78408. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78409. /**
  78410. * Returns the light type ID (integer).
  78411. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78412. */
  78413. getTypeID(): number;
  78414. /**
  78415. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  78416. * @returns the scaled intensity in intensity mode unit
  78417. */
  78418. getScaledIntensity(): number;
  78419. /**
  78420. * Returns a new Light object, named "name", from the current one.
  78421. * @param name The name of the cloned light
  78422. * @returns the new created light
  78423. */
  78424. clone(name: string): Nullable<Light>;
  78425. /**
  78426. * Serializes the current light into a Serialization object.
  78427. * @returns the serialized object.
  78428. */
  78429. serialize(): any;
  78430. /**
  78431. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  78432. * This new light is named "name" and added to the passed scene.
  78433. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  78434. * @param name The friendly name of the light
  78435. * @param scene The scene the new light will belong to
  78436. * @returns the constructor function
  78437. */
  78438. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  78439. /**
  78440. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  78441. * @param parsedLight The JSON representation of the light
  78442. * @param scene The scene to create the parsed light in
  78443. * @returns the created light after parsing
  78444. */
  78445. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  78446. private _hookArrayForExcluded;
  78447. private _hookArrayForIncludedOnly;
  78448. private _resyncMeshes;
  78449. /**
  78450. * Forces the meshes to update their light related information in their rendering used effects
  78451. * @hidden Internal Use Only
  78452. */
  78453. _markMeshesAsLightDirty(): void;
  78454. /**
  78455. * Recomputes the cached photometric scale if needed.
  78456. */
  78457. private _computePhotometricScale;
  78458. /**
  78459. * Returns the Photometric Scale according to the light type and intensity mode.
  78460. */
  78461. private _getPhotometricScale;
  78462. /**
  78463. * Reorder the light in the scene according to their defined priority.
  78464. * @hidden Internal Use Only
  78465. */
  78466. _reorderLightsInScene(): void;
  78467. /**
  78468. * Prepares the list of defines specific to the light type.
  78469. * @param defines the list of defines
  78470. * @param lightIndex defines the index of the light for the effect
  78471. */
  78472. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78473. }
  78474. }
  78475. declare module BABYLON {
  78476. /**
  78477. * Interface used to define Action
  78478. */
  78479. export interface IAction {
  78480. /**
  78481. * Trigger for the action
  78482. */
  78483. trigger: number;
  78484. /** Options of the trigger */
  78485. triggerOptions: any;
  78486. /**
  78487. * Gets the trigger parameters
  78488. * @returns the trigger parameters
  78489. */
  78490. getTriggerParameter(): any;
  78491. /**
  78492. * Internal only - executes current action event
  78493. * @hidden
  78494. */
  78495. _executeCurrent(evt?: ActionEvent): void;
  78496. /**
  78497. * Serialize placeholder for child classes
  78498. * @param parent of child
  78499. * @returns the serialized object
  78500. */
  78501. serialize(parent: any): any;
  78502. /**
  78503. * Internal only
  78504. * @hidden
  78505. */
  78506. _prepare(): void;
  78507. /**
  78508. * Internal only - manager for action
  78509. * @hidden
  78510. */
  78511. _actionManager: AbstractActionManager;
  78512. /**
  78513. * Adds action to chain of actions, may be a DoNothingAction
  78514. * @param action defines the next action to execute
  78515. * @returns The action passed in
  78516. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78517. */
  78518. then(action: IAction): IAction;
  78519. }
  78520. /**
  78521. * The action to be carried out following a trigger
  78522. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  78523. */
  78524. export class Action implements IAction {
  78525. /** the trigger, with or without parameters, for the action */
  78526. triggerOptions: any;
  78527. /**
  78528. * Trigger for the action
  78529. */
  78530. trigger: number;
  78531. /**
  78532. * Internal only - manager for action
  78533. * @hidden
  78534. */
  78535. _actionManager: ActionManager;
  78536. private _nextActiveAction;
  78537. private _child;
  78538. private _condition?;
  78539. private _triggerParameter;
  78540. /**
  78541. * An event triggered prior to action being executed.
  78542. */
  78543. onBeforeExecuteObservable: Observable<Action>;
  78544. /**
  78545. * Creates a new Action
  78546. * @param triggerOptions the trigger, with or without parameters, for the action
  78547. * @param condition an optional determinant of action
  78548. */
  78549. constructor(
  78550. /** the trigger, with or without parameters, for the action */
  78551. triggerOptions: any, condition?: Condition);
  78552. /**
  78553. * Internal only
  78554. * @hidden
  78555. */
  78556. _prepare(): void;
  78557. /**
  78558. * Gets the trigger parameters
  78559. * @returns the trigger parameters
  78560. */
  78561. getTriggerParameter(): any;
  78562. /**
  78563. * Internal only - executes current action event
  78564. * @hidden
  78565. */
  78566. _executeCurrent(evt?: ActionEvent): void;
  78567. /**
  78568. * Execute placeholder for child classes
  78569. * @param evt optional action event
  78570. */
  78571. execute(evt?: ActionEvent): void;
  78572. /**
  78573. * Skips to next active action
  78574. */
  78575. skipToNextActiveAction(): void;
  78576. /**
  78577. * Adds action to chain of actions, may be a DoNothingAction
  78578. * @param action defines the next action to execute
  78579. * @returns The action passed in
  78580. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78581. */
  78582. then(action: Action): Action;
  78583. /**
  78584. * Internal only
  78585. * @hidden
  78586. */
  78587. _getProperty(propertyPath: string): string;
  78588. /**
  78589. * Internal only
  78590. * @hidden
  78591. */
  78592. _getEffectiveTarget(target: any, propertyPath: string): any;
  78593. /**
  78594. * Serialize placeholder for child classes
  78595. * @param parent of child
  78596. * @returns the serialized object
  78597. */
  78598. serialize(parent: any): any;
  78599. /**
  78600. * Internal only called by serialize
  78601. * @hidden
  78602. */
  78603. protected _serialize(serializedAction: any, parent?: any): any;
  78604. /**
  78605. * Internal only
  78606. * @hidden
  78607. */
  78608. static _SerializeValueAsString: (value: any) => string;
  78609. /**
  78610. * Internal only
  78611. * @hidden
  78612. */
  78613. static _GetTargetProperty: (target: Node | Scene) => {
  78614. name: string;
  78615. targetType: string;
  78616. value: string;
  78617. };
  78618. }
  78619. }
  78620. declare module BABYLON {
  78621. /**
  78622. * A Condition applied to an Action
  78623. */
  78624. export class Condition {
  78625. /**
  78626. * Internal only - manager for action
  78627. * @hidden
  78628. */
  78629. _actionManager: ActionManager;
  78630. /**
  78631. * Internal only
  78632. * @hidden
  78633. */
  78634. _evaluationId: number;
  78635. /**
  78636. * Internal only
  78637. * @hidden
  78638. */
  78639. _currentResult: boolean;
  78640. /**
  78641. * Creates a new Condition
  78642. * @param actionManager the manager of the action the condition is applied to
  78643. */
  78644. constructor(actionManager: ActionManager);
  78645. /**
  78646. * Check if the current condition is valid
  78647. * @returns a boolean
  78648. */
  78649. isValid(): boolean;
  78650. /**
  78651. * Internal only
  78652. * @hidden
  78653. */
  78654. _getProperty(propertyPath: string): string;
  78655. /**
  78656. * Internal only
  78657. * @hidden
  78658. */
  78659. _getEffectiveTarget(target: any, propertyPath: string): any;
  78660. /**
  78661. * Serialize placeholder for child classes
  78662. * @returns the serialized object
  78663. */
  78664. serialize(): any;
  78665. /**
  78666. * Internal only
  78667. * @hidden
  78668. */
  78669. protected _serialize(serializedCondition: any): any;
  78670. }
  78671. /**
  78672. * Defines specific conditional operators as extensions of Condition
  78673. */
  78674. export class ValueCondition extends Condition {
  78675. /** path to specify the property of the target the conditional operator uses */
  78676. propertyPath: string;
  78677. /** the value compared by the conditional operator against the current value of the property */
  78678. value: any;
  78679. /** the conditional operator, default ValueCondition.IsEqual */
  78680. operator: number;
  78681. /**
  78682. * Internal only
  78683. * @hidden
  78684. */
  78685. private static _IsEqual;
  78686. /**
  78687. * Internal only
  78688. * @hidden
  78689. */
  78690. private static _IsDifferent;
  78691. /**
  78692. * Internal only
  78693. * @hidden
  78694. */
  78695. private static _IsGreater;
  78696. /**
  78697. * Internal only
  78698. * @hidden
  78699. */
  78700. private static _IsLesser;
  78701. /**
  78702. * returns the number for IsEqual
  78703. */
  78704. static readonly IsEqual: number;
  78705. /**
  78706. * Returns the number for IsDifferent
  78707. */
  78708. static readonly IsDifferent: number;
  78709. /**
  78710. * Returns the number for IsGreater
  78711. */
  78712. static readonly IsGreater: number;
  78713. /**
  78714. * Returns the number for IsLesser
  78715. */
  78716. static readonly IsLesser: number;
  78717. /**
  78718. * Internal only The action manager for the condition
  78719. * @hidden
  78720. */
  78721. _actionManager: ActionManager;
  78722. /**
  78723. * Internal only
  78724. * @hidden
  78725. */
  78726. private _target;
  78727. /**
  78728. * Internal only
  78729. * @hidden
  78730. */
  78731. private _effectiveTarget;
  78732. /**
  78733. * Internal only
  78734. * @hidden
  78735. */
  78736. private _property;
  78737. /**
  78738. * Creates a new ValueCondition
  78739. * @param actionManager manager for the action the condition applies to
  78740. * @param target for the action
  78741. * @param propertyPath path to specify the property of the target the conditional operator uses
  78742. * @param value the value compared by the conditional operator against the current value of the property
  78743. * @param operator the conditional operator, default ValueCondition.IsEqual
  78744. */
  78745. constructor(actionManager: ActionManager, target: any,
  78746. /** path to specify the property of the target the conditional operator uses */
  78747. propertyPath: string,
  78748. /** the value compared by the conditional operator against the current value of the property */
  78749. value: any,
  78750. /** the conditional operator, default ValueCondition.IsEqual */
  78751. operator?: number);
  78752. /**
  78753. * Compares the given value with the property value for the specified conditional operator
  78754. * @returns the result of the comparison
  78755. */
  78756. isValid(): boolean;
  78757. /**
  78758. * Serialize the ValueCondition into a JSON compatible object
  78759. * @returns serialization object
  78760. */
  78761. serialize(): any;
  78762. /**
  78763. * Gets the name of the conditional operator for the ValueCondition
  78764. * @param operator the conditional operator
  78765. * @returns the name
  78766. */
  78767. static GetOperatorName(operator: number): string;
  78768. }
  78769. /**
  78770. * Defines a predicate condition as an extension of Condition
  78771. */
  78772. export class PredicateCondition extends Condition {
  78773. /** defines the predicate function used to validate the condition */
  78774. predicate: () => boolean;
  78775. /**
  78776. * Internal only - manager for action
  78777. * @hidden
  78778. */
  78779. _actionManager: ActionManager;
  78780. /**
  78781. * Creates a new PredicateCondition
  78782. * @param actionManager manager for the action the condition applies to
  78783. * @param predicate defines the predicate function used to validate the condition
  78784. */
  78785. constructor(actionManager: ActionManager,
  78786. /** defines the predicate function used to validate the condition */
  78787. predicate: () => boolean);
  78788. /**
  78789. * @returns the validity of the predicate condition
  78790. */
  78791. isValid(): boolean;
  78792. }
  78793. /**
  78794. * Defines a state condition as an extension of Condition
  78795. */
  78796. export class StateCondition extends Condition {
  78797. /** Value to compare with target state */
  78798. value: string;
  78799. /**
  78800. * Internal only - manager for action
  78801. * @hidden
  78802. */
  78803. _actionManager: ActionManager;
  78804. /**
  78805. * Internal only
  78806. * @hidden
  78807. */
  78808. private _target;
  78809. /**
  78810. * Creates a new StateCondition
  78811. * @param actionManager manager for the action the condition applies to
  78812. * @param target of the condition
  78813. * @param value to compare with target state
  78814. */
  78815. constructor(actionManager: ActionManager, target: any,
  78816. /** Value to compare with target state */
  78817. value: string);
  78818. /**
  78819. * Gets a boolean indicating if the current condition is met
  78820. * @returns the validity of the state
  78821. */
  78822. isValid(): boolean;
  78823. /**
  78824. * Serialize the StateCondition into a JSON compatible object
  78825. * @returns serialization object
  78826. */
  78827. serialize(): any;
  78828. }
  78829. }
  78830. declare module BABYLON {
  78831. /**
  78832. * This defines an action responsible to toggle a boolean once triggered.
  78833. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78834. */
  78835. export class SwitchBooleanAction extends Action {
  78836. /**
  78837. * The path to the boolean property in the target object
  78838. */
  78839. propertyPath: string;
  78840. private _target;
  78841. private _effectiveTarget;
  78842. private _property;
  78843. /**
  78844. * Instantiate the action
  78845. * @param triggerOptions defines the trigger options
  78846. * @param target defines the object containing the boolean
  78847. * @param propertyPath defines the path to the boolean property in the target object
  78848. * @param condition defines the trigger related conditions
  78849. */
  78850. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78851. /** @hidden */
  78852. _prepare(): void;
  78853. /**
  78854. * Execute the action toggle the boolean value.
  78855. */
  78856. execute(): void;
  78857. /**
  78858. * Serializes the actions and its related information.
  78859. * @param parent defines the object to serialize in
  78860. * @returns the serialized object
  78861. */
  78862. serialize(parent: any): any;
  78863. }
  78864. /**
  78865. * This defines an action responsible to set a the state field of the target
  78866. * to a desired value once triggered.
  78867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78868. */
  78869. export class SetStateAction extends Action {
  78870. /**
  78871. * The value to store in the state field.
  78872. */
  78873. value: string;
  78874. private _target;
  78875. /**
  78876. * Instantiate the action
  78877. * @param triggerOptions defines the trigger options
  78878. * @param target defines the object containing the state property
  78879. * @param value defines the value to store in the state field
  78880. * @param condition defines the trigger related conditions
  78881. */
  78882. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78883. /**
  78884. * Execute the action and store the value on the target state property.
  78885. */
  78886. execute(): void;
  78887. /**
  78888. * Serializes the actions and its related information.
  78889. * @param parent defines the object to serialize in
  78890. * @returns the serialized object
  78891. */
  78892. serialize(parent: any): any;
  78893. }
  78894. /**
  78895. * This defines an action responsible to set a property of the target
  78896. * to a desired value once triggered.
  78897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78898. */
  78899. export class SetValueAction extends Action {
  78900. /**
  78901. * The path of the property to set in the target.
  78902. */
  78903. propertyPath: string;
  78904. /**
  78905. * The value to set in the property
  78906. */
  78907. value: any;
  78908. private _target;
  78909. private _effectiveTarget;
  78910. private _property;
  78911. /**
  78912. * Instantiate the action
  78913. * @param triggerOptions defines the trigger options
  78914. * @param target defines the object containing the property
  78915. * @param propertyPath defines the path of the property to set in the target
  78916. * @param value defines the value to set in the property
  78917. * @param condition defines the trigger related conditions
  78918. */
  78919. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78920. /** @hidden */
  78921. _prepare(): void;
  78922. /**
  78923. * Execute the action and set the targetted property to the desired value.
  78924. */
  78925. execute(): void;
  78926. /**
  78927. * Serializes the actions and its related information.
  78928. * @param parent defines the object to serialize in
  78929. * @returns the serialized object
  78930. */
  78931. serialize(parent: any): any;
  78932. }
  78933. /**
  78934. * This defines an action responsible to increment the target value
  78935. * to a desired value once triggered.
  78936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78937. */
  78938. export class IncrementValueAction extends Action {
  78939. /**
  78940. * The path of the property to increment in the target.
  78941. */
  78942. propertyPath: string;
  78943. /**
  78944. * The value we should increment the property by.
  78945. */
  78946. value: any;
  78947. private _target;
  78948. private _effectiveTarget;
  78949. private _property;
  78950. /**
  78951. * Instantiate the action
  78952. * @param triggerOptions defines the trigger options
  78953. * @param target defines the object containing the property
  78954. * @param propertyPath defines the path of the property to increment in the target
  78955. * @param value defines the value value we should increment the property by
  78956. * @param condition defines the trigger related conditions
  78957. */
  78958. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78959. /** @hidden */
  78960. _prepare(): void;
  78961. /**
  78962. * Execute the action and increment the target of the value amount.
  78963. */
  78964. execute(): void;
  78965. /**
  78966. * Serializes the actions and its related information.
  78967. * @param parent defines the object to serialize in
  78968. * @returns the serialized object
  78969. */
  78970. serialize(parent: any): any;
  78971. }
  78972. /**
  78973. * This defines an action responsible to start an animation once triggered.
  78974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78975. */
  78976. export class PlayAnimationAction extends Action {
  78977. /**
  78978. * Where the animation should start (animation frame)
  78979. */
  78980. from: number;
  78981. /**
  78982. * Where the animation should stop (animation frame)
  78983. */
  78984. to: number;
  78985. /**
  78986. * Define if the animation should loop or stop after the first play.
  78987. */
  78988. loop?: boolean;
  78989. private _target;
  78990. /**
  78991. * Instantiate the action
  78992. * @param triggerOptions defines the trigger options
  78993. * @param target defines the target animation or animation name
  78994. * @param from defines from where the animation should start (animation frame)
  78995. * @param end defines where the animation should stop (animation frame)
  78996. * @param loop defines if the animation should loop or stop after the first play
  78997. * @param condition defines the trigger related conditions
  78998. */
  78999. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  79000. /** @hidden */
  79001. _prepare(): void;
  79002. /**
  79003. * Execute the action and play the animation.
  79004. */
  79005. execute(): void;
  79006. /**
  79007. * Serializes the actions and its related information.
  79008. * @param parent defines the object to serialize in
  79009. * @returns the serialized object
  79010. */
  79011. serialize(parent: any): any;
  79012. }
  79013. /**
  79014. * This defines an action responsible to stop an animation once triggered.
  79015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79016. */
  79017. export class StopAnimationAction extends Action {
  79018. private _target;
  79019. /**
  79020. * Instantiate the action
  79021. * @param triggerOptions defines the trigger options
  79022. * @param target defines the target animation or animation name
  79023. * @param condition defines the trigger related conditions
  79024. */
  79025. constructor(triggerOptions: any, target: any, condition?: Condition);
  79026. /** @hidden */
  79027. _prepare(): void;
  79028. /**
  79029. * Execute the action and stop the animation.
  79030. */
  79031. execute(): void;
  79032. /**
  79033. * Serializes the actions and its related information.
  79034. * @param parent defines the object to serialize in
  79035. * @returns the serialized object
  79036. */
  79037. serialize(parent: any): any;
  79038. }
  79039. /**
  79040. * This defines an action responsible that does nothing once triggered.
  79041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79042. */
  79043. export class DoNothingAction extends Action {
  79044. /**
  79045. * Instantiate the action
  79046. * @param triggerOptions defines the trigger options
  79047. * @param condition defines the trigger related conditions
  79048. */
  79049. constructor(triggerOptions?: any, condition?: Condition);
  79050. /**
  79051. * Execute the action and do nothing.
  79052. */
  79053. execute(): void;
  79054. /**
  79055. * Serializes the actions and its related information.
  79056. * @param parent defines the object to serialize in
  79057. * @returns the serialized object
  79058. */
  79059. serialize(parent: any): any;
  79060. }
  79061. /**
  79062. * This defines an action responsible to trigger several actions once triggered.
  79063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79064. */
  79065. export class CombineAction extends Action {
  79066. /**
  79067. * The list of aggregated animations to run.
  79068. */
  79069. children: Action[];
  79070. /**
  79071. * Instantiate the action
  79072. * @param triggerOptions defines the trigger options
  79073. * @param children defines the list of aggregated animations to run
  79074. * @param condition defines the trigger related conditions
  79075. */
  79076. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  79077. /** @hidden */
  79078. _prepare(): void;
  79079. /**
  79080. * Execute the action and executes all the aggregated actions.
  79081. */
  79082. execute(evt: ActionEvent): void;
  79083. /**
  79084. * Serializes the actions and its related information.
  79085. * @param parent defines the object to serialize in
  79086. * @returns the serialized object
  79087. */
  79088. serialize(parent: any): any;
  79089. }
  79090. /**
  79091. * This defines an action responsible to run code (external event) once triggered.
  79092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79093. */
  79094. export class ExecuteCodeAction extends Action {
  79095. /**
  79096. * The callback function to run.
  79097. */
  79098. func: (evt: ActionEvent) => void;
  79099. /**
  79100. * Instantiate the action
  79101. * @param triggerOptions defines the trigger options
  79102. * @param func defines the callback function to run
  79103. * @param condition defines the trigger related conditions
  79104. */
  79105. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  79106. /**
  79107. * Execute the action and run the attached code.
  79108. */
  79109. execute(evt: ActionEvent): void;
  79110. }
  79111. /**
  79112. * This defines an action responsible to set the parent property of the target once triggered.
  79113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79114. */
  79115. export class SetParentAction extends Action {
  79116. private _parent;
  79117. private _target;
  79118. /**
  79119. * Instantiate the action
  79120. * @param triggerOptions defines the trigger options
  79121. * @param target defines the target containing the parent property
  79122. * @param parent defines from where the animation should start (animation frame)
  79123. * @param condition defines the trigger related conditions
  79124. */
  79125. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  79126. /** @hidden */
  79127. _prepare(): void;
  79128. /**
  79129. * Execute the action and set the parent property.
  79130. */
  79131. execute(): void;
  79132. /**
  79133. * Serializes the actions and its related information.
  79134. * @param parent defines the object to serialize in
  79135. * @returns the serialized object
  79136. */
  79137. serialize(parent: any): any;
  79138. }
  79139. }
  79140. declare module BABYLON {
  79141. /**
  79142. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  79143. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  79144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79145. */
  79146. export class ActionManager extends AbstractActionManager {
  79147. /**
  79148. * Nothing
  79149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79150. */
  79151. static readonly NothingTrigger: number;
  79152. /**
  79153. * On pick
  79154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79155. */
  79156. static readonly OnPickTrigger: number;
  79157. /**
  79158. * On left pick
  79159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79160. */
  79161. static readonly OnLeftPickTrigger: number;
  79162. /**
  79163. * On right pick
  79164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79165. */
  79166. static readonly OnRightPickTrigger: number;
  79167. /**
  79168. * On center pick
  79169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79170. */
  79171. static readonly OnCenterPickTrigger: number;
  79172. /**
  79173. * On pick down
  79174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79175. */
  79176. static readonly OnPickDownTrigger: number;
  79177. /**
  79178. * On double pick
  79179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79180. */
  79181. static readonly OnDoublePickTrigger: number;
  79182. /**
  79183. * On pick up
  79184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79185. */
  79186. static readonly OnPickUpTrigger: number;
  79187. /**
  79188. * On pick out.
  79189. * This trigger will only be raised if you also declared a OnPickDown
  79190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79191. */
  79192. static readonly OnPickOutTrigger: number;
  79193. /**
  79194. * On long press
  79195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79196. */
  79197. static readonly OnLongPressTrigger: number;
  79198. /**
  79199. * On pointer over
  79200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79201. */
  79202. static readonly OnPointerOverTrigger: number;
  79203. /**
  79204. * On pointer out
  79205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79206. */
  79207. static readonly OnPointerOutTrigger: number;
  79208. /**
  79209. * On every frame
  79210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79211. */
  79212. static readonly OnEveryFrameTrigger: number;
  79213. /**
  79214. * On intersection enter
  79215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79216. */
  79217. static readonly OnIntersectionEnterTrigger: number;
  79218. /**
  79219. * On intersection exit
  79220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79221. */
  79222. static readonly OnIntersectionExitTrigger: number;
  79223. /**
  79224. * On key down
  79225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79226. */
  79227. static readonly OnKeyDownTrigger: number;
  79228. /**
  79229. * On key up
  79230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79231. */
  79232. static readonly OnKeyUpTrigger: number;
  79233. private _scene;
  79234. /**
  79235. * Creates a new action manager
  79236. * @param scene defines the hosting scene
  79237. */
  79238. constructor(scene: Scene);
  79239. /**
  79240. * Releases all associated resources
  79241. */
  79242. dispose(): void;
  79243. /**
  79244. * Gets hosting scene
  79245. * @returns the hosting scene
  79246. */
  79247. getScene(): Scene;
  79248. /**
  79249. * Does this action manager handles actions of any of the given triggers
  79250. * @param triggers defines the triggers to be tested
  79251. * @return a boolean indicating whether one (or more) of the triggers is handled
  79252. */
  79253. hasSpecificTriggers(triggers: number[]): boolean;
  79254. /**
  79255. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  79256. * speed.
  79257. * @param triggerA defines the trigger to be tested
  79258. * @param triggerB defines the trigger to be tested
  79259. * @return a boolean indicating whether one (or more) of the triggers is handled
  79260. */
  79261. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  79262. /**
  79263. * Does this action manager handles actions of a given trigger
  79264. * @param trigger defines the trigger to be tested
  79265. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  79266. * @return whether the trigger is handled
  79267. */
  79268. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  79269. /**
  79270. * Does this action manager has pointer triggers
  79271. */
  79272. readonly hasPointerTriggers: boolean;
  79273. /**
  79274. * Does this action manager has pick triggers
  79275. */
  79276. readonly hasPickTriggers: boolean;
  79277. /**
  79278. * Registers an action to this action manager
  79279. * @param action defines the action to be registered
  79280. * @return the action amended (prepared) after registration
  79281. */
  79282. registerAction(action: IAction): Nullable<IAction>;
  79283. /**
  79284. * Unregisters an action to this action manager
  79285. * @param action defines the action to be unregistered
  79286. * @return a boolean indicating whether the action has been unregistered
  79287. */
  79288. unregisterAction(action: IAction): Boolean;
  79289. /**
  79290. * Process a specific trigger
  79291. * @param trigger defines the trigger to process
  79292. * @param evt defines the event details to be processed
  79293. */
  79294. processTrigger(trigger: number, evt?: IActionEvent): void;
  79295. /** @hidden */
  79296. _getEffectiveTarget(target: any, propertyPath: string): any;
  79297. /** @hidden */
  79298. _getProperty(propertyPath: string): string;
  79299. /**
  79300. * Serialize this manager to a JSON object
  79301. * @param name defines the property name to store this manager
  79302. * @returns a JSON representation of this manager
  79303. */
  79304. serialize(name: string): any;
  79305. /**
  79306. * Creates a new ActionManager from a JSON data
  79307. * @param parsedActions defines the JSON data to read from
  79308. * @param object defines the hosting mesh
  79309. * @param scene defines the hosting scene
  79310. */
  79311. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  79312. /**
  79313. * Get a trigger name by index
  79314. * @param trigger defines the trigger index
  79315. * @returns a trigger name
  79316. */
  79317. static GetTriggerName(trigger: number): string;
  79318. }
  79319. }
  79320. declare module BABYLON {
  79321. /**
  79322. * Class representing a ray with position and direction
  79323. */
  79324. export class Ray {
  79325. /** origin point */
  79326. origin: Vector3;
  79327. /** direction */
  79328. direction: Vector3;
  79329. /** length of the ray */
  79330. length: number;
  79331. private static readonly TmpVector3;
  79332. private _tmpRay;
  79333. /**
  79334. * Creates a new ray
  79335. * @param origin origin point
  79336. * @param direction direction
  79337. * @param length length of the ray
  79338. */
  79339. constructor(
  79340. /** origin point */
  79341. origin: Vector3,
  79342. /** direction */
  79343. direction: Vector3,
  79344. /** length of the ray */
  79345. length?: number);
  79346. /**
  79347. * Checks if the ray intersects a box
  79348. * @param minimum bound of the box
  79349. * @param maximum bound of the box
  79350. * @param intersectionTreshold extra extend to be added to the box in all direction
  79351. * @returns if the box was hit
  79352. */
  79353. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  79354. /**
  79355. * Checks if the ray intersects a box
  79356. * @param box the bounding box to check
  79357. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  79358. * @returns if the box was hit
  79359. */
  79360. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  79361. /**
  79362. * If the ray hits a sphere
  79363. * @param sphere the bounding sphere to check
  79364. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  79365. * @returns true if it hits the sphere
  79366. */
  79367. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  79368. /**
  79369. * If the ray hits a triange
  79370. * @param vertex0 triangle vertex
  79371. * @param vertex1 triangle vertex
  79372. * @param vertex2 triangle vertex
  79373. * @returns intersection information if hit
  79374. */
  79375. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  79376. /**
  79377. * Checks if ray intersects a plane
  79378. * @param plane the plane to check
  79379. * @returns the distance away it was hit
  79380. */
  79381. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  79382. /**
  79383. * Calculate the intercept of a ray on a given axis
  79384. * @param axis to check 'x' | 'y' | 'z'
  79385. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  79386. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  79387. */
  79388. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  79389. /**
  79390. * Checks if ray intersects a mesh
  79391. * @param mesh the mesh to check
  79392. * @param fastCheck if only the bounding box should checked
  79393. * @returns picking info of the intersecton
  79394. */
  79395. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  79396. /**
  79397. * Checks if ray intersects a mesh
  79398. * @param meshes the meshes to check
  79399. * @param fastCheck if only the bounding box should checked
  79400. * @param results array to store result in
  79401. * @returns Array of picking infos
  79402. */
  79403. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  79404. private _comparePickingInfo;
  79405. private static smallnum;
  79406. private static rayl;
  79407. /**
  79408. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  79409. * @param sega the first point of the segment to test the intersection against
  79410. * @param segb the second point of the segment to test the intersection against
  79411. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  79412. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  79413. */
  79414. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  79415. /**
  79416. * Update the ray from viewport position
  79417. * @param x position
  79418. * @param y y position
  79419. * @param viewportWidth viewport width
  79420. * @param viewportHeight viewport height
  79421. * @param world world matrix
  79422. * @param view view matrix
  79423. * @param projection projection matrix
  79424. * @returns this ray updated
  79425. */
  79426. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79427. /**
  79428. * Creates a ray with origin and direction of 0,0,0
  79429. * @returns the new ray
  79430. */
  79431. static Zero(): Ray;
  79432. /**
  79433. * Creates a new ray from screen space and viewport
  79434. * @param x position
  79435. * @param y y position
  79436. * @param viewportWidth viewport width
  79437. * @param viewportHeight viewport height
  79438. * @param world world matrix
  79439. * @param view view matrix
  79440. * @param projection projection matrix
  79441. * @returns new ray
  79442. */
  79443. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79444. /**
  79445. * 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
  79446. * transformed to the given world matrix.
  79447. * @param origin The origin point
  79448. * @param end The end point
  79449. * @param world a matrix to transform the ray to. Default is the identity matrix.
  79450. * @returns the new ray
  79451. */
  79452. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  79453. /**
  79454. * Transforms a ray by a matrix
  79455. * @param ray ray to transform
  79456. * @param matrix matrix to apply
  79457. * @returns the resulting new ray
  79458. */
  79459. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  79460. /**
  79461. * Transforms a ray by a matrix
  79462. * @param ray ray to transform
  79463. * @param matrix matrix to apply
  79464. * @param result ray to store result in
  79465. */
  79466. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  79467. /**
  79468. * Unproject a ray from screen space to object space
  79469. * @param sourceX defines the screen space x coordinate to use
  79470. * @param sourceY defines the screen space y coordinate to use
  79471. * @param viewportWidth defines the current width of the viewport
  79472. * @param viewportHeight defines the current height of the viewport
  79473. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79474. * @param view defines the view matrix to use
  79475. * @param projection defines the projection matrix to use
  79476. */
  79477. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  79478. }
  79479. /**
  79480. * Type used to define predicate used to select faces when a mesh intersection is detected
  79481. */
  79482. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  79483. interface Scene {
  79484. /** @hidden */
  79485. _tempPickingRay: Nullable<Ray>;
  79486. /** @hidden */
  79487. _cachedRayForTransform: Ray;
  79488. /** @hidden */
  79489. _pickWithRayInverseMatrix: Matrix;
  79490. /** @hidden */
  79491. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  79492. /** @hidden */
  79493. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  79494. }
  79495. }
  79496. declare module BABYLON {
  79497. /**
  79498. * Groups all the scene component constants in one place to ease maintenance.
  79499. * @hidden
  79500. */
  79501. export class SceneComponentConstants {
  79502. static readonly NAME_EFFECTLAYER: string;
  79503. static readonly NAME_LAYER: string;
  79504. static readonly NAME_LENSFLARESYSTEM: string;
  79505. static readonly NAME_BOUNDINGBOXRENDERER: string;
  79506. static readonly NAME_PARTICLESYSTEM: string;
  79507. static readonly NAME_GAMEPAD: string;
  79508. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  79509. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  79510. static readonly NAME_DEPTHRENDERER: string;
  79511. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  79512. static readonly NAME_SPRITE: string;
  79513. static readonly NAME_OUTLINERENDERER: string;
  79514. static readonly NAME_PROCEDURALTEXTURE: string;
  79515. static readonly NAME_SHADOWGENERATOR: string;
  79516. static readonly NAME_OCTREE: string;
  79517. static readonly NAME_PHYSICSENGINE: string;
  79518. static readonly NAME_AUDIO: string;
  79519. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  79520. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79521. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  79522. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79523. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  79524. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  79525. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  79526. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  79527. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  79528. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  79529. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  79530. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  79531. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  79532. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  79533. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  79534. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  79535. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  79536. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  79537. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  79538. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  79539. static readonly STEP_AFTERRENDER_AUDIO: number;
  79540. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  79541. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  79542. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  79543. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  79544. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  79545. static readonly STEP_POINTERMOVE_SPRITE: number;
  79546. static readonly STEP_POINTERDOWN_SPRITE: number;
  79547. static readonly STEP_POINTERUP_SPRITE: number;
  79548. }
  79549. /**
  79550. * This represents a scene component.
  79551. *
  79552. * This is used to decouple the dependency the scene is having on the different workloads like
  79553. * layers, post processes...
  79554. */
  79555. export interface ISceneComponent {
  79556. /**
  79557. * The name of the component. Each component must have a unique name.
  79558. */
  79559. name: string;
  79560. /**
  79561. * The scene the component belongs to.
  79562. */
  79563. scene: Scene;
  79564. /**
  79565. * Register the component to one instance of a scene.
  79566. */
  79567. register(): void;
  79568. /**
  79569. * Rebuilds the elements related to this component in case of
  79570. * context lost for instance.
  79571. */
  79572. rebuild(): void;
  79573. /**
  79574. * Disposes the component and the associated ressources.
  79575. */
  79576. dispose(): void;
  79577. }
  79578. /**
  79579. * This represents a SERIALIZABLE scene component.
  79580. *
  79581. * This extends Scene Component to add Serialization methods on top.
  79582. */
  79583. export interface ISceneSerializableComponent extends ISceneComponent {
  79584. /**
  79585. * Adds all the elements from the container to the scene
  79586. * @param container the container holding the elements
  79587. */
  79588. addFromContainer(container: AbstractScene): void;
  79589. /**
  79590. * Removes all the elements in the container from the scene
  79591. * @param container contains the elements to remove
  79592. * @param dispose if the removed element should be disposed (default: false)
  79593. */
  79594. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  79595. /**
  79596. * Serializes the component data to the specified json object
  79597. * @param serializationObject The object to serialize to
  79598. */
  79599. serialize(serializationObject: any): void;
  79600. }
  79601. /**
  79602. * Strong typing of a Mesh related stage step action
  79603. */
  79604. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  79605. /**
  79606. * Strong typing of a Evaluate Sub Mesh related stage step action
  79607. */
  79608. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  79609. /**
  79610. * Strong typing of a Active Mesh related stage step action
  79611. */
  79612. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  79613. /**
  79614. * Strong typing of a Camera related stage step action
  79615. */
  79616. export type CameraStageAction = (camera: Camera) => void;
  79617. /**
  79618. * Strong typing of a Camera Frame buffer related stage step action
  79619. */
  79620. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  79621. /**
  79622. * Strong typing of a Render Target related stage step action
  79623. */
  79624. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  79625. /**
  79626. * Strong typing of a RenderingGroup related stage step action
  79627. */
  79628. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  79629. /**
  79630. * Strong typing of a Mesh Render related stage step action
  79631. */
  79632. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  79633. /**
  79634. * Strong typing of a simple stage step action
  79635. */
  79636. export type SimpleStageAction = () => void;
  79637. /**
  79638. * Strong typing of a render target action.
  79639. */
  79640. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  79641. /**
  79642. * Strong typing of a pointer move action.
  79643. */
  79644. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  79645. /**
  79646. * Strong typing of a pointer up/down action.
  79647. */
  79648. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  79649. /**
  79650. * Representation of a stage in the scene (Basically a list of ordered steps)
  79651. * @hidden
  79652. */
  79653. export class Stage<T extends Function> extends Array<{
  79654. index: number;
  79655. component: ISceneComponent;
  79656. action: T;
  79657. }> {
  79658. /**
  79659. * Hide ctor from the rest of the world.
  79660. * @param items The items to add.
  79661. */
  79662. private constructor();
  79663. /**
  79664. * Creates a new Stage.
  79665. * @returns A new instance of a Stage
  79666. */
  79667. static Create<T extends Function>(): Stage<T>;
  79668. /**
  79669. * Registers a step in an ordered way in the targeted stage.
  79670. * @param index Defines the position to register the step in
  79671. * @param component Defines the component attached to the step
  79672. * @param action Defines the action to launch during the step
  79673. */
  79674. registerStep(index: number, component: ISceneComponent, action: T): void;
  79675. /**
  79676. * Clears all the steps from the stage.
  79677. */
  79678. clear(): void;
  79679. }
  79680. }
  79681. declare module BABYLON {
  79682. interface Scene {
  79683. /** @hidden */
  79684. _pointerOverSprite: Nullable<Sprite>;
  79685. /** @hidden */
  79686. _pickedDownSprite: Nullable<Sprite>;
  79687. /** @hidden */
  79688. _tempSpritePickingRay: Nullable<Ray>;
  79689. /**
  79690. * All of the sprite managers added to this scene
  79691. * @see http://doc.babylonjs.com/babylon101/sprites
  79692. */
  79693. spriteManagers: Array<ISpriteManager>;
  79694. /**
  79695. * An event triggered when sprites rendering is about to start
  79696. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79697. */
  79698. onBeforeSpritesRenderingObservable: Observable<Scene>;
  79699. /**
  79700. * An event triggered when sprites rendering is done
  79701. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79702. */
  79703. onAfterSpritesRenderingObservable: Observable<Scene>;
  79704. /** @hidden */
  79705. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79706. /** Launch a ray to try to pick a sprite in the scene
  79707. * @param x position on screen
  79708. * @param y position on screen
  79709. * @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
  79710. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79711. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79712. * @returns a PickingInfo
  79713. */
  79714. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79715. /** Use the given ray to pick a sprite in the scene
  79716. * @param ray The ray (in world space) to use to pick meshes
  79717. * @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
  79718. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79719. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79720. * @returns a PickingInfo
  79721. */
  79722. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79723. /** @hidden */
  79724. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79725. /** Launch a ray to try to pick sprites in the scene
  79726. * @param x position on screen
  79727. * @param y position on screen
  79728. * @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
  79729. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79730. * @returns a PickingInfo array
  79731. */
  79732. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79733. /** Use the given ray to pick sprites in the scene
  79734. * @param ray The ray (in world space) to use to pick meshes
  79735. * @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
  79736. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79737. * @returns a PickingInfo array
  79738. */
  79739. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79740. /**
  79741. * Force the sprite under the pointer
  79742. * @param sprite defines the sprite to use
  79743. */
  79744. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  79745. /**
  79746. * Gets the sprite under the pointer
  79747. * @returns a Sprite or null if no sprite is under the pointer
  79748. */
  79749. getPointerOverSprite(): Nullable<Sprite>;
  79750. }
  79751. /**
  79752. * Defines the sprite scene component responsible to manage sprites
  79753. * in a given scene.
  79754. */
  79755. export class SpriteSceneComponent implements ISceneComponent {
  79756. /**
  79757. * The component name helpfull to identify the component in the list of scene components.
  79758. */
  79759. readonly name: string;
  79760. /**
  79761. * The scene the component belongs to.
  79762. */
  79763. scene: Scene;
  79764. /** @hidden */
  79765. private _spritePredicate;
  79766. /**
  79767. * Creates a new instance of the component for the given scene
  79768. * @param scene Defines the scene to register the component in
  79769. */
  79770. constructor(scene: Scene);
  79771. /**
  79772. * Registers the component in a given scene
  79773. */
  79774. register(): void;
  79775. /**
  79776. * Rebuilds the elements related to this component in case of
  79777. * context lost for instance.
  79778. */
  79779. rebuild(): void;
  79780. /**
  79781. * Disposes the component and the associated ressources.
  79782. */
  79783. dispose(): void;
  79784. private _pickSpriteButKeepRay;
  79785. private _pointerMove;
  79786. private _pointerDown;
  79787. private _pointerUp;
  79788. }
  79789. }
  79790. declare module BABYLON {
  79791. /** @hidden */
  79792. export var fogFragmentDeclaration: {
  79793. name: string;
  79794. shader: string;
  79795. };
  79796. }
  79797. declare module BABYLON {
  79798. /** @hidden */
  79799. export var fogFragment: {
  79800. name: string;
  79801. shader: string;
  79802. };
  79803. }
  79804. declare module BABYLON {
  79805. /** @hidden */
  79806. export var spritesPixelShader: {
  79807. name: string;
  79808. shader: string;
  79809. };
  79810. }
  79811. declare module BABYLON {
  79812. /** @hidden */
  79813. export var fogVertexDeclaration: {
  79814. name: string;
  79815. shader: string;
  79816. };
  79817. }
  79818. declare module BABYLON {
  79819. /** @hidden */
  79820. export var spritesVertexShader: {
  79821. name: string;
  79822. shader: string;
  79823. };
  79824. }
  79825. declare module BABYLON {
  79826. /**
  79827. * Defines the minimum interface to fullfil in order to be a sprite manager.
  79828. */
  79829. export interface ISpriteManager extends IDisposable {
  79830. /**
  79831. * Restricts the camera to viewing objects with the same layerMask.
  79832. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  79833. */
  79834. layerMask: number;
  79835. /**
  79836. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79837. */
  79838. isPickable: boolean;
  79839. /**
  79840. * Specifies the rendering group id for this mesh (0 by default)
  79841. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79842. */
  79843. renderingGroupId: number;
  79844. /**
  79845. * Defines the list of sprites managed by the manager.
  79846. */
  79847. sprites: Array<Sprite>;
  79848. /**
  79849. * Tests the intersection of a sprite with a specific ray.
  79850. * @param ray The ray we are sending to test the collision
  79851. * @param camera The camera space we are sending rays in
  79852. * @param predicate A predicate allowing excluding sprites from the list of object to test
  79853. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  79854. * @returns picking info or null.
  79855. */
  79856. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79857. /**
  79858. * Intersects the sprites with a ray
  79859. * @param ray defines the ray to intersect with
  79860. * @param camera defines the current active camera
  79861. * @param predicate defines a predicate used to select candidate sprites
  79862. * @returns null if no hit or a PickingInfo array
  79863. */
  79864. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79865. /**
  79866. * Renders the list of sprites on screen.
  79867. */
  79868. render(): void;
  79869. }
  79870. /**
  79871. * Class used to manage multiple sprites on the same spritesheet
  79872. * @see http://doc.babylonjs.com/babylon101/sprites
  79873. */
  79874. export class SpriteManager implements ISpriteManager {
  79875. /** defines the manager's name */
  79876. name: string;
  79877. /** Gets the list of sprites */
  79878. sprites: Sprite[];
  79879. /** Gets or sets the rendering group id (0 by default) */
  79880. renderingGroupId: number;
  79881. /** Gets or sets camera layer mask */
  79882. layerMask: number;
  79883. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  79884. fogEnabled: boolean;
  79885. /** Gets or sets a boolean indicating if the sprites are pickable */
  79886. isPickable: boolean;
  79887. /** Defines the default width of a cell in the spritesheet */
  79888. cellWidth: number;
  79889. /** Defines the default height of a cell in the spritesheet */
  79890. cellHeight: number;
  79891. /** Associative array from JSON sprite data file */
  79892. private _cellData;
  79893. /** Array of sprite names from JSON sprite data file */
  79894. private _spriteMap;
  79895. /** True when packed cell data from JSON file is ready*/
  79896. private _packedAndReady;
  79897. /**
  79898. * An event triggered when the manager is disposed.
  79899. */
  79900. onDisposeObservable: Observable<SpriteManager>;
  79901. private _onDisposeObserver;
  79902. /**
  79903. * Callback called when the manager is disposed
  79904. */
  79905. onDispose: () => void;
  79906. private _capacity;
  79907. private _fromPacked;
  79908. private _spriteTexture;
  79909. private _epsilon;
  79910. private _scene;
  79911. private _vertexData;
  79912. private _buffer;
  79913. private _vertexBuffers;
  79914. private _indexBuffer;
  79915. private _effectBase;
  79916. private _effectFog;
  79917. /**
  79918. * Gets or sets the spritesheet texture
  79919. */
  79920. texture: Texture;
  79921. /**
  79922. * Creates a new sprite manager
  79923. * @param name defines the manager's name
  79924. * @param imgUrl defines the sprite sheet url
  79925. * @param capacity defines the maximum allowed number of sprites
  79926. * @param cellSize defines the size of a sprite cell
  79927. * @param scene defines the hosting scene
  79928. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  79929. * @param samplingMode defines the smapling mode to use with spritesheet
  79930. * @param fromPacked set to false; do not alter
  79931. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  79932. */
  79933. constructor(
  79934. /** defines the manager's name */
  79935. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  79936. private _makePacked;
  79937. private _appendSpriteVertex;
  79938. /**
  79939. * Intersects the sprites with a ray
  79940. * @param ray defines the ray to intersect with
  79941. * @param camera defines the current active camera
  79942. * @param predicate defines a predicate used to select candidate sprites
  79943. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  79944. * @returns null if no hit or a PickingInfo
  79945. */
  79946. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79947. /**
  79948. * Intersects the sprites with a ray
  79949. * @param ray defines the ray to intersect with
  79950. * @param camera defines the current active camera
  79951. * @param predicate defines a predicate used to select candidate sprites
  79952. * @returns null if no hit or a PickingInfo array
  79953. */
  79954. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79955. /**
  79956. * Render all child sprites
  79957. */
  79958. render(): void;
  79959. /**
  79960. * Release associated resources
  79961. */
  79962. dispose(): void;
  79963. }
  79964. }
  79965. declare module BABYLON {
  79966. /**
  79967. * Class used to represent a sprite
  79968. * @see http://doc.babylonjs.com/babylon101/sprites
  79969. */
  79970. export class Sprite {
  79971. /** defines the name */
  79972. name: string;
  79973. /** Gets or sets the current world position */
  79974. position: Vector3;
  79975. /** Gets or sets the main color */
  79976. color: Color4;
  79977. /** Gets or sets the width */
  79978. width: number;
  79979. /** Gets or sets the height */
  79980. height: number;
  79981. /** Gets or sets rotation angle */
  79982. angle: number;
  79983. /** Gets or sets the cell index in the sprite sheet */
  79984. cellIndex: number;
  79985. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  79986. cellRef: string;
  79987. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  79988. invertU: number;
  79989. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  79990. invertV: number;
  79991. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  79992. disposeWhenFinishedAnimating: boolean;
  79993. /** Gets the list of attached animations */
  79994. animations: Animation[];
  79995. /** Gets or sets a boolean indicating if the sprite can be picked */
  79996. isPickable: boolean;
  79997. /**
  79998. * Gets or sets the associated action manager
  79999. */
  80000. actionManager: Nullable<ActionManager>;
  80001. private _animationStarted;
  80002. private _loopAnimation;
  80003. private _fromIndex;
  80004. private _toIndex;
  80005. private _delay;
  80006. private _direction;
  80007. private _manager;
  80008. private _time;
  80009. private _onAnimationEnd;
  80010. /**
  80011. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  80012. */
  80013. isVisible: boolean;
  80014. /**
  80015. * Gets or sets the sprite size
  80016. */
  80017. size: number;
  80018. /**
  80019. * Creates a new Sprite
  80020. * @param name defines the name
  80021. * @param manager defines the manager
  80022. */
  80023. constructor(
  80024. /** defines the name */
  80025. name: string, manager: ISpriteManager);
  80026. /**
  80027. * Starts an animation
  80028. * @param from defines the initial key
  80029. * @param to defines the end key
  80030. * @param loop defines if the animation must loop
  80031. * @param delay defines the start delay (in ms)
  80032. * @param onAnimationEnd defines a callback to call when animation ends
  80033. */
  80034. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  80035. /** Stops current animation (if any) */
  80036. stopAnimation(): void;
  80037. /** @hidden */
  80038. _animate(deltaTime: number): void;
  80039. /** Release associated resources */
  80040. dispose(): void;
  80041. }
  80042. }
  80043. declare module BABYLON {
  80044. /**
  80045. * Information about the result of picking within a scene
  80046. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  80047. */
  80048. export class PickingInfo {
  80049. /** @hidden */
  80050. _pickingUnavailable: boolean;
  80051. /**
  80052. * If the pick collided with an object
  80053. */
  80054. hit: boolean;
  80055. /**
  80056. * Distance away where the pick collided
  80057. */
  80058. distance: number;
  80059. /**
  80060. * The location of pick collision
  80061. */
  80062. pickedPoint: Nullable<Vector3>;
  80063. /**
  80064. * The mesh corresponding the the pick collision
  80065. */
  80066. pickedMesh: Nullable<AbstractMesh>;
  80067. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  80068. bu: number;
  80069. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  80070. bv: number;
  80071. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  80072. faceId: number;
  80073. /** Id of the the submesh that was picked */
  80074. subMeshId: number;
  80075. /** If a sprite was picked, this will be the sprite the pick collided with */
  80076. pickedSprite: Nullable<Sprite>;
  80077. /**
  80078. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  80079. */
  80080. originMesh: Nullable<AbstractMesh>;
  80081. /**
  80082. * The ray that was used to perform the picking.
  80083. */
  80084. ray: Nullable<Ray>;
  80085. /**
  80086. * Gets the normal correspodning to the face the pick collided with
  80087. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  80088. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  80089. * @returns The normal correspodning to the face the pick collided with
  80090. */
  80091. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  80092. /**
  80093. * Gets the texture coordinates of where the pick occured
  80094. * @returns the vector containing the coordnates of the texture
  80095. */
  80096. getTextureCoordinates(): Nullable<Vector2>;
  80097. }
  80098. }
  80099. declare module BABYLON {
  80100. /**
  80101. * Gather the list of pointer event types as constants.
  80102. */
  80103. export class PointerEventTypes {
  80104. /**
  80105. * 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.
  80106. */
  80107. static readonly POINTERDOWN: number;
  80108. /**
  80109. * The pointerup event is fired when a pointer is no longer active.
  80110. */
  80111. static readonly POINTERUP: number;
  80112. /**
  80113. * The pointermove event is fired when a pointer changes coordinates.
  80114. */
  80115. static readonly POINTERMOVE: number;
  80116. /**
  80117. * The pointerwheel event is fired when a mouse wheel has been rotated.
  80118. */
  80119. static readonly POINTERWHEEL: number;
  80120. /**
  80121. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  80122. */
  80123. static readonly POINTERPICK: number;
  80124. /**
  80125. * The pointertap event is fired when a the object has been touched and released without drag.
  80126. */
  80127. static readonly POINTERTAP: number;
  80128. /**
  80129. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  80130. */
  80131. static readonly POINTERDOUBLETAP: number;
  80132. }
  80133. /**
  80134. * Base class of pointer info types.
  80135. */
  80136. export class PointerInfoBase {
  80137. /**
  80138. * Defines the type of event (PointerEventTypes)
  80139. */
  80140. type: number;
  80141. /**
  80142. * Defines the related dom event
  80143. */
  80144. event: PointerEvent | MouseWheelEvent;
  80145. /**
  80146. * Instantiates the base class of pointers info.
  80147. * @param type Defines the type of event (PointerEventTypes)
  80148. * @param event Defines the related dom event
  80149. */
  80150. constructor(
  80151. /**
  80152. * Defines the type of event (PointerEventTypes)
  80153. */
  80154. type: number,
  80155. /**
  80156. * Defines the related dom event
  80157. */
  80158. event: PointerEvent | MouseWheelEvent);
  80159. }
  80160. /**
  80161. * This class is used to store pointer related info for the onPrePointerObservable event.
  80162. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  80163. */
  80164. export class PointerInfoPre extends PointerInfoBase {
  80165. /**
  80166. * Ray from a pointer if availible (eg. 6dof controller)
  80167. */
  80168. ray: Nullable<Ray>;
  80169. /**
  80170. * Defines the local position of the pointer on the canvas.
  80171. */
  80172. localPosition: Vector2;
  80173. /**
  80174. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  80175. */
  80176. skipOnPointerObservable: boolean;
  80177. /**
  80178. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  80179. * @param type Defines the type of event (PointerEventTypes)
  80180. * @param event Defines the related dom event
  80181. * @param localX Defines the local x coordinates of the pointer when the event occured
  80182. * @param localY Defines the local y coordinates of the pointer when the event occured
  80183. */
  80184. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  80185. }
  80186. /**
  80187. * This type contains all the data related to a pointer event in Babylon.js.
  80188. * 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.
  80189. */
  80190. export class PointerInfo extends PointerInfoBase {
  80191. /**
  80192. * Defines the picking info associated to the info (if any)\
  80193. */
  80194. pickInfo: Nullable<PickingInfo>;
  80195. /**
  80196. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  80197. * @param type Defines the type of event (PointerEventTypes)
  80198. * @param event Defines the related dom event
  80199. * @param pickInfo Defines the picking info associated to the info (if any)\
  80200. */
  80201. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  80202. /**
  80203. * Defines the picking info associated to the info (if any)\
  80204. */
  80205. pickInfo: Nullable<PickingInfo>);
  80206. }
  80207. /**
  80208. * Data relating to a touch event on the screen.
  80209. */
  80210. export interface PointerTouch {
  80211. /**
  80212. * X coordinate of touch.
  80213. */
  80214. x: number;
  80215. /**
  80216. * Y coordinate of touch.
  80217. */
  80218. y: number;
  80219. /**
  80220. * Id of touch. Unique for each finger.
  80221. */
  80222. pointerId: number;
  80223. /**
  80224. * Event type passed from DOM.
  80225. */
  80226. type: any;
  80227. }
  80228. }
  80229. declare module BABYLON {
  80230. /**
  80231. * Manage the mouse inputs to control the movement of a free camera.
  80232. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80233. */
  80234. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  80235. /**
  80236. * Define if touch is enabled in the mouse input
  80237. */
  80238. touchEnabled: boolean;
  80239. /**
  80240. * Defines the camera the input is attached to.
  80241. */
  80242. camera: FreeCamera;
  80243. /**
  80244. * Defines the buttons associated with the input to handle camera move.
  80245. */
  80246. buttons: number[];
  80247. /**
  80248. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  80249. */
  80250. angularSensibility: number;
  80251. private _pointerInput;
  80252. private _onMouseMove;
  80253. private _observer;
  80254. private previousPosition;
  80255. /**
  80256. * Observable for when a pointer move event occurs containing the move offset
  80257. */
  80258. onPointerMovedObservable: Observable<{
  80259. offsetX: number;
  80260. offsetY: number;
  80261. }>;
  80262. /**
  80263. * @hidden
  80264. * If the camera should be rotated automatically based on pointer movement
  80265. */
  80266. _allowCameraRotation: boolean;
  80267. /**
  80268. * Manage the mouse inputs to control the movement of a free camera.
  80269. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80270. * @param touchEnabled Defines if touch is enabled or not
  80271. */
  80272. constructor(
  80273. /**
  80274. * Define if touch is enabled in the mouse input
  80275. */
  80276. touchEnabled?: boolean);
  80277. /**
  80278. * Attach the input controls to a specific dom element to get the input from.
  80279. * @param element Defines the element the controls should be listened from
  80280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80281. */
  80282. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80283. /**
  80284. * Called on JS contextmenu event.
  80285. * Override this method to provide functionality.
  80286. */
  80287. protected onContextMenu(evt: PointerEvent): void;
  80288. /**
  80289. * Detach the current controls from the specified dom element.
  80290. * @param element Defines the element to stop listening the inputs from
  80291. */
  80292. detachControl(element: Nullable<HTMLElement>): void;
  80293. /**
  80294. * Gets the class name of the current intput.
  80295. * @returns the class name
  80296. */
  80297. getClassName(): string;
  80298. /**
  80299. * Get the friendly name associated with the input class.
  80300. * @returns the input friendly name
  80301. */
  80302. getSimpleName(): string;
  80303. }
  80304. }
  80305. declare module BABYLON {
  80306. /**
  80307. * Manage the touch inputs to control the movement of a free camera.
  80308. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80309. */
  80310. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  80311. /**
  80312. * Defines the camera the input is attached to.
  80313. */
  80314. camera: FreeCamera;
  80315. /**
  80316. * Defines the touch sensibility for rotation.
  80317. * The higher the faster.
  80318. */
  80319. touchAngularSensibility: number;
  80320. /**
  80321. * Defines the touch sensibility for move.
  80322. * The higher the faster.
  80323. */
  80324. touchMoveSensibility: number;
  80325. private _offsetX;
  80326. private _offsetY;
  80327. private _pointerPressed;
  80328. private _pointerInput;
  80329. private _observer;
  80330. private _onLostFocus;
  80331. /**
  80332. * Attach the input controls to a specific dom element to get the input from.
  80333. * @param element Defines the element the controls should be listened from
  80334. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80335. */
  80336. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80337. /**
  80338. * Detach the current controls from the specified dom element.
  80339. * @param element Defines the element to stop listening the inputs from
  80340. */
  80341. detachControl(element: Nullable<HTMLElement>): void;
  80342. /**
  80343. * Update the current camera state depending on the inputs that have been used this frame.
  80344. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80345. */
  80346. checkInputs(): void;
  80347. /**
  80348. * Gets the class name of the current intput.
  80349. * @returns the class name
  80350. */
  80351. getClassName(): string;
  80352. /**
  80353. * Get the friendly name associated with the input class.
  80354. * @returns the input friendly name
  80355. */
  80356. getSimpleName(): string;
  80357. }
  80358. }
  80359. declare module BABYLON {
  80360. /**
  80361. * Default Inputs manager for the FreeCamera.
  80362. * It groups all the default supported inputs for ease of use.
  80363. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80364. */
  80365. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  80366. /**
  80367. * @hidden
  80368. */
  80369. _mouseInput: Nullable<FreeCameraMouseInput>;
  80370. /**
  80371. * Instantiates a new FreeCameraInputsManager.
  80372. * @param camera Defines the camera the inputs belong to
  80373. */
  80374. constructor(camera: FreeCamera);
  80375. /**
  80376. * Add keyboard input support to the input manager.
  80377. * @returns the current input manager
  80378. */
  80379. addKeyboard(): FreeCameraInputsManager;
  80380. /**
  80381. * Add mouse input support to the input manager.
  80382. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  80383. * @returns the current input manager
  80384. */
  80385. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  80386. /**
  80387. * Removes the mouse input support from the manager
  80388. * @returns the current input manager
  80389. */
  80390. removeMouse(): FreeCameraInputsManager;
  80391. /**
  80392. * Add touch input support to the input manager.
  80393. * @returns the current input manager
  80394. */
  80395. addTouch(): FreeCameraInputsManager;
  80396. /**
  80397. * Remove all attached input methods from a camera
  80398. */
  80399. clear(): void;
  80400. }
  80401. }
  80402. declare module BABYLON {
  80403. /**
  80404. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80405. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  80406. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80407. */
  80408. export class FreeCamera extends TargetCamera {
  80409. /**
  80410. * Define the collision ellipsoid of the camera.
  80411. * This is helpful to simulate a camera body like the player body around the camera
  80412. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  80413. */
  80414. ellipsoid: Vector3;
  80415. /**
  80416. * Define an offset for the position of the ellipsoid around the camera.
  80417. * This can be helpful to determine the center of the body near the gravity center of the body
  80418. * instead of its head.
  80419. */
  80420. ellipsoidOffset: Vector3;
  80421. /**
  80422. * Enable or disable collisions of the camera with the rest of the scene objects.
  80423. */
  80424. checkCollisions: boolean;
  80425. /**
  80426. * Enable or disable gravity on the camera.
  80427. */
  80428. applyGravity: boolean;
  80429. /**
  80430. * Define the input manager associated to the camera.
  80431. */
  80432. inputs: FreeCameraInputsManager;
  80433. /**
  80434. * Gets the input sensibility for a mouse input. (default is 2000.0)
  80435. * Higher values reduce sensitivity.
  80436. */
  80437. /**
  80438. * Sets the input sensibility for a mouse input. (default is 2000.0)
  80439. * Higher values reduce sensitivity.
  80440. */
  80441. angularSensibility: number;
  80442. /**
  80443. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  80444. */
  80445. keysUp: number[];
  80446. /**
  80447. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  80448. */
  80449. keysDown: number[];
  80450. /**
  80451. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  80452. */
  80453. keysLeft: number[];
  80454. /**
  80455. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  80456. */
  80457. keysRight: number[];
  80458. /**
  80459. * Event raised when the camera collide with a mesh in the scene.
  80460. */
  80461. onCollide: (collidedMesh: AbstractMesh) => void;
  80462. private _collider;
  80463. private _needMoveForGravity;
  80464. private _oldPosition;
  80465. private _diffPosition;
  80466. private _newPosition;
  80467. /** @hidden */
  80468. _localDirection: Vector3;
  80469. /** @hidden */
  80470. _transformedDirection: Vector3;
  80471. /**
  80472. * Instantiates a Free Camera.
  80473. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80474. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  80475. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80476. * @param name Define the name of the camera in the scene
  80477. * @param position Define the start position of the camera in the scene
  80478. * @param scene Define the scene the camera belongs to
  80479. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  80480. */
  80481. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  80482. /**
  80483. * Attached controls to the current camera.
  80484. * @param element Defines the element the controls should be listened from
  80485. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80486. */
  80487. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80488. /**
  80489. * Detach the current controls from the camera.
  80490. * The camera will stop reacting to inputs.
  80491. * @param element Defines the element to stop listening the inputs from
  80492. */
  80493. detachControl(element: HTMLElement): void;
  80494. private _collisionMask;
  80495. /**
  80496. * Define a collision mask to limit the list of object the camera can collide with
  80497. */
  80498. collisionMask: number;
  80499. /** @hidden */
  80500. _collideWithWorld(displacement: Vector3): void;
  80501. private _onCollisionPositionChange;
  80502. /** @hidden */
  80503. _checkInputs(): void;
  80504. /** @hidden */
  80505. _decideIfNeedsToMove(): boolean;
  80506. /** @hidden */
  80507. _updatePosition(): void;
  80508. /**
  80509. * Destroy the camera and release the current resources hold by it.
  80510. */
  80511. dispose(): void;
  80512. /**
  80513. * Gets the current object class name.
  80514. * @return the class name
  80515. */
  80516. getClassName(): string;
  80517. }
  80518. }
  80519. declare module BABYLON {
  80520. /**
  80521. * Represents a gamepad control stick position
  80522. */
  80523. export class StickValues {
  80524. /**
  80525. * The x component of the control stick
  80526. */
  80527. x: number;
  80528. /**
  80529. * The y component of the control stick
  80530. */
  80531. y: number;
  80532. /**
  80533. * Initializes the gamepad x and y control stick values
  80534. * @param x The x component of the gamepad control stick value
  80535. * @param y The y component of the gamepad control stick value
  80536. */
  80537. constructor(
  80538. /**
  80539. * The x component of the control stick
  80540. */
  80541. x: number,
  80542. /**
  80543. * The y component of the control stick
  80544. */
  80545. y: number);
  80546. }
  80547. /**
  80548. * An interface which manages callbacks for gamepad button changes
  80549. */
  80550. export interface GamepadButtonChanges {
  80551. /**
  80552. * Called when a gamepad has been changed
  80553. */
  80554. changed: boolean;
  80555. /**
  80556. * Called when a gamepad press event has been triggered
  80557. */
  80558. pressChanged: boolean;
  80559. /**
  80560. * Called when a touch event has been triggered
  80561. */
  80562. touchChanged: boolean;
  80563. /**
  80564. * Called when a value has changed
  80565. */
  80566. valueChanged: boolean;
  80567. }
  80568. /**
  80569. * Represents a gamepad
  80570. */
  80571. export class Gamepad {
  80572. /**
  80573. * The id of the gamepad
  80574. */
  80575. id: string;
  80576. /**
  80577. * The index of the gamepad
  80578. */
  80579. index: number;
  80580. /**
  80581. * The browser gamepad
  80582. */
  80583. browserGamepad: any;
  80584. /**
  80585. * Specifies what type of gamepad this represents
  80586. */
  80587. type: number;
  80588. private _leftStick;
  80589. private _rightStick;
  80590. /** @hidden */
  80591. _isConnected: boolean;
  80592. private _leftStickAxisX;
  80593. private _leftStickAxisY;
  80594. private _rightStickAxisX;
  80595. private _rightStickAxisY;
  80596. /**
  80597. * Triggered when the left control stick has been changed
  80598. */
  80599. private _onleftstickchanged;
  80600. /**
  80601. * Triggered when the right control stick has been changed
  80602. */
  80603. private _onrightstickchanged;
  80604. /**
  80605. * Represents a gamepad controller
  80606. */
  80607. static GAMEPAD: number;
  80608. /**
  80609. * Represents a generic controller
  80610. */
  80611. static GENERIC: number;
  80612. /**
  80613. * Represents an XBox controller
  80614. */
  80615. static XBOX: number;
  80616. /**
  80617. * Represents a pose-enabled controller
  80618. */
  80619. static POSE_ENABLED: number;
  80620. /**
  80621. * Represents an Dual Shock controller
  80622. */
  80623. static DUALSHOCK: number;
  80624. /**
  80625. * Specifies whether the left control stick should be Y-inverted
  80626. */
  80627. protected _invertLeftStickY: boolean;
  80628. /**
  80629. * Specifies if the gamepad has been connected
  80630. */
  80631. readonly isConnected: boolean;
  80632. /**
  80633. * Initializes the gamepad
  80634. * @param id The id of the gamepad
  80635. * @param index The index of the gamepad
  80636. * @param browserGamepad The browser gamepad
  80637. * @param leftStickX The x component of the left joystick
  80638. * @param leftStickY The y component of the left joystick
  80639. * @param rightStickX The x component of the right joystick
  80640. * @param rightStickY The y component of the right joystick
  80641. */
  80642. constructor(
  80643. /**
  80644. * The id of the gamepad
  80645. */
  80646. id: string,
  80647. /**
  80648. * The index of the gamepad
  80649. */
  80650. index: number,
  80651. /**
  80652. * The browser gamepad
  80653. */
  80654. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  80655. /**
  80656. * Callback triggered when the left joystick has changed
  80657. * @param callback
  80658. */
  80659. onleftstickchanged(callback: (values: StickValues) => void): void;
  80660. /**
  80661. * Callback triggered when the right joystick has changed
  80662. * @param callback
  80663. */
  80664. onrightstickchanged(callback: (values: StickValues) => void): void;
  80665. /**
  80666. * Gets the left joystick
  80667. */
  80668. /**
  80669. * Sets the left joystick values
  80670. */
  80671. leftStick: StickValues;
  80672. /**
  80673. * Gets the right joystick
  80674. */
  80675. /**
  80676. * Sets the right joystick value
  80677. */
  80678. rightStick: StickValues;
  80679. /**
  80680. * Updates the gamepad joystick positions
  80681. */
  80682. update(): void;
  80683. /**
  80684. * Disposes the gamepad
  80685. */
  80686. dispose(): void;
  80687. }
  80688. /**
  80689. * Represents a generic gamepad
  80690. */
  80691. export class GenericPad extends Gamepad {
  80692. private _buttons;
  80693. private _onbuttondown;
  80694. private _onbuttonup;
  80695. /**
  80696. * Observable triggered when a button has been pressed
  80697. */
  80698. onButtonDownObservable: Observable<number>;
  80699. /**
  80700. * Observable triggered when a button has been released
  80701. */
  80702. onButtonUpObservable: Observable<number>;
  80703. /**
  80704. * Callback triggered when a button has been pressed
  80705. * @param callback Called when a button has been pressed
  80706. */
  80707. onbuttondown(callback: (buttonPressed: number) => void): void;
  80708. /**
  80709. * Callback triggered when a button has been released
  80710. * @param callback Called when a button has been released
  80711. */
  80712. onbuttonup(callback: (buttonReleased: number) => void): void;
  80713. /**
  80714. * Initializes the generic gamepad
  80715. * @param id The id of the generic gamepad
  80716. * @param index The index of the generic gamepad
  80717. * @param browserGamepad The browser gamepad
  80718. */
  80719. constructor(id: string, index: number, browserGamepad: any);
  80720. private _setButtonValue;
  80721. /**
  80722. * Updates the generic gamepad
  80723. */
  80724. update(): void;
  80725. /**
  80726. * Disposes the generic gamepad
  80727. */
  80728. dispose(): void;
  80729. }
  80730. }
  80731. declare module BABYLON {
  80732. interface Engine {
  80733. /**
  80734. * Creates a raw texture
  80735. * @param data defines the data to store in the texture
  80736. * @param width defines the width of the texture
  80737. * @param height defines the height of the texture
  80738. * @param format defines the format of the data
  80739. * @param generateMipMaps defines if the engine should generate the mip levels
  80740. * @param invertY defines if data must be stored with Y axis inverted
  80741. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  80742. * @param compression defines the compression used (null by default)
  80743. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80744. * @returns the raw texture inside an InternalTexture
  80745. */
  80746. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  80747. /**
  80748. * Update a raw texture
  80749. * @param texture defines the texture to update
  80750. * @param data defines the data to store in the texture
  80751. * @param format defines the format of the data
  80752. * @param invertY defines if data must be stored with Y axis inverted
  80753. */
  80754. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80755. /**
  80756. * Update a raw texture
  80757. * @param texture defines the texture to update
  80758. * @param data defines the data to store in the texture
  80759. * @param format defines the format of the data
  80760. * @param invertY defines if data must be stored with Y axis inverted
  80761. * @param compression defines the compression used (null by default)
  80762. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80763. */
  80764. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  80765. /**
  80766. * Creates a new raw cube texture
  80767. * @param data defines the array of data to use to create each face
  80768. * @param size defines the size of the textures
  80769. * @param format defines the format of the data
  80770. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80771. * @param generateMipMaps defines if the engine should generate the mip levels
  80772. * @param invertY defines if data must be stored with Y axis inverted
  80773. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80774. * @param compression defines the compression used (null by default)
  80775. * @returns the cube texture as an InternalTexture
  80776. */
  80777. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  80778. /**
  80779. * Update a raw cube texture
  80780. * @param texture defines the texture to udpdate
  80781. * @param data defines the data to store
  80782. * @param format defines the data format
  80783. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80784. * @param invertY defines if data must be stored with Y axis inverted
  80785. */
  80786. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  80787. /**
  80788. * Update a raw cube texture
  80789. * @param texture defines the texture to udpdate
  80790. * @param data defines the data to store
  80791. * @param format defines the data format
  80792. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80793. * @param invertY defines if data must be stored with Y axis inverted
  80794. * @param compression defines the compression used (null by default)
  80795. */
  80796. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  80797. /**
  80798. * Update a raw cube texture
  80799. * @param texture defines the texture to udpdate
  80800. * @param data defines the data to store
  80801. * @param format defines the data format
  80802. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80803. * @param invertY defines if data must be stored with Y axis inverted
  80804. * @param compression defines the compression used (null by default)
  80805. * @param level defines which level of the texture to update
  80806. */
  80807. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  80808. /**
  80809. * Creates a new raw cube texture from a specified url
  80810. * @param url defines the url where the data is located
  80811. * @param scene defines the current scene
  80812. * @param size defines the size of the textures
  80813. * @param format defines the format of the data
  80814. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80815. * @param noMipmap defines if the engine should avoid generating the mip levels
  80816. * @param callback defines a callback used to extract texture data from loaded data
  80817. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80818. * @param onLoad defines a callback called when texture is loaded
  80819. * @param onError defines a callback called if there is an error
  80820. * @returns the cube texture as an InternalTexture
  80821. */
  80822. 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;
  80823. /**
  80824. * Creates a new raw cube texture from a specified url
  80825. * @param url defines the url where the data is located
  80826. * @param scene defines the current scene
  80827. * @param size defines the size of the textures
  80828. * @param format defines the format of the data
  80829. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80830. * @param noMipmap defines if the engine should avoid generating the mip levels
  80831. * @param callback defines a callback used to extract texture data from loaded data
  80832. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80833. * @param onLoad defines a callback called when texture is loaded
  80834. * @param onError defines a callback called if there is an error
  80835. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80836. * @param invertY defines if data must be stored with Y axis inverted
  80837. * @returns the cube texture as an InternalTexture
  80838. */
  80839. 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;
  80840. /**
  80841. * Creates a new raw 3D texture
  80842. * @param data defines the data used to create the texture
  80843. * @param width defines the width of the texture
  80844. * @param height defines the height of the texture
  80845. * @param depth defines the depth of the texture
  80846. * @param format defines the format of the texture
  80847. * @param generateMipMaps defines if the engine must generate mip levels
  80848. * @param invertY defines if data must be stored with Y axis inverted
  80849. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80850. * @param compression defines the compressed used (can be null)
  80851. * @param textureType defines the compressed used (can be null)
  80852. * @returns a new raw 3D texture (stored in an InternalTexture)
  80853. */
  80854. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80855. /**
  80856. * Update a raw 3D texture
  80857. * @param texture defines the texture to update
  80858. * @param data defines the data to store
  80859. * @param format defines the data format
  80860. * @param invertY defines if data must be stored with Y axis inverted
  80861. */
  80862. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80863. /**
  80864. * Update a raw 3D texture
  80865. * @param texture defines the texture to update
  80866. * @param data defines the data to store
  80867. * @param format defines the data format
  80868. * @param invertY defines if data must be stored with Y axis inverted
  80869. * @param compression defines the used compression (can be null)
  80870. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80871. */
  80872. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80873. /**
  80874. * Creates a new raw 2D array texture
  80875. * @param data defines the data used to create the texture
  80876. * @param width defines the width of the texture
  80877. * @param height defines the height of the texture
  80878. * @param depth defines the number of layers of the texture
  80879. * @param format defines the format of the texture
  80880. * @param generateMipMaps defines if the engine must generate mip levels
  80881. * @param invertY defines if data must be stored with Y axis inverted
  80882. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80883. * @param compression defines the compressed used (can be null)
  80884. * @param textureType defines the compressed used (can be null)
  80885. * @returns a new raw 2D array texture (stored in an InternalTexture)
  80886. */
  80887. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80888. /**
  80889. * Update a raw 2D array texture
  80890. * @param texture defines the texture to update
  80891. * @param data defines the data to store
  80892. * @param format defines the data format
  80893. * @param invertY defines if data must be stored with Y axis inverted
  80894. */
  80895. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80896. /**
  80897. * Update a raw 2D array texture
  80898. * @param texture defines the texture to update
  80899. * @param data defines the data to store
  80900. * @param format defines the data format
  80901. * @param invertY defines if data must be stored with Y axis inverted
  80902. * @param compression defines the used compression (can be null)
  80903. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80904. */
  80905. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80906. }
  80907. }
  80908. declare module BABYLON {
  80909. /**
  80910. * Raw texture can help creating a texture directly from an array of data.
  80911. * This can be super useful if you either get the data from an uncompressed source or
  80912. * if you wish to create your texture pixel by pixel.
  80913. */
  80914. export class RawTexture extends Texture {
  80915. /**
  80916. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80917. */
  80918. format: number;
  80919. private _engine;
  80920. /**
  80921. * Instantiates a new RawTexture.
  80922. * Raw texture can help creating a texture directly from an array of data.
  80923. * This can be super useful if you either get the data from an uncompressed source or
  80924. * if you wish to create your texture pixel by pixel.
  80925. * @param data define the array of data to use to create the texture
  80926. * @param width define the width of the texture
  80927. * @param height define the height of the texture
  80928. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80929. * @param scene define the scene the texture belongs to
  80930. * @param generateMipMaps define whether mip maps should be generated or not
  80931. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80932. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80933. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80934. */
  80935. constructor(data: ArrayBufferView, width: number, height: number,
  80936. /**
  80937. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80938. */
  80939. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  80940. /**
  80941. * Updates the texture underlying data.
  80942. * @param data Define the new data of the texture
  80943. */
  80944. update(data: ArrayBufferView): void;
  80945. /**
  80946. * Creates a luminance texture from some data.
  80947. * @param data Define the texture data
  80948. * @param width Define the width of the texture
  80949. * @param height Define the height of the texture
  80950. * @param scene Define the scene the texture belongs to
  80951. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80952. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80953. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80954. * @returns the luminance texture
  80955. */
  80956. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80957. /**
  80958. * Creates a luminance alpha texture from some data.
  80959. * @param data Define the texture data
  80960. * @param width Define the width of the texture
  80961. * @param height Define the height of the texture
  80962. * @param scene Define the scene the texture belongs to
  80963. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80964. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80965. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80966. * @returns the luminance alpha texture
  80967. */
  80968. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80969. /**
  80970. * Creates an alpha texture from some data.
  80971. * @param data Define the texture data
  80972. * @param width Define the width of the texture
  80973. * @param height Define the height of the texture
  80974. * @param scene Define the scene the texture belongs to
  80975. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80976. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80977. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80978. * @returns the alpha texture
  80979. */
  80980. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80981. /**
  80982. * Creates a RGB texture from some data.
  80983. * @param data Define the texture data
  80984. * @param width Define the width of the texture
  80985. * @param height Define the height of the texture
  80986. * @param scene Define the scene the texture belongs to
  80987. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80988. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80989. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80990. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80991. * @returns the RGB alpha texture
  80992. */
  80993. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80994. /**
  80995. * Creates a RGBA texture from some data.
  80996. * @param data Define the texture data
  80997. * @param width Define the width of the texture
  80998. * @param height Define the height of the texture
  80999. * @param scene Define the scene the texture belongs to
  81000. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81001. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81002. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81003. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81004. * @returns the RGBA texture
  81005. */
  81006. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81007. /**
  81008. * Creates a R texture from some data.
  81009. * @param data Define the texture data
  81010. * @param width Define the width of the texture
  81011. * @param height Define the height of the texture
  81012. * @param scene Define the scene the texture belongs to
  81013. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81014. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81015. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81016. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81017. * @returns the R texture
  81018. */
  81019. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81020. }
  81021. }
  81022. declare module BABYLON {
  81023. /**
  81024. * Interface for the size containing width and height
  81025. */
  81026. export interface ISize {
  81027. /**
  81028. * Width
  81029. */
  81030. width: number;
  81031. /**
  81032. * Heighht
  81033. */
  81034. height: number;
  81035. }
  81036. /**
  81037. * Size containing widht and height
  81038. */
  81039. export class Size implements ISize {
  81040. /**
  81041. * Width
  81042. */
  81043. width: number;
  81044. /**
  81045. * Height
  81046. */
  81047. height: number;
  81048. /**
  81049. * Creates a Size object from the given width and height (floats).
  81050. * @param width width of the new size
  81051. * @param height height of the new size
  81052. */
  81053. constructor(width: number, height: number);
  81054. /**
  81055. * Returns a string with the Size width and height
  81056. * @returns a string with the Size width and height
  81057. */
  81058. toString(): string;
  81059. /**
  81060. * "Size"
  81061. * @returns the string "Size"
  81062. */
  81063. getClassName(): string;
  81064. /**
  81065. * Returns the Size hash code.
  81066. * @returns a hash code for a unique width and height
  81067. */
  81068. getHashCode(): number;
  81069. /**
  81070. * Updates the current size from the given one.
  81071. * @param src the given size
  81072. */
  81073. copyFrom(src: Size): void;
  81074. /**
  81075. * Updates in place the current Size from the given floats.
  81076. * @param width width of the new size
  81077. * @param height height of the new size
  81078. * @returns the updated Size.
  81079. */
  81080. copyFromFloats(width: number, height: number): Size;
  81081. /**
  81082. * Updates in place the current Size from the given floats.
  81083. * @param width width to set
  81084. * @param height height to set
  81085. * @returns the updated Size.
  81086. */
  81087. set(width: number, height: number): Size;
  81088. /**
  81089. * Multiplies the width and height by numbers
  81090. * @param w factor to multiple the width by
  81091. * @param h factor to multiple the height by
  81092. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  81093. */
  81094. multiplyByFloats(w: number, h: number): Size;
  81095. /**
  81096. * Clones the size
  81097. * @returns a new Size copied from the given one.
  81098. */
  81099. clone(): Size;
  81100. /**
  81101. * True if the current Size and the given one width and height are strictly equal.
  81102. * @param other the other size to compare against
  81103. * @returns True if the current Size and the given one width and height are strictly equal.
  81104. */
  81105. equals(other: Size): boolean;
  81106. /**
  81107. * The surface of the Size : width * height (float).
  81108. */
  81109. readonly surface: number;
  81110. /**
  81111. * Create a new size of zero
  81112. * @returns a new Size set to (0.0, 0.0)
  81113. */
  81114. static Zero(): Size;
  81115. /**
  81116. * Sums the width and height of two sizes
  81117. * @param otherSize size to add to this size
  81118. * @returns a new Size set as the addition result of the current Size and the given one.
  81119. */
  81120. add(otherSize: Size): Size;
  81121. /**
  81122. * Subtracts the width and height of two
  81123. * @param otherSize size to subtract to this size
  81124. * @returns a new Size set as the subtraction result of the given one from the current Size.
  81125. */
  81126. subtract(otherSize: Size): Size;
  81127. /**
  81128. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  81129. * @param start starting size to lerp between
  81130. * @param end end size to lerp between
  81131. * @param amount amount to lerp between the start and end values
  81132. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  81133. */
  81134. static Lerp(start: Size, end: Size, amount: number): Size;
  81135. }
  81136. }
  81137. declare module BABYLON {
  81138. /**
  81139. * Defines a runtime animation
  81140. */
  81141. export class RuntimeAnimation {
  81142. private _events;
  81143. /**
  81144. * The current frame of the runtime animation
  81145. */
  81146. private _currentFrame;
  81147. /**
  81148. * The animation used by the runtime animation
  81149. */
  81150. private _animation;
  81151. /**
  81152. * The target of the runtime animation
  81153. */
  81154. private _target;
  81155. /**
  81156. * The initiating animatable
  81157. */
  81158. private _host;
  81159. /**
  81160. * The original value of the runtime animation
  81161. */
  81162. private _originalValue;
  81163. /**
  81164. * The original blend value of the runtime animation
  81165. */
  81166. private _originalBlendValue;
  81167. /**
  81168. * The offsets cache of the runtime animation
  81169. */
  81170. private _offsetsCache;
  81171. /**
  81172. * The high limits cache of the runtime animation
  81173. */
  81174. private _highLimitsCache;
  81175. /**
  81176. * Specifies if the runtime animation has been stopped
  81177. */
  81178. private _stopped;
  81179. /**
  81180. * The blending factor of the runtime animation
  81181. */
  81182. private _blendingFactor;
  81183. /**
  81184. * The BabylonJS scene
  81185. */
  81186. private _scene;
  81187. /**
  81188. * The current value of the runtime animation
  81189. */
  81190. private _currentValue;
  81191. /** @hidden */
  81192. _animationState: _IAnimationState;
  81193. /**
  81194. * The active target of the runtime animation
  81195. */
  81196. private _activeTargets;
  81197. private _currentActiveTarget;
  81198. private _directTarget;
  81199. /**
  81200. * The target path of the runtime animation
  81201. */
  81202. private _targetPath;
  81203. /**
  81204. * The weight of the runtime animation
  81205. */
  81206. private _weight;
  81207. /**
  81208. * The ratio offset of the runtime animation
  81209. */
  81210. private _ratioOffset;
  81211. /**
  81212. * The previous delay of the runtime animation
  81213. */
  81214. private _previousDelay;
  81215. /**
  81216. * The previous ratio of the runtime animation
  81217. */
  81218. private _previousRatio;
  81219. private _enableBlending;
  81220. private _keys;
  81221. private _minFrame;
  81222. private _maxFrame;
  81223. private _minValue;
  81224. private _maxValue;
  81225. private _targetIsArray;
  81226. /**
  81227. * Gets the current frame of the runtime animation
  81228. */
  81229. readonly currentFrame: number;
  81230. /**
  81231. * Gets the weight of the runtime animation
  81232. */
  81233. readonly weight: number;
  81234. /**
  81235. * Gets the current value of the runtime animation
  81236. */
  81237. readonly currentValue: any;
  81238. /**
  81239. * Gets the target path of the runtime animation
  81240. */
  81241. readonly targetPath: string;
  81242. /**
  81243. * Gets the actual target of the runtime animation
  81244. */
  81245. readonly target: any;
  81246. /** @hidden */
  81247. _onLoop: () => void;
  81248. /**
  81249. * Create a new RuntimeAnimation object
  81250. * @param target defines the target of the animation
  81251. * @param animation defines the source animation object
  81252. * @param scene defines the hosting scene
  81253. * @param host defines the initiating Animatable
  81254. */
  81255. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  81256. private _preparePath;
  81257. /**
  81258. * Gets the animation from the runtime animation
  81259. */
  81260. readonly animation: Animation;
  81261. /**
  81262. * Resets the runtime animation to the beginning
  81263. * @param restoreOriginal defines whether to restore the target property to the original value
  81264. */
  81265. reset(restoreOriginal?: boolean): void;
  81266. /**
  81267. * Specifies if the runtime animation is stopped
  81268. * @returns Boolean specifying if the runtime animation is stopped
  81269. */
  81270. isStopped(): boolean;
  81271. /**
  81272. * Disposes of the runtime animation
  81273. */
  81274. dispose(): void;
  81275. /**
  81276. * Apply the interpolated value to the target
  81277. * @param currentValue defines the value computed by the animation
  81278. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  81279. */
  81280. setValue(currentValue: any, weight: number): void;
  81281. private _getOriginalValues;
  81282. private _setValue;
  81283. /**
  81284. * Gets the loop pmode of the runtime animation
  81285. * @returns Loop Mode
  81286. */
  81287. private _getCorrectLoopMode;
  81288. /**
  81289. * Move the current animation to a given frame
  81290. * @param frame defines the frame to move to
  81291. */
  81292. goToFrame(frame: number): void;
  81293. /**
  81294. * @hidden Internal use only
  81295. */
  81296. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  81297. /**
  81298. * Execute the current animation
  81299. * @param delay defines the delay to add to the current frame
  81300. * @param from defines the lower bound of the animation range
  81301. * @param to defines the upper bound of the animation range
  81302. * @param loop defines if the current animation must loop
  81303. * @param speedRatio defines the current speed ratio
  81304. * @param weight defines the weight of the animation (default is -1 so no weight)
  81305. * @param onLoop optional callback called when animation loops
  81306. * @returns a boolean indicating if the animation is running
  81307. */
  81308. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  81309. }
  81310. }
  81311. declare module BABYLON {
  81312. /**
  81313. * Class used to store an actual running animation
  81314. */
  81315. export class Animatable {
  81316. /** defines the target object */
  81317. target: any;
  81318. /** defines the starting frame number (default is 0) */
  81319. fromFrame: number;
  81320. /** defines the ending frame number (default is 100) */
  81321. toFrame: number;
  81322. /** defines if the animation must loop (default is false) */
  81323. loopAnimation: boolean;
  81324. /** defines a callback to call when animation ends if it is not looping */
  81325. onAnimationEnd?: (() => void) | null | undefined;
  81326. /** defines a callback to call when animation loops */
  81327. onAnimationLoop?: (() => void) | null | undefined;
  81328. private _localDelayOffset;
  81329. private _pausedDelay;
  81330. private _runtimeAnimations;
  81331. private _paused;
  81332. private _scene;
  81333. private _speedRatio;
  81334. private _weight;
  81335. private _syncRoot;
  81336. /**
  81337. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  81338. * This will only apply for non looping animation (default is true)
  81339. */
  81340. disposeOnEnd: boolean;
  81341. /**
  81342. * Gets a boolean indicating if the animation has started
  81343. */
  81344. animationStarted: boolean;
  81345. /**
  81346. * Observer raised when the animation ends
  81347. */
  81348. onAnimationEndObservable: Observable<Animatable>;
  81349. /**
  81350. * Observer raised when the animation loops
  81351. */
  81352. onAnimationLoopObservable: Observable<Animatable>;
  81353. /**
  81354. * Gets the root Animatable used to synchronize and normalize animations
  81355. */
  81356. readonly syncRoot: Nullable<Animatable>;
  81357. /**
  81358. * Gets the current frame of the first RuntimeAnimation
  81359. * Used to synchronize Animatables
  81360. */
  81361. readonly masterFrame: number;
  81362. /**
  81363. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  81364. */
  81365. weight: number;
  81366. /**
  81367. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  81368. */
  81369. speedRatio: number;
  81370. /**
  81371. * Creates a new Animatable
  81372. * @param scene defines the hosting scene
  81373. * @param target defines the target object
  81374. * @param fromFrame defines the starting frame number (default is 0)
  81375. * @param toFrame defines the ending frame number (default is 100)
  81376. * @param loopAnimation defines if the animation must loop (default is false)
  81377. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  81378. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  81379. * @param animations defines a group of animation to add to the new Animatable
  81380. * @param onAnimationLoop defines a callback to call when animation loops
  81381. */
  81382. constructor(scene: Scene,
  81383. /** defines the target object */
  81384. target: any,
  81385. /** defines the starting frame number (default is 0) */
  81386. fromFrame?: number,
  81387. /** defines the ending frame number (default is 100) */
  81388. toFrame?: number,
  81389. /** defines if the animation must loop (default is false) */
  81390. loopAnimation?: boolean, speedRatio?: number,
  81391. /** defines a callback to call when animation ends if it is not looping */
  81392. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  81393. /** defines a callback to call when animation loops */
  81394. onAnimationLoop?: (() => void) | null | undefined);
  81395. /**
  81396. * Synchronize and normalize current Animatable with a source Animatable
  81397. * This is useful when using animation weights and when animations are not of the same length
  81398. * @param root defines the root Animatable to synchronize with
  81399. * @returns the current Animatable
  81400. */
  81401. syncWith(root: Animatable): Animatable;
  81402. /**
  81403. * Gets the list of runtime animations
  81404. * @returns an array of RuntimeAnimation
  81405. */
  81406. getAnimations(): RuntimeAnimation[];
  81407. /**
  81408. * Adds more animations to the current animatable
  81409. * @param target defines the target of the animations
  81410. * @param animations defines the new animations to add
  81411. */
  81412. appendAnimations(target: any, animations: Animation[]): void;
  81413. /**
  81414. * Gets the source animation for a specific property
  81415. * @param property defines the propertyu to look for
  81416. * @returns null or the source animation for the given property
  81417. */
  81418. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  81419. /**
  81420. * Gets the runtime animation for a specific property
  81421. * @param property defines the propertyu to look for
  81422. * @returns null or the runtime animation for the given property
  81423. */
  81424. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  81425. /**
  81426. * Resets the animatable to its original state
  81427. */
  81428. reset(): void;
  81429. /**
  81430. * Allows the animatable to blend with current running animations
  81431. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81432. * @param blendingSpeed defines the blending speed to use
  81433. */
  81434. enableBlending(blendingSpeed: number): void;
  81435. /**
  81436. * Disable animation blending
  81437. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81438. */
  81439. disableBlending(): void;
  81440. /**
  81441. * Jump directly to a given frame
  81442. * @param frame defines the frame to jump to
  81443. */
  81444. goToFrame(frame: number): void;
  81445. /**
  81446. * Pause the animation
  81447. */
  81448. pause(): void;
  81449. /**
  81450. * Restart the animation
  81451. */
  81452. restart(): void;
  81453. private _raiseOnAnimationEnd;
  81454. /**
  81455. * Stop and delete the current animation
  81456. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  81457. * @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)
  81458. */
  81459. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  81460. /**
  81461. * Wait asynchronously for the animation to end
  81462. * @returns a promise which will be fullfilled when the animation ends
  81463. */
  81464. waitAsync(): Promise<Animatable>;
  81465. /** @hidden */
  81466. _animate(delay: number): boolean;
  81467. }
  81468. interface Scene {
  81469. /** @hidden */
  81470. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  81471. /** @hidden */
  81472. _processLateAnimationBindingsForMatrices(holder: {
  81473. totalWeight: number;
  81474. animations: RuntimeAnimation[];
  81475. originalValue: Matrix;
  81476. }): any;
  81477. /** @hidden */
  81478. _processLateAnimationBindingsForQuaternions(holder: {
  81479. totalWeight: number;
  81480. animations: RuntimeAnimation[];
  81481. originalValue: Quaternion;
  81482. }, refQuaternion: Quaternion): Quaternion;
  81483. /** @hidden */
  81484. _processLateAnimationBindings(): void;
  81485. /**
  81486. * Will start the animation sequence of a given target
  81487. * @param target defines the target
  81488. * @param from defines from which frame should animation start
  81489. * @param to defines until which frame should animation run.
  81490. * @param weight defines the weight to apply to the animation (1.0 by default)
  81491. * @param loop defines if the animation loops
  81492. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81493. * @param onAnimationEnd defines the function to be executed when the animation ends
  81494. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81495. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81496. * @param onAnimationLoop defines the callback to call when an animation loops
  81497. * @returns the animatable object created for this animation
  81498. */
  81499. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81500. /**
  81501. * Will start the animation sequence of a given target
  81502. * @param target defines the target
  81503. * @param from defines from which frame should animation start
  81504. * @param to defines until which frame should animation run.
  81505. * @param loop defines if the animation loops
  81506. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81507. * @param onAnimationEnd defines the function to be executed when the animation ends
  81508. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81509. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81510. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  81511. * @param onAnimationLoop defines the callback to call when an animation loops
  81512. * @returns the animatable object created for this animation
  81513. */
  81514. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81515. /**
  81516. * Will start the animation sequence of a given target and its hierarchy
  81517. * @param target defines the target
  81518. * @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.
  81519. * @param from defines from which frame should animation start
  81520. * @param to defines until which frame should animation run.
  81521. * @param loop defines if the animation loops
  81522. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81523. * @param onAnimationEnd defines the function to be executed when the animation ends
  81524. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81525. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81526. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81527. * @param onAnimationLoop defines the callback to call when an animation loops
  81528. * @returns the list of created animatables
  81529. */
  81530. 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[];
  81531. /**
  81532. * Begin a new animation on a given node
  81533. * @param target defines the target where the animation will take place
  81534. * @param animations defines the list of animations to start
  81535. * @param from defines the initial value
  81536. * @param to defines the final value
  81537. * @param loop defines if you want animation to loop (off by default)
  81538. * @param speedRatio defines the speed ratio to apply to all animations
  81539. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81540. * @param onAnimationLoop defines the callback to call when an animation loops
  81541. * @returns the list of created animatables
  81542. */
  81543. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  81544. /**
  81545. * Begin a new animation on a given node and its hierarchy
  81546. * @param target defines the root node where the animation will take place
  81547. * @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.
  81548. * @param animations defines the list of animations to start
  81549. * @param from defines the initial value
  81550. * @param to defines the final value
  81551. * @param loop defines if you want animation to loop (off by default)
  81552. * @param speedRatio defines the speed ratio to apply to all animations
  81553. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81554. * @param onAnimationLoop defines the callback to call when an animation loops
  81555. * @returns the list of animatables created for all nodes
  81556. */
  81557. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  81558. /**
  81559. * Gets the animatable associated with a specific target
  81560. * @param target defines the target of the animatable
  81561. * @returns the required animatable if found
  81562. */
  81563. getAnimatableByTarget(target: any): Nullable<Animatable>;
  81564. /**
  81565. * Gets all animatables associated with a given target
  81566. * @param target defines the target to look animatables for
  81567. * @returns an array of Animatables
  81568. */
  81569. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  81570. /**
  81571. * Stops and removes all animations that have been applied to the scene
  81572. */
  81573. stopAllAnimations(): void;
  81574. /**
  81575. * Gets the current delta time used by animation engine
  81576. */
  81577. deltaTime: number;
  81578. }
  81579. interface Bone {
  81580. /**
  81581. * Copy an animation range from another bone
  81582. * @param source defines the source bone
  81583. * @param rangeName defines the range name to copy
  81584. * @param frameOffset defines the frame offset
  81585. * @param rescaleAsRequired defines if rescaling must be applied if required
  81586. * @param skelDimensionsRatio defines the scaling ratio
  81587. * @returns true if operation was successful
  81588. */
  81589. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  81590. }
  81591. }
  81592. declare module BABYLON {
  81593. /**
  81594. * Class used to override all child animations of a given target
  81595. */
  81596. export class AnimationPropertiesOverride {
  81597. /**
  81598. * Gets or sets a value indicating if animation blending must be used
  81599. */
  81600. enableBlending: boolean;
  81601. /**
  81602. * Gets or sets the blending speed to use when enableBlending is true
  81603. */
  81604. blendingSpeed: number;
  81605. /**
  81606. * Gets or sets the default loop mode to use
  81607. */
  81608. loopMode: number;
  81609. }
  81610. }
  81611. declare module BABYLON {
  81612. /**
  81613. * Class used to handle skinning animations
  81614. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81615. */
  81616. export class Skeleton implements IAnimatable {
  81617. /** defines the skeleton name */
  81618. name: string;
  81619. /** defines the skeleton Id */
  81620. id: string;
  81621. /**
  81622. * Defines the list of child bones
  81623. */
  81624. bones: Bone[];
  81625. /**
  81626. * Defines an estimate of the dimension of the skeleton at rest
  81627. */
  81628. dimensionsAtRest: Vector3;
  81629. /**
  81630. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  81631. */
  81632. needInitialSkinMatrix: boolean;
  81633. /**
  81634. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  81635. */
  81636. overrideMesh: Nullable<AbstractMesh>;
  81637. /**
  81638. * Gets the list of animations attached to this skeleton
  81639. */
  81640. animations: Array<Animation>;
  81641. private _scene;
  81642. private _isDirty;
  81643. private _transformMatrices;
  81644. private _transformMatrixTexture;
  81645. private _meshesWithPoseMatrix;
  81646. private _animatables;
  81647. private _identity;
  81648. private _synchronizedWithMesh;
  81649. private _ranges;
  81650. private _lastAbsoluteTransformsUpdateId;
  81651. private _canUseTextureForBones;
  81652. private _uniqueId;
  81653. /** @hidden */
  81654. _numBonesWithLinkedTransformNode: number;
  81655. /** @hidden */
  81656. _hasWaitingData: Nullable<boolean>;
  81657. /**
  81658. * Specifies if the skeleton should be serialized
  81659. */
  81660. doNotSerialize: boolean;
  81661. private _useTextureToStoreBoneMatrices;
  81662. /**
  81663. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  81664. * Please note that this option is not available if the hardware does not support it
  81665. */
  81666. useTextureToStoreBoneMatrices: boolean;
  81667. private _animationPropertiesOverride;
  81668. /**
  81669. * Gets or sets the animation properties override
  81670. */
  81671. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81672. /**
  81673. * List of inspectable custom properties (used by the Inspector)
  81674. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81675. */
  81676. inspectableCustomProperties: IInspectable[];
  81677. /**
  81678. * An observable triggered before computing the skeleton's matrices
  81679. */
  81680. onBeforeComputeObservable: Observable<Skeleton>;
  81681. /**
  81682. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  81683. */
  81684. readonly isUsingTextureForMatrices: boolean;
  81685. /**
  81686. * Gets the unique ID of this skeleton
  81687. */
  81688. readonly uniqueId: number;
  81689. /**
  81690. * Creates a new skeleton
  81691. * @param name defines the skeleton name
  81692. * @param id defines the skeleton Id
  81693. * @param scene defines the hosting scene
  81694. */
  81695. constructor(
  81696. /** defines the skeleton name */
  81697. name: string,
  81698. /** defines the skeleton Id */
  81699. id: string, scene: Scene);
  81700. /**
  81701. * Gets the current object class name.
  81702. * @return the class name
  81703. */
  81704. getClassName(): string;
  81705. /**
  81706. * Returns an array containing the root bones
  81707. * @returns an array containing the root bones
  81708. */
  81709. getChildren(): Array<Bone>;
  81710. /**
  81711. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  81712. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81713. * @returns a Float32Array containing matrices data
  81714. */
  81715. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  81716. /**
  81717. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  81718. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81719. * @returns a raw texture containing the data
  81720. */
  81721. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  81722. /**
  81723. * Gets the current hosting scene
  81724. * @returns a scene object
  81725. */
  81726. getScene(): Scene;
  81727. /**
  81728. * Gets a string representing the current skeleton data
  81729. * @param fullDetails defines a boolean indicating if we want a verbose version
  81730. * @returns a string representing the current skeleton data
  81731. */
  81732. toString(fullDetails?: boolean): string;
  81733. /**
  81734. * Get bone's index searching by name
  81735. * @param name defines bone's name to search for
  81736. * @return the indice of the bone. Returns -1 if not found
  81737. */
  81738. getBoneIndexByName(name: string): number;
  81739. /**
  81740. * Creater a new animation range
  81741. * @param name defines the name of the range
  81742. * @param from defines the start key
  81743. * @param to defines the end key
  81744. */
  81745. createAnimationRange(name: string, from: number, to: number): void;
  81746. /**
  81747. * Delete a specific animation range
  81748. * @param name defines the name of the range
  81749. * @param deleteFrames defines if frames must be removed as well
  81750. */
  81751. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81752. /**
  81753. * Gets a specific animation range
  81754. * @param name defines the name of the range to look for
  81755. * @returns the requested animation range or null if not found
  81756. */
  81757. getAnimationRange(name: string): Nullable<AnimationRange>;
  81758. /**
  81759. * Gets the list of all animation ranges defined on this skeleton
  81760. * @returns an array
  81761. */
  81762. getAnimationRanges(): Nullable<AnimationRange>[];
  81763. /**
  81764. * Copy animation range from a source skeleton.
  81765. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  81766. * @param source defines the source skeleton
  81767. * @param name defines the name of the range to copy
  81768. * @param rescaleAsRequired defines if rescaling must be applied if required
  81769. * @returns true if operation was successful
  81770. */
  81771. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  81772. /**
  81773. * Forces the skeleton to go to rest pose
  81774. */
  81775. returnToRest(): void;
  81776. private _getHighestAnimationFrame;
  81777. /**
  81778. * Begin a specific animation range
  81779. * @param name defines the name of the range to start
  81780. * @param loop defines if looping must be turned on (false by default)
  81781. * @param speedRatio defines the speed ratio to apply (1 by default)
  81782. * @param onAnimationEnd defines a callback which will be called when animation will end
  81783. * @returns a new animatable
  81784. */
  81785. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81786. /** @hidden */
  81787. _markAsDirty(): void;
  81788. /** @hidden */
  81789. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81790. /** @hidden */
  81791. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81792. private _computeTransformMatrices;
  81793. /**
  81794. * Build all resources required to render a skeleton
  81795. */
  81796. prepare(): void;
  81797. /**
  81798. * Gets the list of animatables currently running for this skeleton
  81799. * @returns an array of animatables
  81800. */
  81801. getAnimatables(): IAnimatable[];
  81802. /**
  81803. * Clone the current skeleton
  81804. * @param name defines the name of the new skeleton
  81805. * @param id defines the id of the new skeleton
  81806. * @returns the new skeleton
  81807. */
  81808. clone(name: string, id?: string): Skeleton;
  81809. /**
  81810. * Enable animation blending for this skeleton
  81811. * @param blendingSpeed defines the blending speed to apply
  81812. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81813. */
  81814. enableBlending(blendingSpeed?: number): void;
  81815. /**
  81816. * Releases all resources associated with the current skeleton
  81817. */
  81818. dispose(): void;
  81819. /**
  81820. * Serialize the skeleton in a JSON object
  81821. * @returns a JSON object
  81822. */
  81823. serialize(): any;
  81824. /**
  81825. * Creates a new skeleton from serialized data
  81826. * @param parsedSkeleton defines the serialized data
  81827. * @param scene defines the hosting scene
  81828. * @returns a new skeleton
  81829. */
  81830. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  81831. /**
  81832. * Compute all node absolute transforms
  81833. * @param forceUpdate defines if computation must be done even if cache is up to date
  81834. */
  81835. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  81836. /**
  81837. * Gets the root pose matrix
  81838. * @returns a matrix
  81839. */
  81840. getPoseMatrix(): Nullable<Matrix>;
  81841. /**
  81842. * Sorts bones per internal index
  81843. */
  81844. sortBones(): void;
  81845. private _sortBones;
  81846. }
  81847. }
  81848. declare module BABYLON {
  81849. /**
  81850. * Class used to store bone information
  81851. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81852. */
  81853. export class Bone extends Node {
  81854. /**
  81855. * defines the bone name
  81856. */
  81857. name: string;
  81858. private static _tmpVecs;
  81859. private static _tmpQuat;
  81860. private static _tmpMats;
  81861. /**
  81862. * Gets the list of child bones
  81863. */
  81864. children: Bone[];
  81865. /** Gets the animations associated with this bone */
  81866. animations: Animation[];
  81867. /**
  81868. * Gets or sets bone length
  81869. */
  81870. length: number;
  81871. /**
  81872. * @hidden Internal only
  81873. * Set this value to map this bone to a different index in the transform matrices
  81874. * Set this value to -1 to exclude the bone from the transform matrices
  81875. */
  81876. _index: Nullable<number>;
  81877. private _skeleton;
  81878. private _localMatrix;
  81879. private _restPose;
  81880. private _baseMatrix;
  81881. private _absoluteTransform;
  81882. private _invertedAbsoluteTransform;
  81883. private _parent;
  81884. private _scalingDeterminant;
  81885. private _worldTransform;
  81886. private _localScaling;
  81887. private _localRotation;
  81888. private _localPosition;
  81889. private _needToDecompose;
  81890. private _needToCompose;
  81891. /** @hidden */
  81892. _linkedTransformNode: Nullable<TransformNode>;
  81893. /** @hidden */
  81894. _waitingTransformNodeId: Nullable<string>;
  81895. /** @hidden */
  81896. /** @hidden */
  81897. _matrix: Matrix;
  81898. /**
  81899. * Create a new bone
  81900. * @param name defines the bone name
  81901. * @param skeleton defines the parent skeleton
  81902. * @param parentBone defines the parent (can be null if the bone is the root)
  81903. * @param localMatrix defines the local matrix
  81904. * @param restPose defines the rest pose matrix
  81905. * @param baseMatrix defines the base matrix
  81906. * @param index defines index of the bone in the hiearchy
  81907. */
  81908. constructor(
  81909. /**
  81910. * defines the bone name
  81911. */
  81912. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  81913. /**
  81914. * Gets the current object class name.
  81915. * @return the class name
  81916. */
  81917. getClassName(): string;
  81918. /**
  81919. * Gets the parent skeleton
  81920. * @returns a skeleton
  81921. */
  81922. getSkeleton(): Skeleton;
  81923. /**
  81924. * Gets parent bone
  81925. * @returns a bone or null if the bone is the root of the bone hierarchy
  81926. */
  81927. getParent(): Nullable<Bone>;
  81928. /**
  81929. * Returns an array containing the root bones
  81930. * @returns an array containing the root bones
  81931. */
  81932. getChildren(): Array<Bone>;
  81933. /**
  81934. * Gets the node index in matrix array generated for rendering
  81935. * @returns the node index
  81936. */
  81937. getIndex(): number;
  81938. /**
  81939. * Sets the parent bone
  81940. * @param parent defines the parent (can be null if the bone is the root)
  81941. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81942. */
  81943. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  81944. /**
  81945. * Gets the local matrix
  81946. * @returns a matrix
  81947. */
  81948. getLocalMatrix(): Matrix;
  81949. /**
  81950. * Gets the base matrix (initial matrix which remains unchanged)
  81951. * @returns a matrix
  81952. */
  81953. getBaseMatrix(): Matrix;
  81954. /**
  81955. * Gets the rest pose matrix
  81956. * @returns a matrix
  81957. */
  81958. getRestPose(): Matrix;
  81959. /**
  81960. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  81961. */
  81962. getWorldMatrix(): Matrix;
  81963. /**
  81964. * Sets the local matrix to rest pose matrix
  81965. */
  81966. returnToRest(): void;
  81967. /**
  81968. * Gets the inverse of the absolute transform matrix.
  81969. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  81970. * @returns a matrix
  81971. */
  81972. getInvertedAbsoluteTransform(): Matrix;
  81973. /**
  81974. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  81975. * @returns a matrix
  81976. */
  81977. getAbsoluteTransform(): Matrix;
  81978. /**
  81979. * Links with the given transform node.
  81980. * The local matrix of this bone is copied from the transform node every frame.
  81981. * @param transformNode defines the transform node to link to
  81982. */
  81983. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  81984. /**
  81985. * Gets the node used to drive the bone's transformation
  81986. * @returns a transform node or null
  81987. */
  81988. getTransformNode(): Nullable<TransformNode>;
  81989. /** Gets or sets current position (in local space) */
  81990. position: Vector3;
  81991. /** Gets or sets current rotation (in local space) */
  81992. rotation: Vector3;
  81993. /** Gets or sets current rotation quaternion (in local space) */
  81994. rotationQuaternion: Quaternion;
  81995. /** Gets or sets current scaling (in local space) */
  81996. scaling: Vector3;
  81997. /**
  81998. * Gets the animation properties override
  81999. */
  82000. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82001. private _decompose;
  82002. private _compose;
  82003. /**
  82004. * Update the base and local matrices
  82005. * @param matrix defines the new base or local matrix
  82006. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  82007. * @param updateLocalMatrix defines if the local matrix should be updated
  82008. */
  82009. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  82010. /** @hidden */
  82011. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  82012. /**
  82013. * Flag the bone as dirty (Forcing it to update everything)
  82014. */
  82015. markAsDirty(): void;
  82016. /** @hidden */
  82017. _markAsDirtyAndCompose(): void;
  82018. private _markAsDirtyAndDecompose;
  82019. /**
  82020. * Translate the bone in local or world space
  82021. * @param vec The amount to translate the bone
  82022. * @param space The space that the translation is in
  82023. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82024. */
  82025. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82026. /**
  82027. * Set the postion of the bone in local or world space
  82028. * @param position The position to set the bone
  82029. * @param space The space that the position is in
  82030. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82031. */
  82032. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82033. /**
  82034. * Set the absolute position of the bone (world space)
  82035. * @param position The position to set the bone
  82036. * @param mesh The mesh that this bone is attached to
  82037. */
  82038. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  82039. /**
  82040. * Scale the bone on the x, y and z axes (in local space)
  82041. * @param x The amount to scale the bone on the x axis
  82042. * @param y The amount to scale the bone on the y axis
  82043. * @param z The amount to scale the bone on the z axis
  82044. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  82045. */
  82046. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  82047. /**
  82048. * Set the bone scaling in local space
  82049. * @param scale defines the scaling vector
  82050. */
  82051. setScale(scale: Vector3): void;
  82052. /**
  82053. * Gets the current scaling in local space
  82054. * @returns the current scaling vector
  82055. */
  82056. getScale(): Vector3;
  82057. /**
  82058. * Gets the current scaling in local space and stores it in a target vector
  82059. * @param result defines the target vector
  82060. */
  82061. getScaleToRef(result: Vector3): void;
  82062. /**
  82063. * Set the yaw, pitch, and roll of the bone in local or world space
  82064. * @param yaw The rotation of the bone on the y axis
  82065. * @param pitch The rotation of the bone on the x axis
  82066. * @param roll The rotation of the bone on the z axis
  82067. * @param space The space that the axes of rotation are in
  82068. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82069. */
  82070. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  82071. /**
  82072. * Add a rotation to the bone on an axis in local or world space
  82073. * @param axis The axis to rotate the bone on
  82074. * @param amount The amount to rotate the bone
  82075. * @param space The space that the axis is in
  82076. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82077. */
  82078. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  82079. /**
  82080. * Set the rotation of the bone to a particular axis angle in local or world space
  82081. * @param axis The axis to rotate the bone on
  82082. * @param angle The angle that the bone should be rotated to
  82083. * @param space The space that the axis is in
  82084. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82085. */
  82086. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  82087. /**
  82088. * Set the euler rotation of the bone in local of world space
  82089. * @param rotation The euler rotation that the bone should be set to
  82090. * @param space The space that the rotation is in
  82091. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82092. */
  82093. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82094. /**
  82095. * Set the quaternion rotation of the bone in local of world space
  82096. * @param quat The quaternion rotation that the bone should be set to
  82097. * @param space The space that the rotation is in
  82098. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82099. */
  82100. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  82101. /**
  82102. * Set the rotation matrix of the bone in local of world space
  82103. * @param rotMat The rotation matrix that the bone should be set to
  82104. * @param space The space that the rotation is in
  82105. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82106. */
  82107. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  82108. private _rotateWithMatrix;
  82109. private _getNegativeRotationToRef;
  82110. /**
  82111. * Get the position of the bone in local or world space
  82112. * @param space The space that the returned position is in
  82113. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82114. * @returns The position of the bone
  82115. */
  82116. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  82117. /**
  82118. * Copy the position of the bone to a vector3 in local or world space
  82119. * @param space The space that the returned position is in
  82120. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82121. * @param result The vector3 to copy the position to
  82122. */
  82123. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  82124. /**
  82125. * Get the absolute position of the bone (world space)
  82126. * @param mesh The mesh that this bone is attached to
  82127. * @returns The absolute position of the bone
  82128. */
  82129. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  82130. /**
  82131. * Copy the absolute position of the bone (world space) to the result param
  82132. * @param mesh The mesh that this bone is attached to
  82133. * @param result The vector3 to copy the absolute position to
  82134. */
  82135. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  82136. /**
  82137. * Compute the absolute transforms of this bone and its children
  82138. */
  82139. computeAbsoluteTransforms(): void;
  82140. /**
  82141. * Get the world direction from an axis that is in the local space of the bone
  82142. * @param localAxis The local direction that is used to compute the world direction
  82143. * @param mesh The mesh that this bone is attached to
  82144. * @returns The world direction
  82145. */
  82146. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82147. /**
  82148. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  82149. * @param localAxis The local direction that is used to compute the world direction
  82150. * @param mesh The mesh that this bone is attached to
  82151. * @param result The vector3 that the world direction will be copied to
  82152. */
  82153. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82154. /**
  82155. * Get the euler rotation of the bone in local or world space
  82156. * @param space The space that the rotation should be in
  82157. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82158. * @returns The euler rotation
  82159. */
  82160. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  82161. /**
  82162. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  82163. * @param space The space that the rotation should be in
  82164. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82165. * @param result The vector3 that the rotation should be copied to
  82166. */
  82167. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82168. /**
  82169. * Get the quaternion rotation of the bone in either local or world space
  82170. * @param space The space that the rotation should be in
  82171. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82172. * @returns The quaternion rotation
  82173. */
  82174. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  82175. /**
  82176. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  82177. * @param space The space that the rotation should be in
  82178. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82179. * @param result The quaternion that the rotation should be copied to
  82180. */
  82181. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  82182. /**
  82183. * Get the rotation matrix of the bone in local or world space
  82184. * @param space The space that the rotation should be in
  82185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82186. * @returns The rotation matrix
  82187. */
  82188. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  82189. /**
  82190. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  82191. * @param space The space that the rotation should be in
  82192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82193. * @param result The quaternion that the rotation should be copied to
  82194. */
  82195. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  82196. /**
  82197. * Get the world position of a point that is in the local space of the bone
  82198. * @param position The local position
  82199. * @param mesh The mesh that this bone is attached to
  82200. * @returns The world position
  82201. */
  82202. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82203. /**
  82204. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  82205. * @param position The local position
  82206. * @param mesh The mesh that this bone is attached to
  82207. * @param result The vector3 that the world position should be copied to
  82208. */
  82209. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82210. /**
  82211. * Get the local position of a point that is in world space
  82212. * @param position The world position
  82213. * @param mesh The mesh that this bone is attached to
  82214. * @returns The local position
  82215. */
  82216. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82217. /**
  82218. * Get the local position of a point that is in world space and copy it to the result param
  82219. * @param position The world position
  82220. * @param mesh The mesh that this bone is attached to
  82221. * @param result The vector3 that the local position should be copied to
  82222. */
  82223. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82224. }
  82225. }
  82226. declare module BABYLON {
  82227. /**
  82228. * 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.
  82229. * @see https://doc.babylonjs.com/how_to/transformnode
  82230. */
  82231. export class TransformNode extends Node {
  82232. /**
  82233. * Object will not rotate to face the camera
  82234. */
  82235. static BILLBOARDMODE_NONE: number;
  82236. /**
  82237. * Object will rotate to face the camera but only on the x axis
  82238. */
  82239. static BILLBOARDMODE_X: number;
  82240. /**
  82241. * Object will rotate to face the camera but only on the y axis
  82242. */
  82243. static BILLBOARDMODE_Y: number;
  82244. /**
  82245. * Object will rotate to face the camera but only on the z axis
  82246. */
  82247. static BILLBOARDMODE_Z: number;
  82248. /**
  82249. * Object will rotate to face the camera
  82250. */
  82251. static BILLBOARDMODE_ALL: number;
  82252. /**
  82253. * Object will rotate to face the camera's position instead of orientation
  82254. */
  82255. static BILLBOARDMODE_USE_POSITION: number;
  82256. private _forward;
  82257. private _forwardInverted;
  82258. private _up;
  82259. private _right;
  82260. private _rightInverted;
  82261. private _position;
  82262. private _rotation;
  82263. private _rotationQuaternion;
  82264. protected _scaling: Vector3;
  82265. protected _isDirty: boolean;
  82266. private _transformToBoneReferal;
  82267. private _isAbsoluteSynced;
  82268. private _billboardMode;
  82269. /**
  82270. * Gets or sets the billboard mode. Default is 0.
  82271. *
  82272. * | Value | Type | Description |
  82273. * | --- | --- | --- |
  82274. * | 0 | BILLBOARDMODE_NONE | |
  82275. * | 1 | BILLBOARDMODE_X | |
  82276. * | 2 | BILLBOARDMODE_Y | |
  82277. * | 4 | BILLBOARDMODE_Z | |
  82278. * | 7 | BILLBOARDMODE_ALL | |
  82279. *
  82280. */
  82281. billboardMode: number;
  82282. private _preserveParentRotationForBillboard;
  82283. /**
  82284. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  82285. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  82286. */
  82287. preserveParentRotationForBillboard: boolean;
  82288. /**
  82289. * 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
  82290. */
  82291. scalingDeterminant: number;
  82292. private _infiniteDistance;
  82293. /**
  82294. * Gets or sets the distance of the object to max, often used by skybox
  82295. */
  82296. infiniteDistance: boolean;
  82297. /**
  82298. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  82299. * By default the system will update normals to compensate
  82300. */
  82301. ignoreNonUniformScaling: boolean;
  82302. /**
  82303. * 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
  82304. */
  82305. reIntegrateRotationIntoRotationQuaternion: boolean;
  82306. /** @hidden */
  82307. _poseMatrix: Nullable<Matrix>;
  82308. /** @hidden */
  82309. _localMatrix: Matrix;
  82310. private _usePivotMatrix;
  82311. private _absolutePosition;
  82312. private _absoluteScaling;
  82313. private _absoluteRotationQuaternion;
  82314. private _pivotMatrix;
  82315. private _pivotMatrixInverse;
  82316. protected _postMultiplyPivotMatrix: boolean;
  82317. protected _isWorldMatrixFrozen: boolean;
  82318. /** @hidden */
  82319. _indexInSceneTransformNodesArray: number;
  82320. /**
  82321. * An event triggered after the world matrix is updated
  82322. */
  82323. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  82324. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  82325. /**
  82326. * Gets a string identifying the name of the class
  82327. * @returns "TransformNode" string
  82328. */
  82329. getClassName(): string;
  82330. /**
  82331. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  82332. */
  82333. position: Vector3;
  82334. /**
  82335. * 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)).
  82336. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  82337. */
  82338. rotation: Vector3;
  82339. /**
  82340. * 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)).
  82341. */
  82342. scaling: Vector3;
  82343. /**
  82344. * 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).
  82345. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  82346. */
  82347. rotationQuaternion: Nullable<Quaternion>;
  82348. /**
  82349. * The forward direction of that transform in world space.
  82350. */
  82351. readonly forward: Vector3;
  82352. /**
  82353. * The up direction of that transform in world space.
  82354. */
  82355. readonly up: Vector3;
  82356. /**
  82357. * The right direction of that transform in world space.
  82358. */
  82359. readonly right: Vector3;
  82360. /**
  82361. * Copies the parameter passed Matrix into the mesh Pose matrix.
  82362. * @param matrix the matrix to copy the pose from
  82363. * @returns this TransformNode.
  82364. */
  82365. updatePoseMatrix(matrix: Matrix): TransformNode;
  82366. /**
  82367. * Returns the mesh Pose matrix.
  82368. * @returns the pose matrix
  82369. */
  82370. getPoseMatrix(): Matrix;
  82371. /** @hidden */
  82372. _isSynchronized(): boolean;
  82373. /** @hidden */
  82374. _initCache(): void;
  82375. /**
  82376. * Flag the transform node as dirty (Forcing it to update everything)
  82377. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  82378. * @returns this transform node
  82379. */
  82380. markAsDirty(property: string): TransformNode;
  82381. /**
  82382. * Returns the current mesh absolute position.
  82383. * Returns a Vector3.
  82384. */
  82385. readonly absolutePosition: Vector3;
  82386. /**
  82387. * Returns the current mesh absolute scaling.
  82388. * Returns a Vector3.
  82389. */
  82390. readonly absoluteScaling: Vector3;
  82391. /**
  82392. * Returns the current mesh absolute rotation.
  82393. * Returns a Quaternion.
  82394. */
  82395. readonly absoluteRotationQuaternion: Quaternion;
  82396. /**
  82397. * Sets a new matrix to apply before all other transformation
  82398. * @param matrix defines the transform matrix
  82399. * @returns the current TransformNode
  82400. */
  82401. setPreTransformMatrix(matrix: Matrix): TransformNode;
  82402. /**
  82403. * Sets a new pivot matrix to the current node
  82404. * @param matrix defines the new pivot matrix to use
  82405. * @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
  82406. * @returns the current TransformNode
  82407. */
  82408. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  82409. /**
  82410. * Returns the mesh pivot matrix.
  82411. * Default : Identity.
  82412. * @returns the matrix
  82413. */
  82414. getPivotMatrix(): Matrix;
  82415. /**
  82416. * Instantiate (when possible) or clone that node with its hierarchy
  82417. * @param newParent defines the new parent to use for the instance (or clone)
  82418. * @param options defines options to configure how copy is done
  82419. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  82420. * @returns an instance (or a clone) of the current node with its hiearchy
  82421. */
  82422. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  82423. doNotInstantiate: boolean;
  82424. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  82425. /**
  82426. * Prevents the World matrix to be computed any longer
  82427. * @param newWorldMatrix defines an optional matrix to use as world matrix
  82428. * @returns the TransformNode.
  82429. */
  82430. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  82431. /**
  82432. * Allows back the World matrix computation.
  82433. * @returns the TransformNode.
  82434. */
  82435. unfreezeWorldMatrix(): this;
  82436. /**
  82437. * True if the World matrix has been frozen.
  82438. */
  82439. readonly isWorldMatrixFrozen: boolean;
  82440. /**
  82441. * Retuns the mesh absolute position in the World.
  82442. * @returns a Vector3.
  82443. */
  82444. getAbsolutePosition(): Vector3;
  82445. /**
  82446. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  82447. * @param absolutePosition the absolute position to set
  82448. * @returns the TransformNode.
  82449. */
  82450. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  82451. /**
  82452. * Sets the mesh position in its local space.
  82453. * @param vector3 the position to set in localspace
  82454. * @returns the TransformNode.
  82455. */
  82456. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  82457. /**
  82458. * Returns the mesh position in the local space from the current World matrix values.
  82459. * @returns a new Vector3.
  82460. */
  82461. getPositionExpressedInLocalSpace(): Vector3;
  82462. /**
  82463. * Translates the mesh along the passed Vector3 in its local space.
  82464. * @param vector3 the distance to translate in localspace
  82465. * @returns the TransformNode.
  82466. */
  82467. locallyTranslate(vector3: Vector3): TransformNode;
  82468. private static _lookAtVectorCache;
  82469. /**
  82470. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  82471. * @param targetPoint the position (must be in same space as current mesh) to look at
  82472. * @param yawCor optional yaw (y-axis) correction in radians
  82473. * @param pitchCor optional pitch (x-axis) correction in radians
  82474. * @param rollCor optional roll (z-axis) correction in radians
  82475. * @param space the choosen space of the target
  82476. * @returns the TransformNode.
  82477. */
  82478. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  82479. /**
  82480. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82481. * This Vector3 is expressed in the World space.
  82482. * @param localAxis axis to rotate
  82483. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82484. */
  82485. getDirection(localAxis: Vector3): Vector3;
  82486. /**
  82487. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  82488. * localAxis is expressed in the mesh local space.
  82489. * result is computed in the Wordl space from the mesh World matrix.
  82490. * @param localAxis axis to rotate
  82491. * @param result the resulting transformnode
  82492. * @returns this TransformNode.
  82493. */
  82494. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  82495. /**
  82496. * Sets this transform node rotation to the given local axis.
  82497. * @param localAxis the axis in local space
  82498. * @param yawCor optional yaw (y-axis) correction in radians
  82499. * @param pitchCor optional pitch (x-axis) correction in radians
  82500. * @param rollCor optional roll (z-axis) correction in radians
  82501. * @returns this TransformNode
  82502. */
  82503. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  82504. /**
  82505. * Sets a new pivot point to the current node
  82506. * @param point defines the new pivot point to use
  82507. * @param space defines if the point is in world or local space (local by default)
  82508. * @returns the current TransformNode
  82509. */
  82510. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  82511. /**
  82512. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  82513. * @returns the pivot point
  82514. */
  82515. getPivotPoint(): Vector3;
  82516. /**
  82517. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  82518. * @param result the vector3 to store the result
  82519. * @returns this TransformNode.
  82520. */
  82521. getPivotPointToRef(result: Vector3): TransformNode;
  82522. /**
  82523. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  82524. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  82525. */
  82526. getAbsolutePivotPoint(): Vector3;
  82527. /**
  82528. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  82529. * @param result vector3 to store the result
  82530. * @returns this TransformNode.
  82531. */
  82532. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  82533. /**
  82534. * Defines the passed node as the parent of the current node.
  82535. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  82536. * @see https://doc.babylonjs.com/how_to/parenting
  82537. * @param node the node ot set as the parent
  82538. * @returns this TransformNode.
  82539. */
  82540. setParent(node: Nullable<Node>): TransformNode;
  82541. private _nonUniformScaling;
  82542. /**
  82543. * True if the scaling property of this object is non uniform eg. (1,2,1)
  82544. */
  82545. readonly nonUniformScaling: boolean;
  82546. /** @hidden */
  82547. _updateNonUniformScalingState(value: boolean): boolean;
  82548. /**
  82549. * Attach the current TransformNode to another TransformNode associated with a bone
  82550. * @param bone Bone affecting the TransformNode
  82551. * @param affectedTransformNode TransformNode associated with the bone
  82552. * @returns this object
  82553. */
  82554. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  82555. /**
  82556. * Detach the transform node if its associated with a bone
  82557. * @returns this object
  82558. */
  82559. detachFromBone(): TransformNode;
  82560. private static _rotationAxisCache;
  82561. /**
  82562. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  82563. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82564. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82565. * The passed axis is also normalized.
  82566. * @param axis the axis to rotate around
  82567. * @param amount the amount to rotate in radians
  82568. * @param space Space to rotate in (Default: local)
  82569. * @returns the TransformNode.
  82570. */
  82571. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  82572. /**
  82573. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  82574. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82575. * The passed axis is also normalized. .
  82576. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  82577. * @param point the point to rotate around
  82578. * @param axis the axis to rotate around
  82579. * @param amount the amount to rotate in radians
  82580. * @returns the TransformNode
  82581. */
  82582. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  82583. /**
  82584. * Translates the mesh along the axis vector for the passed distance in the given space.
  82585. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82586. * @param axis the axis to translate in
  82587. * @param distance the distance to translate
  82588. * @param space Space to rotate in (Default: local)
  82589. * @returns the TransformNode.
  82590. */
  82591. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  82592. /**
  82593. * Adds a rotation step to the mesh current rotation.
  82594. * x, y, z are Euler angles expressed in radians.
  82595. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  82596. * This means this rotation is made in the mesh local space only.
  82597. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  82598. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  82599. * ```javascript
  82600. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  82601. * ```
  82602. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  82603. * 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.
  82604. * @param x Rotation to add
  82605. * @param y Rotation to add
  82606. * @param z Rotation to add
  82607. * @returns the TransformNode.
  82608. */
  82609. addRotation(x: number, y: number, z: number): TransformNode;
  82610. /**
  82611. * @hidden
  82612. */
  82613. protected _getEffectiveParent(): Nullable<Node>;
  82614. /**
  82615. * Computes the world matrix of the node
  82616. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82617. * @returns the world matrix
  82618. */
  82619. computeWorldMatrix(force?: boolean): Matrix;
  82620. protected _afterComputeWorldMatrix(): void;
  82621. /**
  82622. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  82623. * @param func callback function to add
  82624. *
  82625. * @returns the TransformNode.
  82626. */
  82627. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82628. /**
  82629. * Removes a registered callback function.
  82630. * @param func callback function to remove
  82631. * @returns the TransformNode.
  82632. */
  82633. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82634. /**
  82635. * Gets the position of the current mesh in camera space
  82636. * @param camera defines the camera to use
  82637. * @returns a position
  82638. */
  82639. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  82640. /**
  82641. * Returns the distance from the mesh to the active camera
  82642. * @param camera defines the camera to use
  82643. * @returns the distance
  82644. */
  82645. getDistanceToCamera(camera?: Nullable<Camera>): number;
  82646. /**
  82647. * Clone the current transform node
  82648. * @param name Name of the new clone
  82649. * @param newParent New parent for the clone
  82650. * @param doNotCloneChildren Do not clone children hierarchy
  82651. * @returns the new transform node
  82652. */
  82653. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  82654. /**
  82655. * Serializes the objects information.
  82656. * @param currentSerializationObject defines the object to serialize in
  82657. * @returns the serialized object
  82658. */
  82659. serialize(currentSerializationObject?: any): any;
  82660. /**
  82661. * Returns a new TransformNode object parsed from the source provided.
  82662. * @param parsedTransformNode is the source.
  82663. * @param scene the scne the object belongs to
  82664. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  82665. * @returns a new TransformNode object parsed from the source provided.
  82666. */
  82667. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  82668. /**
  82669. * Get all child-transformNodes of this node
  82670. * @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
  82671. * @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
  82672. * @returns an array of TransformNode
  82673. */
  82674. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  82675. /**
  82676. * Releases resources associated with this transform node.
  82677. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82678. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82679. */
  82680. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82681. /**
  82682. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82683. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  82684. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  82685. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  82686. * @returns the current mesh
  82687. */
  82688. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  82689. private _syncAbsoluteScalingAndRotation;
  82690. }
  82691. }
  82692. declare module BABYLON {
  82693. /**
  82694. * Defines the types of pose enabled controllers that are supported
  82695. */
  82696. export enum PoseEnabledControllerType {
  82697. /**
  82698. * HTC Vive
  82699. */
  82700. VIVE = 0,
  82701. /**
  82702. * Oculus Rift
  82703. */
  82704. OCULUS = 1,
  82705. /**
  82706. * Windows mixed reality
  82707. */
  82708. WINDOWS = 2,
  82709. /**
  82710. * Samsung gear VR
  82711. */
  82712. GEAR_VR = 3,
  82713. /**
  82714. * Google Daydream
  82715. */
  82716. DAYDREAM = 4,
  82717. /**
  82718. * Generic
  82719. */
  82720. GENERIC = 5
  82721. }
  82722. /**
  82723. * Defines the MutableGamepadButton interface for the state of a gamepad button
  82724. */
  82725. export interface MutableGamepadButton {
  82726. /**
  82727. * Value of the button/trigger
  82728. */
  82729. value: number;
  82730. /**
  82731. * If the button/trigger is currently touched
  82732. */
  82733. touched: boolean;
  82734. /**
  82735. * If the button/trigger is currently pressed
  82736. */
  82737. pressed: boolean;
  82738. }
  82739. /**
  82740. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  82741. * @hidden
  82742. */
  82743. export interface ExtendedGamepadButton extends GamepadButton {
  82744. /**
  82745. * If the button/trigger is currently pressed
  82746. */
  82747. readonly pressed: boolean;
  82748. /**
  82749. * If the button/trigger is currently touched
  82750. */
  82751. readonly touched: boolean;
  82752. /**
  82753. * Value of the button/trigger
  82754. */
  82755. readonly value: number;
  82756. }
  82757. /** @hidden */
  82758. export interface _GamePadFactory {
  82759. /**
  82760. * Returns wether or not the current gamepad can be created for this type of controller.
  82761. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82762. * @returns true if it can be created, otherwise false
  82763. */
  82764. canCreate(gamepadInfo: any): boolean;
  82765. /**
  82766. * Creates a new instance of the Gamepad.
  82767. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82768. * @returns the new gamepad instance
  82769. */
  82770. create(gamepadInfo: any): Gamepad;
  82771. }
  82772. /**
  82773. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82774. */
  82775. export class PoseEnabledControllerHelper {
  82776. /** @hidden */
  82777. static _ControllerFactories: _GamePadFactory[];
  82778. /** @hidden */
  82779. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  82780. /**
  82781. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82782. * @param vrGamepad the gamepad to initialized
  82783. * @returns a vr controller of the type the gamepad identified as
  82784. */
  82785. static InitiateController(vrGamepad: any): Gamepad;
  82786. }
  82787. /**
  82788. * Defines the PoseEnabledController object that contains state of a vr capable controller
  82789. */
  82790. export class PoseEnabledController extends Gamepad implements PoseControlled {
  82791. /**
  82792. * If the controller is used in a webXR session
  82793. */
  82794. isXR: boolean;
  82795. private _deviceRoomPosition;
  82796. private _deviceRoomRotationQuaternion;
  82797. /**
  82798. * The device position in babylon space
  82799. */
  82800. devicePosition: Vector3;
  82801. /**
  82802. * The device rotation in babylon space
  82803. */
  82804. deviceRotationQuaternion: Quaternion;
  82805. /**
  82806. * The scale factor of the device in babylon space
  82807. */
  82808. deviceScaleFactor: number;
  82809. /**
  82810. * (Likely devicePosition should be used instead) The device position in its room space
  82811. */
  82812. position: Vector3;
  82813. /**
  82814. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  82815. */
  82816. rotationQuaternion: Quaternion;
  82817. /**
  82818. * The type of controller (Eg. Windows mixed reality)
  82819. */
  82820. controllerType: PoseEnabledControllerType;
  82821. protected _calculatedPosition: Vector3;
  82822. private _calculatedRotation;
  82823. /**
  82824. * The raw pose from the device
  82825. */
  82826. rawPose: DevicePose;
  82827. private _trackPosition;
  82828. private _maxRotationDistFromHeadset;
  82829. private _draggedRoomRotation;
  82830. /**
  82831. * @hidden
  82832. */
  82833. _disableTrackPosition(fixedPosition: Vector3): void;
  82834. /**
  82835. * Internal, the mesh attached to the controller
  82836. * @hidden
  82837. */
  82838. _mesh: Nullable<AbstractMesh>;
  82839. private _poseControlledCamera;
  82840. private _leftHandSystemQuaternion;
  82841. /**
  82842. * Internal, matrix used to convert room space to babylon space
  82843. * @hidden
  82844. */
  82845. _deviceToWorld: Matrix;
  82846. /**
  82847. * Node to be used when casting a ray from the controller
  82848. * @hidden
  82849. */
  82850. _pointingPoseNode: Nullable<TransformNode>;
  82851. /**
  82852. * Name of the child mesh that can be used to cast a ray from the controller
  82853. */
  82854. static readonly POINTING_POSE: string;
  82855. /**
  82856. * Creates a new PoseEnabledController from a gamepad
  82857. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  82858. */
  82859. constructor(browserGamepad: any);
  82860. private _workingMatrix;
  82861. /**
  82862. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  82863. */
  82864. update(): void;
  82865. /**
  82866. * Updates only the pose device and mesh without doing any button event checking
  82867. */
  82868. protected _updatePoseAndMesh(): void;
  82869. /**
  82870. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  82871. * @param poseData raw pose fromthe device
  82872. */
  82873. updateFromDevice(poseData: DevicePose): void;
  82874. /**
  82875. * @hidden
  82876. */
  82877. _meshAttachedObservable: Observable<AbstractMesh>;
  82878. /**
  82879. * Attaches a mesh to the controller
  82880. * @param mesh the mesh to be attached
  82881. */
  82882. attachToMesh(mesh: AbstractMesh): void;
  82883. /**
  82884. * Attaches the controllers mesh to a camera
  82885. * @param camera the camera the mesh should be attached to
  82886. */
  82887. attachToPoseControlledCamera(camera: TargetCamera): void;
  82888. /**
  82889. * Disposes of the controller
  82890. */
  82891. dispose(): void;
  82892. /**
  82893. * The mesh that is attached to the controller
  82894. */
  82895. readonly mesh: Nullable<AbstractMesh>;
  82896. /**
  82897. * Gets the ray of the controller in the direction the controller is pointing
  82898. * @param length the length the resulting ray should be
  82899. * @returns a ray in the direction the controller is pointing
  82900. */
  82901. getForwardRay(length?: number): Ray;
  82902. }
  82903. }
  82904. declare module BABYLON {
  82905. /**
  82906. * Defines the WebVRController object that represents controllers tracked in 3D space
  82907. */
  82908. export abstract class WebVRController extends PoseEnabledController {
  82909. /**
  82910. * Internal, the default controller model for the controller
  82911. */
  82912. protected _defaultModel: Nullable<AbstractMesh>;
  82913. /**
  82914. * Fired when the trigger state has changed
  82915. */
  82916. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  82917. /**
  82918. * Fired when the main button state has changed
  82919. */
  82920. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82921. /**
  82922. * Fired when the secondary button state has changed
  82923. */
  82924. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82925. /**
  82926. * Fired when the pad state has changed
  82927. */
  82928. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  82929. /**
  82930. * Fired when controllers stick values have changed
  82931. */
  82932. onPadValuesChangedObservable: Observable<StickValues>;
  82933. /**
  82934. * Array of button availible on the controller
  82935. */
  82936. protected _buttons: Array<MutableGamepadButton>;
  82937. private _onButtonStateChange;
  82938. /**
  82939. * Fired when a controller button's state has changed
  82940. * @param callback the callback containing the button that was modified
  82941. */
  82942. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  82943. /**
  82944. * X and Y axis corresponding to the controllers joystick
  82945. */
  82946. pad: StickValues;
  82947. /**
  82948. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  82949. */
  82950. hand: string;
  82951. /**
  82952. * The default controller model for the controller
  82953. */
  82954. readonly defaultModel: Nullable<AbstractMesh>;
  82955. /**
  82956. * Creates a new WebVRController from a gamepad
  82957. * @param vrGamepad the gamepad that the WebVRController should be created from
  82958. */
  82959. constructor(vrGamepad: any);
  82960. /**
  82961. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  82962. */
  82963. update(): void;
  82964. /**
  82965. * Function to be called when a button is modified
  82966. */
  82967. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  82968. /**
  82969. * Loads a mesh and attaches it to the controller
  82970. * @param scene the scene the mesh should be added to
  82971. * @param meshLoaded callback for when the mesh has been loaded
  82972. */
  82973. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  82974. private _setButtonValue;
  82975. private _changes;
  82976. private _checkChanges;
  82977. /**
  82978. * Disposes of th webVRCOntroller
  82979. */
  82980. dispose(): void;
  82981. }
  82982. }
  82983. declare module BABYLON {
  82984. /**
  82985. * The HemisphericLight simulates the ambient environment light,
  82986. * so the passed direction is the light reflection direction, not the incoming direction.
  82987. */
  82988. export class HemisphericLight extends Light {
  82989. /**
  82990. * The groundColor is the light in the opposite direction to the one specified during creation.
  82991. * 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.
  82992. */
  82993. groundColor: Color3;
  82994. /**
  82995. * The light reflection direction, not the incoming direction.
  82996. */
  82997. direction: Vector3;
  82998. /**
  82999. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  83000. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  83001. * The HemisphericLight can't cast shadows.
  83002. * Documentation : https://doc.babylonjs.com/babylon101/lights
  83003. * @param name The friendly name of the light
  83004. * @param direction The direction of the light reflection
  83005. * @param scene The scene the light belongs to
  83006. */
  83007. constructor(name: string, direction: Vector3, scene: Scene);
  83008. protected _buildUniformLayout(): void;
  83009. /**
  83010. * Returns the string "HemisphericLight".
  83011. * @return The class name
  83012. */
  83013. getClassName(): string;
  83014. /**
  83015. * Sets the HemisphericLight direction towards the passed target (Vector3).
  83016. * Returns the updated direction.
  83017. * @param target The target the direction should point to
  83018. * @return The computed direction
  83019. */
  83020. setDirectionToTarget(target: Vector3): Vector3;
  83021. /**
  83022. * Returns the shadow generator associated to the light.
  83023. * @returns Always null for hemispheric lights because it does not support shadows.
  83024. */
  83025. getShadowGenerator(): Nullable<IShadowGenerator>;
  83026. /**
  83027. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  83028. * @param effect The effect to update
  83029. * @param lightIndex The index of the light in the effect to update
  83030. * @returns The hemispheric light
  83031. */
  83032. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  83033. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  83034. /**
  83035. * Computes the world matrix of the node
  83036. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83037. * @param useWasUpdatedFlag defines a reserved property
  83038. * @returns the world matrix
  83039. */
  83040. computeWorldMatrix(): Matrix;
  83041. /**
  83042. * Returns the integer 3.
  83043. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  83044. */
  83045. getTypeID(): number;
  83046. /**
  83047. * Prepares the list of defines specific to the light type.
  83048. * @param defines the list of defines
  83049. * @param lightIndex defines the index of the light for the effect
  83050. */
  83051. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  83052. }
  83053. }
  83054. declare module BABYLON {
  83055. /** @hidden */
  83056. export var vrMultiviewToSingleviewPixelShader: {
  83057. name: string;
  83058. shader: string;
  83059. };
  83060. }
  83061. declare module BABYLON {
  83062. /**
  83063. * Renders to multiple views with a single draw call
  83064. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  83065. */
  83066. export class MultiviewRenderTarget extends RenderTargetTexture {
  83067. /**
  83068. * Creates a multiview render target
  83069. * @param scene scene used with the render target
  83070. * @param size the size of the render target (used for each view)
  83071. */
  83072. constructor(scene: Scene, size?: number | {
  83073. width: number;
  83074. height: number;
  83075. } | {
  83076. ratio: number;
  83077. });
  83078. /**
  83079. * @hidden
  83080. * @param faceIndex the face index, if its a cube texture
  83081. */
  83082. _bindFrameBuffer(faceIndex?: number): void;
  83083. /**
  83084. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  83085. * @returns the view count
  83086. */
  83087. getViewCount(): number;
  83088. }
  83089. }
  83090. declare module BABYLON {
  83091. /**
  83092. * Represents a camera frustum
  83093. */
  83094. export class Frustum {
  83095. /**
  83096. * Gets the planes representing the frustum
  83097. * @param transform matrix to be applied to the returned planes
  83098. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  83099. */
  83100. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  83101. /**
  83102. * Gets the near frustum plane transformed by the transform matrix
  83103. * @param transform transformation matrix to be applied to the resulting frustum plane
  83104. * @param frustumPlane the resuling frustum plane
  83105. */
  83106. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83107. /**
  83108. * Gets the far frustum plane transformed by the transform matrix
  83109. * @param transform transformation matrix to be applied to the resulting frustum plane
  83110. * @param frustumPlane the resuling frustum plane
  83111. */
  83112. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83113. /**
  83114. * Gets the left frustum plane transformed by the transform matrix
  83115. * @param transform transformation matrix to be applied to the resulting frustum plane
  83116. * @param frustumPlane the resuling frustum plane
  83117. */
  83118. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83119. /**
  83120. * Gets the right frustum plane transformed by the transform matrix
  83121. * @param transform transformation matrix to be applied to the resulting frustum plane
  83122. * @param frustumPlane the resuling frustum plane
  83123. */
  83124. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83125. /**
  83126. * Gets the top frustum plane transformed by the transform matrix
  83127. * @param transform transformation matrix to be applied to the resulting frustum plane
  83128. * @param frustumPlane the resuling frustum plane
  83129. */
  83130. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83131. /**
  83132. * Gets the bottom frustum plane transformed by the transform matrix
  83133. * @param transform transformation matrix to be applied to the resulting frustum plane
  83134. * @param frustumPlane the resuling frustum plane
  83135. */
  83136. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83137. /**
  83138. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  83139. * @param transform transformation matrix to be applied to the resulting frustum planes
  83140. * @param frustumPlanes the resuling frustum planes
  83141. */
  83142. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  83143. }
  83144. }
  83145. declare module BABYLON {
  83146. interface Engine {
  83147. /**
  83148. * Creates a new multiview render target
  83149. * @param width defines the width of the texture
  83150. * @param height defines the height of the texture
  83151. * @returns the created multiview texture
  83152. */
  83153. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  83154. /**
  83155. * Binds a multiview framebuffer to be drawn to
  83156. * @param multiviewTexture texture to bind
  83157. */
  83158. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  83159. }
  83160. interface Camera {
  83161. /**
  83162. * @hidden
  83163. * 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)
  83164. */
  83165. _useMultiviewToSingleView: boolean;
  83166. /**
  83167. * @hidden
  83168. * 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)
  83169. */
  83170. _multiviewTexture: Nullable<RenderTargetTexture>;
  83171. /**
  83172. * @hidden
  83173. * ensures the multiview texture of the camera exists and has the specified width/height
  83174. * @param width height to set on the multiview texture
  83175. * @param height width to set on the multiview texture
  83176. */
  83177. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  83178. }
  83179. interface Scene {
  83180. /** @hidden */
  83181. _transformMatrixR: Matrix;
  83182. /** @hidden */
  83183. _multiviewSceneUbo: Nullable<UniformBuffer>;
  83184. /** @hidden */
  83185. _createMultiviewUbo(): void;
  83186. /** @hidden */
  83187. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  83188. /** @hidden */
  83189. _renderMultiviewToSingleView(camera: Camera): void;
  83190. }
  83191. }
  83192. declare module BABYLON {
  83193. /**
  83194. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  83195. * This will not be used for webXR as it supports displaying texture arrays directly
  83196. */
  83197. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  83198. /**
  83199. * Initializes a VRMultiviewToSingleview
  83200. * @param name name of the post process
  83201. * @param camera camera to be applied to
  83202. * @param scaleFactor scaling factor to the size of the output texture
  83203. */
  83204. constructor(name: string, camera: Camera, scaleFactor: number);
  83205. }
  83206. }
  83207. declare module BABYLON {
  83208. /**
  83209. * Interface used to define additional presentation attributes
  83210. */
  83211. export interface IVRPresentationAttributes {
  83212. /**
  83213. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  83214. */
  83215. highRefreshRate: boolean;
  83216. /**
  83217. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  83218. */
  83219. foveationLevel: number;
  83220. }
  83221. interface Engine {
  83222. /** @hidden */
  83223. _vrDisplay: any;
  83224. /** @hidden */
  83225. _vrSupported: boolean;
  83226. /** @hidden */
  83227. _oldSize: Size;
  83228. /** @hidden */
  83229. _oldHardwareScaleFactor: number;
  83230. /** @hidden */
  83231. _vrExclusivePointerMode: boolean;
  83232. /** @hidden */
  83233. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  83234. /** @hidden */
  83235. _onVRDisplayPointerRestricted: () => void;
  83236. /** @hidden */
  83237. _onVRDisplayPointerUnrestricted: () => void;
  83238. /** @hidden */
  83239. _onVrDisplayConnect: Nullable<(display: any) => void>;
  83240. /** @hidden */
  83241. _onVrDisplayDisconnect: Nullable<() => void>;
  83242. /** @hidden */
  83243. _onVrDisplayPresentChange: Nullable<() => void>;
  83244. /**
  83245. * Observable signaled when VR display mode changes
  83246. */
  83247. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  83248. /**
  83249. * Observable signaled when VR request present is complete
  83250. */
  83251. onVRRequestPresentComplete: Observable<boolean>;
  83252. /**
  83253. * Observable signaled when VR request present starts
  83254. */
  83255. onVRRequestPresentStart: Observable<Engine>;
  83256. /**
  83257. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  83258. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  83259. */
  83260. isInVRExclusivePointerMode: boolean;
  83261. /**
  83262. * Gets a boolean indicating if a webVR device was detected
  83263. * @returns true if a webVR device was detected
  83264. */
  83265. isVRDevicePresent(): boolean;
  83266. /**
  83267. * Gets the current webVR device
  83268. * @returns the current webVR device (or null)
  83269. */
  83270. getVRDevice(): any;
  83271. /**
  83272. * Initializes a webVR display and starts listening to display change events
  83273. * The onVRDisplayChangedObservable will be notified upon these changes
  83274. * @returns A promise containing a VRDisplay and if vr is supported
  83275. */
  83276. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  83277. /** @hidden */
  83278. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  83279. /**
  83280. * Gets or sets the presentation attributes used to configure VR rendering
  83281. */
  83282. vrPresentationAttributes?: IVRPresentationAttributes;
  83283. /**
  83284. * Call this function to switch to webVR mode
  83285. * Will do nothing if webVR is not supported or if there is no webVR device
  83286. * @param options the webvr options provided to the camera. mainly used for multiview
  83287. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83288. */
  83289. enableVR(options: WebVROptions): void;
  83290. /** @hidden */
  83291. _onVRFullScreenTriggered(): void;
  83292. }
  83293. }
  83294. declare module BABYLON {
  83295. /**
  83296. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  83297. * IMPORTANT!! The data is right-hand data.
  83298. * @export
  83299. * @interface DevicePose
  83300. */
  83301. export interface DevicePose {
  83302. /**
  83303. * The position of the device, values in array are [x,y,z].
  83304. */
  83305. readonly position: Nullable<Float32Array>;
  83306. /**
  83307. * The linearVelocity of the device, values in array are [x,y,z].
  83308. */
  83309. readonly linearVelocity: Nullable<Float32Array>;
  83310. /**
  83311. * The linearAcceleration of the device, values in array are [x,y,z].
  83312. */
  83313. readonly linearAcceleration: Nullable<Float32Array>;
  83314. /**
  83315. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  83316. */
  83317. readonly orientation: Nullable<Float32Array>;
  83318. /**
  83319. * The angularVelocity of the device, values in array are [x,y,z].
  83320. */
  83321. readonly angularVelocity: Nullable<Float32Array>;
  83322. /**
  83323. * The angularAcceleration of the device, values in array are [x,y,z].
  83324. */
  83325. readonly angularAcceleration: Nullable<Float32Array>;
  83326. }
  83327. /**
  83328. * Interface representing a pose controlled object in Babylon.
  83329. * A pose controlled object has both regular pose values as well as pose values
  83330. * from an external device such as a VR head mounted display
  83331. */
  83332. export interface PoseControlled {
  83333. /**
  83334. * The position of the object in babylon space.
  83335. */
  83336. position: Vector3;
  83337. /**
  83338. * The rotation quaternion of the object in babylon space.
  83339. */
  83340. rotationQuaternion: Quaternion;
  83341. /**
  83342. * The position of the device in babylon space.
  83343. */
  83344. devicePosition?: Vector3;
  83345. /**
  83346. * The rotation quaternion of the device in babylon space.
  83347. */
  83348. deviceRotationQuaternion: Quaternion;
  83349. /**
  83350. * The raw pose coming from the device.
  83351. */
  83352. rawPose: Nullable<DevicePose>;
  83353. /**
  83354. * The scale of the device to be used when translating from device space to babylon space.
  83355. */
  83356. deviceScaleFactor: number;
  83357. /**
  83358. * Updates the poseControlled values based on the input device pose.
  83359. * @param poseData the pose data to update the object with
  83360. */
  83361. updateFromDevice(poseData: DevicePose): void;
  83362. }
  83363. /**
  83364. * Set of options to customize the webVRCamera
  83365. */
  83366. export interface WebVROptions {
  83367. /**
  83368. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  83369. */
  83370. trackPosition?: boolean;
  83371. /**
  83372. * Sets the scale of the vrDevice in babylon space. (default: 1)
  83373. */
  83374. positionScale?: number;
  83375. /**
  83376. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  83377. */
  83378. displayName?: string;
  83379. /**
  83380. * Should the native controller meshes be initialized. (default: true)
  83381. */
  83382. controllerMeshes?: boolean;
  83383. /**
  83384. * Creating a default HemiLight only on controllers. (default: true)
  83385. */
  83386. defaultLightingOnControllers?: boolean;
  83387. /**
  83388. * If you don't want to use the default VR button of the helper. (default: false)
  83389. */
  83390. useCustomVRButton?: boolean;
  83391. /**
  83392. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  83393. */
  83394. customVRButton?: HTMLButtonElement;
  83395. /**
  83396. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  83397. */
  83398. rayLength?: number;
  83399. /**
  83400. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  83401. */
  83402. defaultHeight?: number;
  83403. /**
  83404. * If multiview should be used if availible (default: false)
  83405. */
  83406. useMultiview?: boolean;
  83407. }
  83408. /**
  83409. * This represents a WebVR camera.
  83410. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  83411. * @example http://doc.babylonjs.com/how_to/webvr_camera
  83412. */
  83413. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  83414. private webVROptions;
  83415. /**
  83416. * @hidden
  83417. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  83418. */
  83419. _vrDevice: any;
  83420. /**
  83421. * The rawPose of the vrDevice.
  83422. */
  83423. rawPose: Nullable<DevicePose>;
  83424. private _onVREnabled;
  83425. private _specsVersion;
  83426. private _attached;
  83427. private _frameData;
  83428. protected _descendants: Array<Node>;
  83429. private _deviceRoomPosition;
  83430. /** @hidden */
  83431. _deviceRoomRotationQuaternion: Quaternion;
  83432. private _standingMatrix;
  83433. /**
  83434. * Represents device position in babylon space.
  83435. */
  83436. devicePosition: Vector3;
  83437. /**
  83438. * Represents device rotation in babylon space.
  83439. */
  83440. deviceRotationQuaternion: Quaternion;
  83441. /**
  83442. * The scale of the device to be used when translating from device space to babylon space.
  83443. */
  83444. deviceScaleFactor: number;
  83445. private _deviceToWorld;
  83446. private _worldToDevice;
  83447. /**
  83448. * References to the webVR controllers for the vrDevice.
  83449. */
  83450. controllers: Array<WebVRController>;
  83451. /**
  83452. * Emits an event when a controller is attached.
  83453. */
  83454. onControllersAttachedObservable: Observable<WebVRController[]>;
  83455. /**
  83456. * Emits an event when a controller's mesh has been loaded;
  83457. */
  83458. onControllerMeshLoadedObservable: Observable<WebVRController>;
  83459. /**
  83460. * Emits an event when the HMD's pose has been updated.
  83461. */
  83462. onPoseUpdatedFromDeviceObservable: Observable<any>;
  83463. private _poseSet;
  83464. /**
  83465. * If the rig cameras be used as parent instead of this camera.
  83466. */
  83467. rigParenting: boolean;
  83468. private _lightOnControllers;
  83469. private _defaultHeight?;
  83470. /**
  83471. * Instantiates a WebVRFreeCamera.
  83472. * @param name The name of the WebVRFreeCamera
  83473. * @param position The starting anchor position for the camera
  83474. * @param scene The scene the camera belongs to
  83475. * @param webVROptions a set of customizable options for the webVRCamera
  83476. */
  83477. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  83478. /**
  83479. * Gets the device distance from the ground in meters.
  83480. * @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.
  83481. */
  83482. deviceDistanceToRoomGround(): number;
  83483. /**
  83484. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83485. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  83486. */
  83487. useStandingMatrix(callback?: (bool: boolean) => void): void;
  83488. /**
  83489. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83490. * @returns A promise with a boolean set to if the standing matrix is supported.
  83491. */
  83492. useStandingMatrixAsync(): Promise<boolean>;
  83493. /**
  83494. * Disposes the camera
  83495. */
  83496. dispose(): void;
  83497. /**
  83498. * Gets a vrController by name.
  83499. * @param name The name of the controller to retreive
  83500. * @returns the controller matching the name specified or null if not found
  83501. */
  83502. getControllerByName(name: string): Nullable<WebVRController>;
  83503. private _leftController;
  83504. /**
  83505. * The controller corresponding to the users left hand.
  83506. */
  83507. readonly leftController: Nullable<WebVRController>;
  83508. private _rightController;
  83509. /**
  83510. * The controller corresponding to the users right hand.
  83511. */
  83512. readonly rightController: Nullable<WebVRController>;
  83513. /**
  83514. * Casts a ray forward from the vrCamera's gaze.
  83515. * @param length Length of the ray (default: 100)
  83516. * @returns the ray corresponding to the gaze
  83517. */
  83518. getForwardRay(length?: number): Ray;
  83519. /**
  83520. * @hidden
  83521. * Updates the camera based on device's frame data
  83522. */
  83523. _checkInputs(): void;
  83524. /**
  83525. * Updates the poseControlled values based on the input device pose.
  83526. * @param poseData Pose coming from the device
  83527. */
  83528. updateFromDevice(poseData: DevicePose): void;
  83529. private _htmlElementAttached;
  83530. private _detachIfAttached;
  83531. /**
  83532. * WebVR's attach control will start broadcasting frames to the device.
  83533. * Note that in certain browsers (chrome for example) this function must be called
  83534. * within a user-interaction callback. Example:
  83535. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  83536. *
  83537. * @param element html element to attach the vrDevice to
  83538. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  83539. */
  83540. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83541. /**
  83542. * Detaches the camera from the html element and disables VR
  83543. *
  83544. * @param element html element to detach from
  83545. */
  83546. detachControl(element: HTMLElement): void;
  83547. /**
  83548. * @returns the name of this class
  83549. */
  83550. getClassName(): string;
  83551. /**
  83552. * Calls resetPose on the vrDisplay
  83553. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  83554. */
  83555. resetToCurrentRotation(): void;
  83556. /**
  83557. * @hidden
  83558. * Updates the rig cameras (left and right eye)
  83559. */
  83560. _updateRigCameras(): void;
  83561. private _workingVector;
  83562. private _oneVector;
  83563. private _workingMatrix;
  83564. private updateCacheCalled;
  83565. private _correctPositionIfNotTrackPosition;
  83566. /**
  83567. * @hidden
  83568. * Updates the cached values of the camera
  83569. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  83570. */
  83571. _updateCache(ignoreParentClass?: boolean): void;
  83572. /**
  83573. * @hidden
  83574. * Get current device position in babylon world
  83575. */
  83576. _computeDevicePosition(): void;
  83577. /**
  83578. * Updates the current device position and rotation in the babylon world
  83579. */
  83580. update(): void;
  83581. /**
  83582. * @hidden
  83583. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  83584. * @returns an identity matrix
  83585. */
  83586. _getViewMatrix(): Matrix;
  83587. private _tmpMatrix;
  83588. /**
  83589. * This function is called by the two RIG cameras.
  83590. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  83591. * @hidden
  83592. */
  83593. _getWebVRViewMatrix(): Matrix;
  83594. /** @hidden */
  83595. _getWebVRProjectionMatrix(): Matrix;
  83596. private _onGamepadConnectedObserver;
  83597. private _onGamepadDisconnectedObserver;
  83598. private _updateCacheWhenTrackingDisabledObserver;
  83599. /**
  83600. * Initializes the controllers and their meshes
  83601. */
  83602. initControllers(): void;
  83603. }
  83604. }
  83605. declare module BABYLON {
  83606. /**
  83607. * Size options for a post process
  83608. */
  83609. export type PostProcessOptions = {
  83610. width: number;
  83611. height: number;
  83612. };
  83613. /**
  83614. * PostProcess can be used to apply a shader to a texture after it has been rendered
  83615. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83616. */
  83617. export class PostProcess {
  83618. /** Name of the PostProcess. */
  83619. name: string;
  83620. /**
  83621. * Gets or sets the unique id of the post process
  83622. */
  83623. uniqueId: number;
  83624. /**
  83625. * Width of the texture to apply the post process on
  83626. */
  83627. width: number;
  83628. /**
  83629. * Height of the texture to apply the post process on
  83630. */
  83631. height: number;
  83632. /**
  83633. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  83634. * @hidden
  83635. */
  83636. _outputTexture: Nullable<InternalTexture>;
  83637. /**
  83638. * Sampling mode used by the shader
  83639. * See https://doc.babylonjs.com/classes/3.1/texture
  83640. */
  83641. renderTargetSamplingMode: number;
  83642. /**
  83643. * Clear color to use when screen clearing
  83644. */
  83645. clearColor: Color4;
  83646. /**
  83647. * If the buffer needs to be cleared before applying the post process. (default: true)
  83648. * Should be set to false if shader will overwrite all previous pixels.
  83649. */
  83650. autoClear: boolean;
  83651. /**
  83652. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  83653. */
  83654. alphaMode: number;
  83655. /**
  83656. * Sets the setAlphaBlendConstants of the babylon engine
  83657. */
  83658. alphaConstants: Color4;
  83659. /**
  83660. * Animations to be used for the post processing
  83661. */
  83662. animations: Animation[];
  83663. /**
  83664. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  83665. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  83666. */
  83667. enablePixelPerfectMode: boolean;
  83668. /**
  83669. * Force the postprocess to be applied without taking in account viewport
  83670. */
  83671. forceFullscreenViewport: boolean;
  83672. /**
  83673. * List of inspectable custom properties (used by the Inspector)
  83674. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83675. */
  83676. inspectableCustomProperties: IInspectable[];
  83677. /**
  83678. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  83679. *
  83680. * | Value | Type | Description |
  83681. * | ----- | ----------------------------------- | ----------- |
  83682. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  83683. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  83684. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  83685. *
  83686. */
  83687. scaleMode: number;
  83688. /**
  83689. * Force textures to be a power of two (default: false)
  83690. */
  83691. alwaysForcePOT: boolean;
  83692. private _samples;
  83693. /**
  83694. * Number of sample textures (default: 1)
  83695. */
  83696. samples: number;
  83697. /**
  83698. * Modify the scale of the post process to be the same as the viewport (default: false)
  83699. */
  83700. adaptScaleToCurrentViewport: boolean;
  83701. private _camera;
  83702. private _scene;
  83703. private _engine;
  83704. private _options;
  83705. private _reusable;
  83706. private _textureType;
  83707. /**
  83708. * Smart array of input and output textures for the post process.
  83709. * @hidden
  83710. */
  83711. _textures: SmartArray<InternalTexture>;
  83712. /**
  83713. * The index in _textures that corresponds to the output texture.
  83714. * @hidden
  83715. */
  83716. _currentRenderTextureInd: number;
  83717. private _effect;
  83718. private _samplers;
  83719. private _fragmentUrl;
  83720. private _vertexUrl;
  83721. private _parameters;
  83722. private _scaleRatio;
  83723. protected _indexParameters: any;
  83724. private _shareOutputWithPostProcess;
  83725. private _texelSize;
  83726. private _forcedOutputTexture;
  83727. /**
  83728. * Returns the fragment url or shader name used in the post process.
  83729. * @returns the fragment url or name in the shader store.
  83730. */
  83731. getEffectName(): string;
  83732. /**
  83733. * An event triggered when the postprocess is activated.
  83734. */
  83735. onActivateObservable: Observable<Camera>;
  83736. private _onActivateObserver;
  83737. /**
  83738. * A function that is added to the onActivateObservable
  83739. */
  83740. onActivate: Nullable<(camera: Camera) => void>;
  83741. /**
  83742. * An event triggered when the postprocess changes its size.
  83743. */
  83744. onSizeChangedObservable: Observable<PostProcess>;
  83745. private _onSizeChangedObserver;
  83746. /**
  83747. * A function that is added to the onSizeChangedObservable
  83748. */
  83749. onSizeChanged: (postProcess: PostProcess) => void;
  83750. /**
  83751. * An event triggered when the postprocess applies its effect.
  83752. */
  83753. onApplyObservable: Observable<Effect>;
  83754. private _onApplyObserver;
  83755. /**
  83756. * A function that is added to the onApplyObservable
  83757. */
  83758. onApply: (effect: Effect) => void;
  83759. /**
  83760. * An event triggered before rendering the postprocess
  83761. */
  83762. onBeforeRenderObservable: Observable<Effect>;
  83763. private _onBeforeRenderObserver;
  83764. /**
  83765. * A function that is added to the onBeforeRenderObservable
  83766. */
  83767. onBeforeRender: (effect: Effect) => void;
  83768. /**
  83769. * An event triggered after rendering the postprocess
  83770. */
  83771. onAfterRenderObservable: Observable<Effect>;
  83772. private _onAfterRenderObserver;
  83773. /**
  83774. * A function that is added to the onAfterRenderObservable
  83775. */
  83776. onAfterRender: (efect: Effect) => void;
  83777. /**
  83778. * 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
  83779. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  83780. */
  83781. inputTexture: InternalTexture;
  83782. /**
  83783. * Gets the camera which post process is applied to.
  83784. * @returns The camera the post process is applied to.
  83785. */
  83786. getCamera(): Camera;
  83787. /**
  83788. * Gets the texel size of the postprocess.
  83789. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  83790. */
  83791. readonly texelSize: Vector2;
  83792. /**
  83793. * Creates a new instance PostProcess
  83794. * @param name The name of the PostProcess.
  83795. * @param fragmentUrl The url of the fragment shader to be used.
  83796. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  83797. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  83798. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83799. * @param camera The camera to apply the render pass to.
  83800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83801. * @param engine The engine which the post process will be applied. (default: current engine)
  83802. * @param reusable If the post process can be reused on the same frame. (default: false)
  83803. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  83804. * @param textureType Type of textures used when performing the post process. (default: 0)
  83805. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  83806. * @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
  83807. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  83808. */
  83809. constructor(
  83810. /** Name of the PostProcess. */
  83811. 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);
  83812. /**
  83813. * Gets a string idenfifying the name of the class
  83814. * @returns "PostProcess" string
  83815. */
  83816. getClassName(): string;
  83817. /**
  83818. * Gets the engine which this post process belongs to.
  83819. * @returns The engine the post process was enabled with.
  83820. */
  83821. getEngine(): Engine;
  83822. /**
  83823. * The effect that is created when initializing the post process.
  83824. * @returns The created effect corresponding the the postprocess.
  83825. */
  83826. getEffect(): Effect;
  83827. /**
  83828. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  83829. * @param postProcess The post process to share the output with.
  83830. * @returns This post process.
  83831. */
  83832. shareOutputWith(postProcess: PostProcess): PostProcess;
  83833. /**
  83834. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  83835. * This should be called if the post process that shares output with this post process is disabled/disposed.
  83836. */
  83837. useOwnOutput(): void;
  83838. /**
  83839. * Updates the effect with the current post process compile time values and recompiles the shader.
  83840. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83841. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83842. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83843. * @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
  83844. * @param onCompiled Called when the shader has been compiled.
  83845. * @param onError Called if there is an error when compiling a shader.
  83846. */
  83847. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83848. /**
  83849. * The post process is reusable if it can be used multiple times within one frame.
  83850. * @returns If the post process is reusable
  83851. */
  83852. isReusable(): boolean;
  83853. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  83854. markTextureDirty(): void;
  83855. /**
  83856. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  83857. * 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.
  83858. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  83859. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  83860. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  83861. * @returns The target texture that was bound to be written to.
  83862. */
  83863. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  83864. /**
  83865. * If the post process is supported.
  83866. */
  83867. readonly isSupported: boolean;
  83868. /**
  83869. * The aspect ratio of the output texture.
  83870. */
  83871. readonly aspectRatio: number;
  83872. /**
  83873. * Get a value indicating if the post-process is ready to be used
  83874. * @returns true if the post-process is ready (shader is compiled)
  83875. */
  83876. isReady(): boolean;
  83877. /**
  83878. * Binds all textures and uniforms to the shader, this will be run on every pass.
  83879. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  83880. */
  83881. apply(): Nullable<Effect>;
  83882. private _disposeTextures;
  83883. /**
  83884. * Disposes the post process.
  83885. * @param camera The camera to dispose the post process on.
  83886. */
  83887. dispose(camera?: Camera): void;
  83888. }
  83889. }
  83890. declare module BABYLON {
  83891. /** @hidden */
  83892. export var kernelBlurVaryingDeclaration: {
  83893. name: string;
  83894. shader: string;
  83895. };
  83896. }
  83897. declare module BABYLON {
  83898. /** @hidden */
  83899. export var kernelBlurFragment: {
  83900. name: string;
  83901. shader: string;
  83902. };
  83903. }
  83904. declare module BABYLON {
  83905. /** @hidden */
  83906. export var kernelBlurFragment2: {
  83907. name: string;
  83908. shader: string;
  83909. };
  83910. }
  83911. declare module BABYLON {
  83912. /** @hidden */
  83913. export var kernelBlurPixelShader: {
  83914. name: string;
  83915. shader: string;
  83916. };
  83917. }
  83918. declare module BABYLON {
  83919. /** @hidden */
  83920. export var kernelBlurVertex: {
  83921. name: string;
  83922. shader: string;
  83923. };
  83924. }
  83925. declare module BABYLON {
  83926. /** @hidden */
  83927. export var kernelBlurVertexShader: {
  83928. name: string;
  83929. shader: string;
  83930. };
  83931. }
  83932. declare module BABYLON {
  83933. /**
  83934. * The Blur Post Process which blurs an image based on a kernel and direction.
  83935. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  83936. */
  83937. export class BlurPostProcess extends PostProcess {
  83938. /** The direction in which to blur the image. */
  83939. direction: Vector2;
  83940. private blockCompilation;
  83941. protected _kernel: number;
  83942. protected _idealKernel: number;
  83943. protected _packedFloat: boolean;
  83944. private _staticDefines;
  83945. /**
  83946. * Sets the length in pixels of the blur sample region
  83947. */
  83948. /**
  83949. * Gets the length in pixels of the blur sample region
  83950. */
  83951. kernel: number;
  83952. /**
  83953. * Sets wether or not the blur needs to unpack/repack floats
  83954. */
  83955. /**
  83956. * Gets wether or not the blur is unpacking/repacking floats
  83957. */
  83958. packedFloat: boolean;
  83959. /**
  83960. * Creates a new instance BlurPostProcess
  83961. * @param name The name of the effect.
  83962. * @param direction The direction in which to blur the image.
  83963. * @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.
  83964. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83965. * @param camera The camera to apply the render pass to.
  83966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83967. * @param engine The engine which the post process will be applied. (default: current engine)
  83968. * @param reusable If the post process can be reused on the same frame. (default: false)
  83969. * @param textureType Type of textures used when performing the post process. (default: 0)
  83970. * @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)
  83971. */
  83972. constructor(name: string,
  83973. /** The direction in which to blur the image. */
  83974. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  83975. /**
  83976. * Updates the effect with the current post process compile time values and recompiles the shader.
  83977. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83978. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83979. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83980. * @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
  83981. * @param onCompiled Called when the shader has been compiled.
  83982. * @param onError Called if there is an error when compiling a shader.
  83983. */
  83984. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83985. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83986. /**
  83987. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  83988. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  83989. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  83990. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  83991. * The gaps between physical kernels are compensated for in the weighting of the samples
  83992. * @param idealKernel Ideal blur kernel.
  83993. * @return Nearest best kernel.
  83994. */
  83995. protected _nearestBestKernel(idealKernel: number): number;
  83996. /**
  83997. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  83998. * @param x The point on the Gaussian distribution to sample.
  83999. * @return the value of the Gaussian function at x.
  84000. */
  84001. protected _gaussianWeight(x: number): number;
  84002. /**
  84003. * Generates a string that can be used as a floating point number in GLSL.
  84004. * @param x Value to print.
  84005. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  84006. * @return GLSL float string.
  84007. */
  84008. protected _glslFloat(x: number, decimalFigures?: number): string;
  84009. }
  84010. }
  84011. declare module BABYLON {
  84012. /**
  84013. * Mirror texture can be used to simulate the view from a mirror in a scene.
  84014. * It will dynamically be rendered every frame to adapt to the camera point of view.
  84015. * You can then easily use it as a reflectionTexture on a flat surface.
  84016. * In case the surface is not a plane, please consider relying on reflection probes.
  84017. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84018. */
  84019. export class MirrorTexture extends RenderTargetTexture {
  84020. private scene;
  84021. /**
  84022. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  84023. * 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.
  84024. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84025. */
  84026. mirrorPlane: Plane;
  84027. /**
  84028. * Define the blur ratio used to blur the reflection if needed.
  84029. */
  84030. blurRatio: number;
  84031. /**
  84032. * Define the adaptive blur kernel used to blur the reflection if needed.
  84033. * This will autocompute the closest best match for the `blurKernel`
  84034. */
  84035. adaptiveBlurKernel: number;
  84036. /**
  84037. * Define the blur kernel used to blur the reflection if needed.
  84038. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84039. */
  84040. blurKernel: number;
  84041. /**
  84042. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  84043. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84044. */
  84045. blurKernelX: number;
  84046. /**
  84047. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  84048. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84049. */
  84050. blurKernelY: number;
  84051. private _autoComputeBlurKernel;
  84052. protected _onRatioRescale(): void;
  84053. private _updateGammaSpace;
  84054. private _imageProcessingConfigChangeObserver;
  84055. private _transformMatrix;
  84056. private _mirrorMatrix;
  84057. private _savedViewMatrix;
  84058. private _blurX;
  84059. private _blurY;
  84060. private _adaptiveBlurKernel;
  84061. private _blurKernelX;
  84062. private _blurKernelY;
  84063. private _blurRatio;
  84064. /**
  84065. * Instantiates a Mirror Texture.
  84066. * Mirror texture can be used to simulate the view from a mirror in a scene.
  84067. * It will dynamically be rendered every frame to adapt to the camera point of view.
  84068. * You can then easily use it as a reflectionTexture on a flat surface.
  84069. * In case the surface is not a plane, please consider relying on reflection probes.
  84070. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84071. * @param name
  84072. * @param size
  84073. * @param scene
  84074. * @param generateMipMaps
  84075. * @param type
  84076. * @param samplingMode
  84077. * @param generateDepthBuffer
  84078. */
  84079. constructor(name: string, size: number | {
  84080. width: number;
  84081. height: number;
  84082. } | {
  84083. ratio: number;
  84084. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  84085. private _preparePostProcesses;
  84086. /**
  84087. * Clone the mirror texture.
  84088. * @returns the cloned texture
  84089. */
  84090. clone(): MirrorTexture;
  84091. /**
  84092. * Serialize the texture to a JSON representation you could use in Parse later on
  84093. * @returns the serialized JSON representation
  84094. */
  84095. serialize(): any;
  84096. /**
  84097. * Dispose the texture and release its associated resources.
  84098. */
  84099. dispose(): void;
  84100. }
  84101. }
  84102. declare module BABYLON {
  84103. /**
  84104. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84105. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84106. */
  84107. export class Texture extends BaseTexture {
  84108. /**
  84109. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  84110. */
  84111. static SerializeBuffers: boolean;
  84112. /** @hidden */
  84113. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  84114. /** @hidden */
  84115. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  84116. /** @hidden */
  84117. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  84118. /** nearest is mag = nearest and min = nearest and mip = linear */
  84119. static readonly NEAREST_SAMPLINGMODE: number;
  84120. /** nearest is mag = nearest and min = nearest and mip = linear */
  84121. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  84122. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84123. static readonly BILINEAR_SAMPLINGMODE: number;
  84124. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84125. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  84126. /** Trilinear is mag = linear and min = linear and mip = linear */
  84127. static readonly TRILINEAR_SAMPLINGMODE: number;
  84128. /** Trilinear is mag = linear and min = linear and mip = linear */
  84129. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  84130. /** mag = nearest and min = nearest and mip = nearest */
  84131. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  84132. /** mag = nearest and min = linear and mip = nearest */
  84133. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  84134. /** mag = nearest and min = linear and mip = linear */
  84135. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  84136. /** mag = nearest and min = linear and mip = none */
  84137. static readonly NEAREST_LINEAR: number;
  84138. /** mag = nearest and min = nearest and mip = none */
  84139. static readonly NEAREST_NEAREST: number;
  84140. /** mag = linear and min = nearest and mip = nearest */
  84141. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  84142. /** mag = linear and min = nearest and mip = linear */
  84143. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  84144. /** mag = linear and min = linear and mip = none */
  84145. static readonly LINEAR_LINEAR: number;
  84146. /** mag = linear and min = nearest and mip = none */
  84147. static readonly LINEAR_NEAREST: number;
  84148. /** Explicit coordinates mode */
  84149. static readonly EXPLICIT_MODE: number;
  84150. /** Spherical coordinates mode */
  84151. static readonly SPHERICAL_MODE: number;
  84152. /** Planar coordinates mode */
  84153. static readonly PLANAR_MODE: number;
  84154. /** Cubic coordinates mode */
  84155. static readonly CUBIC_MODE: number;
  84156. /** Projection coordinates mode */
  84157. static readonly PROJECTION_MODE: number;
  84158. /** Inverse Cubic coordinates mode */
  84159. static readonly SKYBOX_MODE: number;
  84160. /** Inverse Cubic coordinates mode */
  84161. static readonly INVCUBIC_MODE: number;
  84162. /** Equirectangular coordinates mode */
  84163. static readonly EQUIRECTANGULAR_MODE: number;
  84164. /** Equirectangular Fixed coordinates mode */
  84165. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  84166. /** Equirectangular Fixed Mirrored coordinates mode */
  84167. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  84168. /** Texture is not repeating outside of 0..1 UVs */
  84169. static readonly CLAMP_ADDRESSMODE: number;
  84170. /** Texture is repeating outside of 0..1 UVs */
  84171. static readonly WRAP_ADDRESSMODE: number;
  84172. /** Texture is repeating and mirrored */
  84173. static readonly MIRROR_ADDRESSMODE: number;
  84174. /**
  84175. * 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
  84176. */
  84177. static UseSerializedUrlIfAny: boolean;
  84178. /**
  84179. * Define the url of the texture.
  84180. */
  84181. url: Nullable<string>;
  84182. /**
  84183. * Define an offset on the texture to offset the u coordinates of the UVs
  84184. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84185. */
  84186. uOffset: number;
  84187. /**
  84188. * Define an offset on the texture to offset the v coordinates of the UVs
  84189. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84190. */
  84191. vOffset: number;
  84192. /**
  84193. * Define an offset on the texture to scale the u coordinates of the UVs
  84194. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84195. */
  84196. uScale: number;
  84197. /**
  84198. * Define an offset on the texture to scale the v coordinates of the UVs
  84199. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84200. */
  84201. vScale: number;
  84202. /**
  84203. * Define an offset on the texture to rotate around the u coordinates of the UVs
  84204. * @see http://doc.babylonjs.com/how_to/more_materials
  84205. */
  84206. uAng: number;
  84207. /**
  84208. * Define an offset on the texture to rotate around the v coordinates of the UVs
  84209. * @see http://doc.babylonjs.com/how_to/more_materials
  84210. */
  84211. vAng: number;
  84212. /**
  84213. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  84214. * @see http://doc.babylonjs.com/how_to/more_materials
  84215. */
  84216. wAng: number;
  84217. /**
  84218. * Defines the center of rotation (U)
  84219. */
  84220. uRotationCenter: number;
  84221. /**
  84222. * Defines the center of rotation (V)
  84223. */
  84224. vRotationCenter: number;
  84225. /**
  84226. * Defines the center of rotation (W)
  84227. */
  84228. wRotationCenter: number;
  84229. /**
  84230. * Are mip maps generated for this texture or not.
  84231. */
  84232. readonly noMipmap: boolean;
  84233. /**
  84234. * List of inspectable custom properties (used by the Inspector)
  84235. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84236. */
  84237. inspectableCustomProperties: Nullable<IInspectable[]>;
  84238. private _noMipmap;
  84239. /** @hidden */
  84240. _invertY: boolean;
  84241. private _rowGenerationMatrix;
  84242. private _cachedTextureMatrix;
  84243. private _projectionModeMatrix;
  84244. private _t0;
  84245. private _t1;
  84246. private _t2;
  84247. private _cachedUOffset;
  84248. private _cachedVOffset;
  84249. private _cachedUScale;
  84250. private _cachedVScale;
  84251. private _cachedUAng;
  84252. private _cachedVAng;
  84253. private _cachedWAng;
  84254. private _cachedProjectionMatrixId;
  84255. private _cachedCoordinatesMode;
  84256. /** @hidden */
  84257. protected _initialSamplingMode: number;
  84258. /** @hidden */
  84259. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  84260. private _deleteBuffer;
  84261. protected _format: Nullable<number>;
  84262. private _delayedOnLoad;
  84263. private _delayedOnError;
  84264. private _mimeType?;
  84265. /**
  84266. * Observable triggered once the texture has been loaded.
  84267. */
  84268. onLoadObservable: Observable<Texture>;
  84269. protected _isBlocking: boolean;
  84270. /**
  84271. * Is the texture preventing material to render while loading.
  84272. * If false, a default texture will be used instead of the loading one during the preparation step.
  84273. */
  84274. isBlocking: boolean;
  84275. /**
  84276. * Get the current sampling mode associated with the texture.
  84277. */
  84278. readonly samplingMode: number;
  84279. /**
  84280. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  84281. */
  84282. readonly invertY: boolean;
  84283. /**
  84284. * Instantiates a new texture.
  84285. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84286. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84287. * @param url defines the url of the picture to load as a texture
  84288. * @param scene defines the scene or engine the texture will belong to
  84289. * @param noMipmap defines if the texture will require mip maps or not
  84290. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  84291. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84292. * @param onLoad defines a callback triggered when the texture has been loaded
  84293. * @param onError defines a callback triggered when an error occurred during the loading session
  84294. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  84295. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  84296. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84297. * @param mimeType defines an optional mime type information
  84298. */
  84299. 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);
  84300. /**
  84301. * Update the url (and optional buffer) of this texture if url was null during construction.
  84302. * @param url the url of the texture
  84303. * @param buffer the buffer of the texture (defaults to null)
  84304. * @param onLoad callback called when the texture is loaded (defaults to null)
  84305. */
  84306. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  84307. /**
  84308. * Finish the loading sequence of a texture flagged as delayed load.
  84309. * @hidden
  84310. */
  84311. delayLoad(): void;
  84312. private _prepareRowForTextureGeneration;
  84313. /**
  84314. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  84315. * @returns the transform matrix of the texture.
  84316. */
  84317. getTextureMatrix(): Matrix;
  84318. /**
  84319. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  84320. * @returns The reflection texture transform
  84321. */
  84322. getReflectionTextureMatrix(): Matrix;
  84323. /**
  84324. * Clones the texture.
  84325. * @returns the cloned texture
  84326. */
  84327. clone(): Texture;
  84328. /**
  84329. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84330. * @returns The JSON representation of the texture
  84331. */
  84332. serialize(): any;
  84333. /**
  84334. * Get the current class name of the texture useful for serialization or dynamic coding.
  84335. * @returns "Texture"
  84336. */
  84337. getClassName(): string;
  84338. /**
  84339. * Dispose the texture and release its associated resources.
  84340. */
  84341. dispose(): void;
  84342. /**
  84343. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  84344. * @param parsedTexture Define the JSON representation of the texture
  84345. * @param scene Define the scene the parsed texture should be instantiated in
  84346. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  84347. * @returns The parsed texture if successful
  84348. */
  84349. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  84350. /**
  84351. * Creates a texture from its base 64 representation.
  84352. * @param data Define the base64 payload without the data: prefix
  84353. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  84354. * @param scene Define the scene the texture should belong to
  84355. * @param noMipmap Forces the texture to not create mip map information if true
  84356. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84357. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84358. * @param onLoad define a callback triggered when the texture has been loaded
  84359. * @param onError define a callback triggered when an error occurred during the loading session
  84360. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84361. * @returns the created texture
  84362. */
  84363. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  84364. /**
  84365. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  84366. * @param data Define the base64 payload without the data: prefix
  84367. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  84368. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  84369. * @param scene Define the scene the texture should belong to
  84370. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  84371. * @param noMipmap Forces the texture to not create mip map information if true
  84372. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84373. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84374. * @param onLoad define a callback triggered when the texture has been loaded
  84375. * @param onError define a callback triggered when an error occurred during the loading session
  84376. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84377. * @returns the created texture
  84378. */
  84379. 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;
  84380. }
  84381. }
  84382. declare module BABYLON {
  84383. /**
  84384. * PostProcessManager is used to manage one or more post processes or post process pipelines
  84385. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  84386. */
  84387. export class PostProcessManager {
  84388. private _scene;
  84389. private _indexBuffer;
  84390. private _vertexBuffers;
  84391. /**
  84392. * Creates a new instance PostProcess
  84393. * @param scene The scene that the post process is associated with.
  84394. */
  84395. constructor(scene: Scene);
  84396. private _prepareBuffers;
  84397. private _buildIndexBuffer;
  84398. /**
  84399. * Rebuilds the vertex buffers of the manager.
  84400. * @hidden
  84401. */
  84402. _rebuild(): void;
  84403. /**
  84404. * Prepares a frame to be run through a post process.
  84405. * @param sourceTexture The input texture to the post procesess. (default: null)
  84406. * @param postProcesses An array of post processes to be run. (default: null)
  84407. * @returns True if the post processes were able to be run.
  84408. * @hidden
  84409. */
  84410. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  84411. /**
  84412. * Manually render a set of post processes to a texture.
  84413. * @param postProcesses An array of post processes to be run.
  84414. * @param targetTexture The target texture to render to.
  84415. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  84416. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  84417. * @param lodLevel defines which lod of the texture to render to
  84418. */
  84419. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  84420. /**
  84421. * Finalize the result of the output of the postprocesses.
  84422. * @param doNotPresent If true the result will not be displayed to the screen.
  84423. * @param targetTexture The target texture to render to.
  84424. * @param faceIndex The index of the face to bind the target texture to.
  84425. * @param postProcesses The array of post processes to render.
  84426. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  84427. * @hidden
  84428. */
  84429. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  84430. /**
  84431. * Disposes of the post process manager.
  84432. */
  84433. dispose(): void;
  84434. }
  84435. }
  84436. declare module BABYLON {
  84437. /** Interface used by value gradients (color, factor, ...) */
  84438. export interface IValueGradient {
  84439. /**
  84440. * Gets or sets the gradient value (between 0 and 1)
  84441. */
  84442. gradient: number;
  84443. }
  84444. /** Class used to store color4 gradient */
  84445. export class ColorGradient implements IValueGradient {
  84446. /**
  84447. * Gets or sets the gradient value (between 0 and 1)
  84448. */
  84449. gradient: number;
  84450. /**
  84451. * Gets or sets first associated color
  84452. */
  84453. color1: Color4;
  84454. /**
  84455. * Gets or sets second associated color
  84456. */
  84457. color2?: Color4;
  84458. /**
  84459. * Will get a color picked randomly between color1 and color2.
  84460. * If color2 is undefined then color1 will be used
  84461. * @param result defines the target Color4 to store the result in
  84462. */
  84463. getColorToRef(result: Color4): void;
  84464. }
  84465. /** Class used to store color 3 gradient */
  84466. export class Color3Gradient implements IValueGradient {
  84467. /**
  84468. * Gets or sets the gradient value (between 0 and 1)
  84469. */
  84470. gradient: number;
  84471. /**
  84472. * Gets or sets the associated color
  84473. */
  84474. color: Color3;
  84475. }
  84476. /** Class used to store factor gradient */
  84477. export class FactorGradient implements IValueGradient {
  84478. /**
  84479. * Gets or sets the gradient value (between 0 and 1)
  84480. */
  84481. gradient: number;
  84482. /**
  84483. * Gets or sets first associated factor
  84484. */
  84485. factor1: number;
  84486. /**
  84487. * Gets or sets second associated factor
  84488. */
  84489. factor2?: number;
  84490. /**
  84491. * Will get a number picked randomly between factor1 and factor2.
  84492. * If factor2 is undefined then factor1 will be used
  84493. * @returns the picked number
  84494. */
  84495. getFactor(): number;
  84496. }
  84497. /**
  84498. * Helper used to simplify some generic gradient tasks
  84499. */
  84500. export class GradientHelper {
  84501. /**
  84502. * Gets the current gradient from an array of IValueGradient
  84503. * @param ratio defines the current ratio to get
  84504. * @param gradients defines the array of IValueGradient
  84505. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  84506. */
  84507. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  84508. }
  84509. }
  84510. declare module BABYLON {
  84511. interface ThinEngine {
  84512. /**
  84513. * Creates a dynamic texture
  84514. * @param width defines the width of the texture
  84515. * @param height defines the height of the texture
  84516. * @param generateMipMaps defines if the engine should generate the mip levels
  84517. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84518. * @returns the dynamic texture inside an InternalTexture
  84519. */
  84520. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84521. /**
  84522. * Update the content of a dynamic texture
  84523. * @param texture defines the texture to update
  84524. * @param canvas defines the canvas containing the source
  84525. * @param invertY defines if data must be stored with Y axis inverted
  84526. * @param premulAlpha defines if alpha is stored as premultiplied
  84527. * @param format defines the format of the data
  84528. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84529. */
  84530. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84531. }
  84532. }
  84533. declare module BABYLON {
  84534. /**
  84535. * Helper class used to generate a canvas to manipulate images
  84536. */
  84537. export class CanvasGenerator {
  84538. /**
  84539. * Create a new canvas (or offscreen canvas depending on the context)
  84540. * @param width defines the expected width
  84541. * @param height defines the expected height
  84542. * @return a new canvas or offscreen canvas
  84543. */
  84544. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  84545. }
  84546. }
  84547. declare module BABYLON {
  84548. /**
  84549. * A class extending Texture allowing drawing on a texture
  84550. * @see http://doc.babylonjs.com/how_to/dynamictexture
  84551. */
  84552. export class DynamicTexture extends Texture {
  84553. private _generateMipMaps;
  84554. private _canvas;
  84555. private _context;
  84556. private _engine;
  84557. /**
  84558. * Creates a DynamicTexture
  84559. * @param name defines the name of the texture
  84560. * @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
  84561. * @param scene defines the scene where you want the texture
  84562. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  84563. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  84564. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  84565. */
  84566. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  84567. /**
  84568. * Get the current class name of the texture useful for serialization or dynamic coding.
  84569. * @returns "DynamicTexture"
  84570. */
  84571. getClassName(): string;
  84572. /**
  84573. * Gets the current state of canRescale
  84574. */
  84575. readonly canRescale: boolean;
  84576. private _recreate;
  84577. /**
  84578. * Scales the texture
  84579. * @param ratio the scale factor to apply to both width and height
  84580. */
  84581. scale(ratio: number): void;
  84582. /**
  84583. * Resizes the texture
  84584. * @param width the new width
  84585. * @param height the new height
  84586. */
  84587. scaleTo(width: number, height: number): void;
  84588. /**
  84589. * Gets the context of the canvas used by the texture
  84590. * @returns the canvas context of the dynamic texture
  84591. */
  84592. getContext(): CanvasRenderingContext2D;
  84593. /**
  84594. * Clears the texture
  84595. */
  84596. clear(): void;
  84597. /**
  84598. * Updates the texture
  84599. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84600. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  84601. */
  84602. update(invertY?: boolean, premulAlpha?: boolean): void;
  84603. /**
  84604. * Draws text onto the texture
  84605. * @param text defines the text to be drawn
  84606. * @param x defines the placement of the text from the left
  84607. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  84608. * @param font defines the font to be used with font-style, font-size, font-name
  84609. * @param color defines the color used for the text
  84610. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  84611. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84612. * @param update defines whether texture is immediately update (default is true)
  84613. */
  84614. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  84615. /**
  84616. * Clones the texture
  84617. * @returns the clone of the texture.
  84618. */
  84619. clone(): DynamicTexture;
  84620. /**
  84621. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  84622. * @returns a serialized dynamic texture object
  84623. */
  84624. serialize(): any;
  84625. /** @hidden */
  84626. _rebuild(): void;
  84627. }
  84628. }
  84629. declare module BABYLON {
  84630. interface AbstractScene {
  84631. /**
  84632. * The list of procedural textures added to the scene
  84633. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84634. */
  84635. proceduralTextures: Array<ProceduralTexture>;
  84636. }
  84637. /**
  84638. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84639. * in a given scene.
  84640. */
  84641. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84642. /**
  84643. * The component name helpfull to identify the component in the list of scene components.
  84644. */
  84645. readonly name: string;
  84646. /**
  84647. * The scene the component belongs to.
  84648. */
  84649. scene: Scene;
  84650. /**
  84651. * Creates a new instance of the component for the given scene
  84652. * @param scene Defines the scene to register the component in
  84653. */
  84654. constructor(scene: Scene);
  84655. /**
  84656. * Registers the component in a given scene
  84657. */
  84658. register(): void;
  84659. /**
  84660. * Rebuilds the elements related to this component in case of
  84661. * context lost for instance.
  84662. */
  84663. rebuild(): void;
  84664. /**
  84665. * Disposes the component and the associated ressources.
  84666. */
  84667. dispose(): void;
  84668. private _beforeClear;
  84669. }
  84670. }
  84671. declare module BABYLON {
  84672. interface ThinEngine {
  84673. /**
  84674. * Creates a new render target cube texture
  84675. * @param size defines the size of the texture
  84676. * @param options defines the options used to create the texture
  84677. * @returns a new render target cube texture stored in an InternalTexture
  84678. */
  84679. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84680. }
  84681. }
  84682. declare module BABYLON {
  84683. /** @hidden */
  84684. export var proceduralVertexShader: {
  84685. name: string;
  84686. shader: string;
  84687. };
  84688. }
  84689. declare module BABYLON {
  84690. /**
  84691. * 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.
  84692. * This is the base class of any Procedural texture and contains most of the shareable code.
  84693. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84694. */
  84695. export class ProceduralTexture extends Texture {
  84696. isCube: boolean;
  84697. /**
  84698. * Define if the texture is enabled or not (disabled texture will not render)
  84699. */
  84700. isEnabled: boolean;
  84701. /**
  84702. * Define if the texture must be cleared before rendering (default is true)
  84703. */
  84704. autoClear: boolean;
  84705. /**
  84706. * Callback called when the texture is generated
  84707. */
  84708. onGenerated: () => void;
  84709. /**
  84710. * Event raised when the texture is generated
  84711. */
  84712. onGeneratedObservable: Observable<ProceduralTexture>;
  84713. /** @hidden */
  84714. _generateMipMaps: boolean;
  84715. /** @hidden **/
  84716. _effect: Effect;
  84717. /** @hidden */
  84718. _textures: {
  84719. [key: string]: Texture;
  84720. };
  84721. private _size;
  84722. private _currentRefreshId;
  84723. private _refreshRate;
  84724. private _vertexBuffers;
  84725. private _indexBuffer;
  84726. private _uniforms;
  84727. private _samplers;
  84728. private _fragment;
  84729. private _floats;
  84730. private _ints;
  84731. private _floatsArrays;
  84732. private _colors3;
  84733. private _colors4;
  84734. private _vectors2;
  84735. private _vectors3;
  84736. private _matrices;
  84737. private _fallbackTexture;
  84738. private _fallbackTextureUsed;
  84739. private _engine;
  84740. private _cachedDefines;
  84741. private _contentUpdateId;
  84742. private _contentData;
  84743. /**
  84744. * Instantiates a new procedural texture.
  84745. * 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.
  84746. * This is the base class of any Procedural texture and contains most of the shareable code.
  84747. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84748. * @param name Define the name of the texture
  84749. * @param size Define the size of the texture to create
  84750. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84751. * @param scene Define the scene the texture belongs to
  84752. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84753. * @param generateMipMaps Define if the texture should creates mip maps or not
  84754. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84755. */
  84756. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84757. /**
  84758. * The effect that is created when initializing the post process.
  84759. * @returns The created effect corresponding the the postprocess.
  84760. */
  84761. getEffect(): Effect;
  84762. /**
  84763. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84764. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84765. */
  84766. getContent(): Nullable<ArrayBufferView>;
  84767. private _createIndexBuffer;
  84768. /** @hidden */
  84769. _rebuild(): void;
  84770. /**
  84771. * Resets the texture in order to recreate its associated resources.
  84772. * This can be called in case of context loss
  84773. */
  84774. reset(): void;
  84775. protected _getDefines(): string;
  84776. /**
  84777. * Is the texture ready to be used ? (rendered at least once)
  84778. * @returns true if ready, otherwise, false.
  84779. */
  84780. isReady(): boolean;
  84781. /**
  84782. * Resets the refresh counter of the texture and start bak from scratch.
  84783. * Could be useful to regenerate the texture if it is setup to render only once.
  84784. */
  84785. resetRefreshCounter(): void;
  84786. /**
  84787. * Set the fragment shader to use in order to render the texture.
  84788. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84789. */
  84790. setFragment(fragment: any): void;
  84791. /**
  84792. * Define the refresh rate of the texture or the rendering frequency.
  84793. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84794. */
  84795. refreshRate: number;
  84796. /** @hidden */
  84797. _shouldRender(): boolean;
  84798. /**
  84799. * Get the size the texture is rendering at.
  84800. * @returns the size (texture is always squared)
  84801. */
  84802. getRenderSize(): number;
  84803. /**
  84804. * Resize the texture to new value.
  84805. * @param size Define the new size the texture should have
  84806. * @param generateMipMaps Define whether the new texture should create mip maps
  84807. */
  84808. resize(size: number, generateMipMaps: boolean): void;
  84809. private _checkUniform;
  84810. /**
  84811. * Set a texture in the shader program used to render.
  84812. * @param name Define the name of the uniform samplers as defined in the shader
  84813. * @param texture Define the texture to bind to this sampler
  84814. * @return the texture itself allowing "fluent" like uniform updates
  84815. */
  84816. setTexture(name: string, texture: Texture): ProceduralTexture;
  84817. /**
  84818. * Set a float in the shader.
  84819. * @param name Define the name of the uniform as defined in the shader
  84820. * @param value Define the value to give to the uniform
  84821. * @return the texture itself allowing "fluent" like uniform updates
  84822. */
  84823. setFloat(name: string, value: number): ProceduralTexture;
  84824. /**
  84825. * Set a int in the shader.
  84826. * @param name Define the name of the uniform as defined in the shader
  84827. * @param value Define the value to give to the uniform
  84828. * @return the texture itself allowing "fluent" like uniform updates
  84829. */
  84830. setInt(name: string, value: number): ProceduralTexture;
  84831. /**
  84832. * Set an array of floats in the shader.
  84833. * @param name Define the name of the uniform as defined in the shader
  84834. * @param value Define the value to give to the uniform
  84835. * @return the texture itself allowing "fluent" like uniform updates
  84836. */
  84837. setFloats(name: string, value: number[]): ProceduralTexture;
  84838. /**
  84839. * Set a vec3 in the shader from a Color3.
  84840. * @param name Define the name of the uniform as defined in the shader
  84841. * @param value Define the value to give to the uniform
  84842. * @return the texture itself allowing "fluent" like uniform updates
  84843. */
  84844. setColor3(name: string, value: Color3): ProceduralTexture;
  84845. /**
  84846. * Set a vec4 in the shader from a Color4.
  84847. * @param name Define the name of the uniform as defined in the shader
  84848. * @param value Define the value to give to the uniform
  84849. * @return the texture itself allowing "fluent" like uniform updates
  84850. */
  84851. setColor4(name: string, value: Color4): ProceduralTexture;
  84852. /**
  84853. * Set a vec2 in the shader from a Vector2.
  84854. * @param name Define the name of the uniform as defined in the shader
  84855. * @param value Define the value to give to the uniform
  84856. * @return the texture itself allowing "fluent" like uniform updates
  84857. */
  84858. setVector2(name: string, value: Vector2): ProceduralTexture;
  84859. /**
  84860. * Set a vec3 in the shader from a Vector3.
  84861. * @param name Define the name of the uniform as defined in the shader
  84862. * @param value Define the value to give to the uniform
  84863. * @return the texture itself allowing "fluent" like uniform updates
  84864. */
  84865. setVector3(name: string, value: Vector3): ProceduralTexture;
  84866. /**
  84867. * Set a mat4 in the shader from a MAtrix.
  84868. * @param name Define the name of the uniform as defined in the shader
  84869. * @param value Define the value to give to the uniform
  84870. * @return the texture itself allowing "fluent" like uniform updates
  84871. */
  84872. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84873. /**
  84874. * Render the texture to its associated render target.
  84875. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84876. */
  84877. render(useCameraPostProcess?: boolean): void;
  84878. /**
  84879. * Clone the texture.
  84880. * @returns the cloned texture
  84881. */
  84882. clone(): ProceduralTexture;
  84883. /**
  84884. * Dispose the texture and release its asoociated resources.
  84885. */
  84886. dispose(): void;
  84887. }
  84888. }
  84889. declare module BABYLON {
  84890. /**
  84891. * This represents the base class for particle system in Babylon.
  84892. * 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.
  84893. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84894. * @example https://doc.babylonjs.com/babylon101/particles
  84895. */
  84896. export class BaseParticleSystem {
  84897. /**
  84898. * Source color is added to the destination color without alpha affecting the result
  84899. */
  84900. static BLENDMODE_ONEONE: number;
  84901. /**
  84902. * Blend current color and particle color using particle’s alpha
  84903. */
  84904. static BLENDMODE_STANDARD: number;
  84905. /**
  84906. * Add current color and particle color multiplied by particle’s alpha
  84907. */
  84908. static BLENDMODE_ADD: number;
  84909. /**
  84910. * Multiply current color with particle color
  84911. */
  84912. static BLENDMODE_MULTIPLY: number;
  84913. /**
  84914. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84915. */
  84916. static BLENDMODE_MULTIPLYADD: number;
  84917. /**
  84918. * List of animations used by the particle system.
  84919. */
  84920. animations: Animation[];
  84921. /**
  84922. * The id of the Particle system.
  84923. */
  84924. id: string;
  84925. /**
  84926. * The friendly name of the Particle system.
  84927. */
  84928. name: string;
  84929. /**
  84930. * The rendering group used by the Particle system to chose when to render.
  84931. */
  84932. renderingGroupId: number;
  84933. /**
  84934. * The emitter represents the Mesh or position we are attaching the particle system to.
  84935. */
  84936. emitter: Nullable<AbstractMesh | Vector3>;
  84937. /**
  84938. * The maximum number of particles to emit per frame
  84939. */
  84940. emitRate: number;
  84941. /**
  84942. * If you want to launch only a few particles at once, that can be done, as well.
  84943. */
  84944. manualEmitCount: number;
  84945. /**
  84946. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84947. */
  84948. updateSpeed: number;
  84949. /**
  84950. * The amount of time the particle system is running (depends of the overall update speed).
  84951. */
  84952. targetStopDuration: number;
  84953. /**
  84954. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84955. */
  84956. disposeOnStop: boolean;
  84957. /**
  84958. * Minimum power of emitting particles.
  84959. */
  84960. minEmitPower: number;
  84961. /**
  84962. * Maximum power of emitting particles.
  84963. */
  84964. maxEmitPower: number;
  84965. /**
  84966. * Minimum life time of emitting particles.
  84967. */
  84968. minLifeTime: number;
  84969. /**
  84970. * Maximum life time of emitting particles.
  84971. */
  84972. maxLifeTime: number;
  84973. /**
  84974. * Minimum Size of emitting particles.
  84975. */
  84976. minSize: number;
  84977. /**
  84978. * Maximum Size of emitting particles.
  84979. */
  84980. maxSize: number;
  84981. /**
  84982. * Minimum scale of emitting particles on X axis.
  84983. */
  84984. minScaleX: number;
  84985. /**
  84986. * Maximum scale of emitting particles on X axis.
  84987. */
  84988. maxScaleX: number;
  84989. /**
  84990. * Minimum scale of emitting particles on Y axis.
  84991. */
  84992. minScaleY: number;
  84993. /**
  84994. * Maximum scale of emitting particles on Y axis.
  84995. */
  84996. maxScaleY: number;
  84997. /**
  84998. * Gets or sets the minimal initial rotation in radians.
  84999. */
  85000. minInitialRotation: number;
  85001. /**
  85002. * Gets or sets the maximal initial rotation in radians.
  85003. */
  85004. maxInitialRotation: number;
  85005. /**
  85006. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85007. */
  85008. minAngularSpeed: number;
  85009. /**
  85010. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85011. */
  85012. maxAngularSpeed: number;
  85013. /**
  85014. * The texture used to render each particle. (this can be a spritesheet)
  85015. */
  85016. particleTexture: Nullable<Texture>;
  85017. /**
  85018. * The layer mask we are rendering the particles through.
  85019. */
  85020. layerMask: number;
  85021. /**
  85022. * This can help using your own shader to render the particle system.
  85023. * The according effect will be created
  85024. */
  85025. customShader: any;
  85026. /**
  85027. * By default particle system starts as soon as they are created. This prevents the
  85028. * automatic start to happen and let you decide when to start emitting particles.
  85029. */
  85030. preventAutoStart: boolean;
  85031. private _noiseTexture;
  85032. /**
  85033. * Gets or sets a texture used to add random noise to particle positions
  85034. */
  85035. noiseTexture: Nullable<ProceduralTexture>;
  85036. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85037. noiseStrength: Vector3;
  85038. /**
  85039. * Callback triggered when the particle animation is ending.
  85040. */
  85041. onAnimationEnd: Nullable<() => void>;
  85042. /**
  85043. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  85044. */
  85045. blendMode: number;
  85046. /**
  85047. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  85048. * to override the particles.
  85049. */
  85050. forceDepthWrite: boolean;
  85051. /** 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 */
  85052. preWarmCycles: number;
  85053. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  85054. preWarmStepOffset: number;
  85055. /**
  85056. * 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)
  85057. */
  85058. spriteCellChangeSpeed: number;
  85059. /**
  85060. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85061. */
  85062. startSpriteCellID: number;
  85063. /**
  85064. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85065. */
  85066. endSpriteCellID: number;
  85067. /**
  85068. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85069. */
  85070. spriteCellWidth: number;
  85071. /**
  85072. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85073. */
  85074. spriteCellHeight: number;
  85075. /**
  85076. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85077. */
  85078. spriteRandomStartCell: boolean;
  85079. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85080. translationPivot: Vector2;
  85081. /** @hidden */
  85082. protected _isAnimationSheetEnabled: boolean;
  85083. /**
  85084. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85085. */
  85086. beginAnimationOnStart: boolean;
  85087. /**
  85088. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85089. */
  85090. beginAnimationFrom: number;
  85091. /**
  85092. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85093. */
  85094. beginAnimationTo: number;
  85095. /**
  85096. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85097. */
  85098. beginAnimationLoop: boolean;
  85099. /**
  85100. * Gets or sets a world offset applied to all particles
  85101. */
  85102. worldOffset: Vector3;
  85103. /**
  85104. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  85105. */
  85106. isAnimationSheetEnabled: boolean;
  85107. /**
  85108. * Get hosting scene
  85109. * @returns the scene
  85110. */
  85111. getScene(): Scene;
  85112. /**
  85113. * You can use gravity if you want to give an orientation to your particles.
  85114. */
  85115. gravity: Vector3;
  85116. protected _colorGradients: Nullable<Array<ColorGradient>>;
  85117. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  85118. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  85119. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  85120. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  85121. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  85122. protected _dragGradients: Nullable<Array<FactorGradient>>;
  85123. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  85124. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  85125. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  85126. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  85127. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  85128. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  85129. /**
  85130. * Defines the delay in milliseconds before starting the system (0 by default)
  85131. */
  85132. startDelay: number;
  85133. /**
  85134. * Gets the current list of drag gradients.
  85135. * You must use addDragGradient and removeDragGradient to udpate this list
  85136. * @returns the list of drag gradients
  85137. */
  85138. getDragGradients(): Nullable<Array<FactorGradient>>;
  85139. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85140. limitVelocityDamping: number;
  85141. /**
  85142. * Gets the current list of limit velocity gradients.
  85143. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85144. * @returns the list of limit velocity gradients
  85145. */
  85146. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85147. /**
  85148. * Gets the current list of color gradients.
  85149. * You must use addColorGradient and removeColorGradient to udpate this list
  85150. * @returns the list of color gradients
  85151. */
  85152. getColorGradients(): Nullable<Array<ColorGradient>>;
  85153. /**
  85154. * Gets the current list of size gradients.
  85155. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85156. * @returns the list of size gradients
  85157. */
  85158. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85159. /**
  85160. * Gets the current list of color remap gradients.
  85161. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85162. * @returns the list of color remap gradients
  85163. */
  85164. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85165. /**
  85166. * Gets the current list of alpha remap gradients.
  85167. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85168. * @returns the list of alpha remap gradients
  85169. */
  85170. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85171. /**
  85172. * Gets the current list of life time gradients.
  85173. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85174. * @returns the list of life time gradients
  85175. */
  85176. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85177. /**
  85178. * Gets the current list of angular speed gradients.
  85179. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85180. * @returns the list of angular speed gradients
  85181. */
  85182. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85183. /**
  85184. * Gets the current list of velocity gradients.
  85185. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85186. * @returns the list of velocity gradients
  85187. */
  85188. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85189. /**
  85190. * Gets the current list of start size gradients.
  85191. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85192. * @returns the list of start size gradients
  85193. */
  85194. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85195. /**
  85196. * Gets the current list of emit rate gradients.
  85197. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85198. * @returns the list of emit rate gradients
  85199. */
  85200. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85201. /**
  85202. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85203. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85204. */
  85205. direction1: Vector3;
  85206. /**
  85207. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85208. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85209. */
  85210. direction2: Vector3;
  85211. /**
  85212. * 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.
  85213. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85214. */
  85215. minEmitBox: Vector3;
  85216. /**
  85217. * 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.
  85218. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85219. */
  85220. maxEmitBox: Vector3;
  85221. /**
  85222. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85223. */
  85224. color1: Color4;
  85225. /**
  85226. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85227. */
  85228. color2: Color4;
  85229. /**
  85230. * Color the particle will have at the end of its lifetime
  85231. */
  85232. colorDead: Color4;
  85233. /**
  85234. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  85235. */
  85236. textureMask: Color4;
  85237. /**
  85238. * The particle emitter type defines the emitter used by the particle system.
  85239. * It can be for example box, sphere, or cone...
  85240. */
  85241. particleEmitterType: IParticleEmitterType;
  85242. /** @hidden */
  85243. _isSubEmitter: boolean;
  85244. /**
  85245. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85246. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85247. */
  85248. billboardMode: number;
  85249. protected _isBillboardBased: boolean;
  85250. /**
  85251. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85252. */
  85253. isBillboardBased: boolean;
  85254. /**
  85255. * The scene the particle system belongs to.
  85256. */
  85257. protected _scene: Scene;
  85258. /**
  85259. * Local cache of defines for image processing.
  85260. */
  85261. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  85262. /**
  85263. * Default configuration related to image processing available in the standard Material.
  85264. */
  85265. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  85266. /**
  85267. * Gets the image processing configuration used either in this material.
  85268. */
  85269. /**
  85270. * Sets the Default image processing configuration used either in the this material.
  85271. *
  85272. * If sets to null, the scene one is in use.
  85273. */
  85274. imageProcessingConfiguration: ImageProcessingConfiguration;
  85275. /**
  85276. * Attaches a new image processing configuration to the Standard Material.
  85277. * @param configuration
  85278. */
  85279. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  85280. /** @hidden */
  85281. protected _reset(): void;
  85282. /** @hidden */
  85283. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  85284. /**
  85285. * Instantiates a particle system.
  85286. * 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.
  85287. * @param name The name of the particle system
  85288. */
  85289. constructor(name: string);
  85290. /**
  85291. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85292. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85293. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85294. * @returns the emitter
  85295. */
  85296. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85297. /**
  85298. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85299. * @param radius The radius of the hemisphere to emit from
  85300. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85301. * @returns the emitter
  85302. */
  85303. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  85304. /**
  85305. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85306. * @param radius The radius of the sphere to emit from
  85307. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85308. * @returns the emitter
  85309. */
  85310. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  85311. /**
  85312. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85313. * @param radius The radius of the sphere to emit from
  85314. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85315. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85316. * @returns the emitter
  85317. */
  85318. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  85319. /**
  85320. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85321. * @param radius The radius of the emission cylinder
  85322. * @param height The height of the emission cylinder
  85323. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85324. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85325. * @returns the emitter
  85326. */
  85327. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  85328. /**
  85329. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85330. * @param radius The radius of the cylinder to emit from
  85331. * @param height The height of the emission cylinder
  85332. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85333. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85334. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85335. * @returns the emitter
  85336. */
  85337. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  85338. /**
  85339. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85340. * @param radius The radius of the cone to emit from
  85341. * @param angle The base angle of the cone
  85342. * @returns the emitter
  85343. */
  85344. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  85345. /**
  85346. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85347. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85348. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85349. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85350. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85351. * @returns the emitter
  85352. */
  85353. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85354. }
  85355. }
  85356. declare module BABYLON {
  85357. /**
  85358. * Type of sub emitter
  85359. */
  85360. export enum SubEmitterType {
  85361. /**
  85362. * Attached to the particle over it's lifetime
  85363. */
  85364. ATTACHED = 0,
  85365. /**
  85366. * Created when the particle dies
  85367. */
  85368. END = 1
  85369. }
  85370. /**
  85371. * Sub emitter class used to emit particles from an existing particle
  85372. */
  85373. export class SubEmitter {
  85374. /**
  85375. * the particle system to be used by the sub emitter
  85376. */
  85377. particleSystem: ParticleSystem;
  85378. /**
  85379. * Type of the submitter (Default: END)
  85380. */
  85381. type: SubEmitterType;
  85382. /**
  85383. * 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)
  85384. * Note: This only is supported when using an emitter of type Mesh
  85385. */
  85386. inheritDirection: boolean;
  85387. /**
  85388. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85389. */
  85390. inheritedVelocityAmount: number;
  85391. /**
  85392. * Creates a sub emitter
  85393. * @param particleSystem the particle system to be used by the sub emitter
  85394. */
  85395. constructor(
  85396. /**
  85397. * the particle system to be used by the sub emitter
  85398. */
  85399. particleSystem: ParticleSystem);
  85400. /**
  85401. * Clones the sub emitter
  85402. * @returns the cloned sub emitter
  85403. */
  85404. clone(): SubEmitter;
  85405. /**
  85406. * Serialize current object to a JSON object
  85407. * @returns the serialized object
  85408. */
  85409. serialize(): any;
  85410. /** @hidden */
  85411. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85412. /**
  85413. * Creates a new SubEmitter from a serialized JSON version
  85414. * @param serializationObject defines the JSON object to read from
  85415. * @param scene defines the hosting scene
  85416. * @param rootUrl defines the rootUrl for data loading
  85417. * @returns a new SubEmitter
  85418. */
  85419. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  85420. /** Release associated resources */
  85421. dispose(): void;
  85422. }
  85423. }
  85424. declare module BABYLON {
  85425. /** @hidden */
  85426. export var clipPlaneFragmentDeclaration: {
  85427. name: string;
  85428. shader: string;
  85429. };
  85430. }
  85431. declare module BABYLON {
  85432. /** @hidden */
  85433. export var imageProcessingDeclaration: {
  85434. name: string;
  85435. shader: string;
  85436. };
  85437. }
  85438. declare module BABYLON {
  85439. /** @hidden */
  85440. export var imageProcessingFunctions: {
  85441. name: string;
  85442. shader: string;
  85443. };
  85444. }
  85445. declare module BABYLON {
  85446. /** @hidden */
  85447. export var clipPlaneFragment: {
  85448. name: string;
  85449. shader: string;
  85450. };
  85451. }
  85452. declare module BABYLON {
  85453. /** @hidden */
  85454. export var particlesPixelShader: {
  85455. name: string;
  85456. shader: string;
  85457. };
  85458. }
  85459. declare module BABYLON {
  85460. /** @hidden */
  85461. export var clipPlaneVertexDeclaration: {
  85462. name: string;
  85463. shader: string;
  85464. };
  85465. }
  85466. declare module BABYLON {
  85467. /** @hidden */
  85468. export var clipPlaneVertex: {
  85469. name: string;
  85470. shader: string;
  85471. };
  85472. }
  85473. declare module BABYLON {
  85474. /** @hidden */
  85475. export var particlesVertexShader: {
  85476. name: string;
  85477. shader: string;
  85478. };
  85479. }
  85480. declare module BABYLON {
  85481. /**
  85482. * This represents a particle system in Babylon.
  85483. * 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.
  85484. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85485. * @example https://doc.babylonjs.com/babylon101/particles
  85486. */
  85487. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  85488. /**
  85489. * Billboard mode will only apply to Y axis
  85490. */
  85491. static readonly BILLBOARDMODE_Y: number;
  85492. /**
  85493. * Billboard mode will apply to all axes
  85494. */
  85495. static readonly BILLBOARDMODE_ALL: number;
  85496. /**
  85497. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85498. */
  85499. static readonly BILLBOARDMODE_STRETCHED: number;
  85500. /**
  85501. * This function can be defined to provide custom update for active particles.
  85502. * This function will be called instead of regular update (age, position, color, etc.).
  85503. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  85504. */
  85505. updateFunction: (particles: Particle[]) => void;
  85506. private _emitterWorldMatrix;
  85507. /**
  85508. * This function can be defined to specify initial direction for every new particle.
  85509. * It by default use the emitterType defined function
  85510. */
  85511. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  85512. /**
  85513. * This function can be defined to specify initial position for every new particle.
  85514. * It by default use the emitterType defined function
  85515. */
  85516. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  85517. /**
  85518. * @hidden
  85519. */
  85520. _inheritedVelocityOffset: Vector3;
  85521. /**
  85522. * An event triggered when the system is disposed
  85523. */
  85524. onDisposeObservable: Observable<ParticleSystem>;
  85525. private _onDisposeObserver;
  85526. /**
  85527. * Sets a callback that will be triggered when the system is disposed
  85528. */
  85529. onDispose: () => void;
  85530. private _particles;
  85531. private _epsilon;
  85532. private _capacity;
  85533. private _stockParticles;
  85534. private _newPartsExcess;
  85535. private _vertexData;
  85536. private _vertexBuffer;
  85537. private _vertexBuffers;
  85538. private _spriteBuffer;
  85539. private _indexBuffer;
  85540. private _effect;
  85541. private _customEffect;
  85542. private _cachedDefines;
  85543. private _scaledColorStep;
  85544. private _colorDiff;
  85545. private _scaledDirection;
  85546. private _scaledGravity;
  85547. private _currentRenderId;
  85548. private _alive;
  85549. private _useInstancing;
  85550. private _started;
  85551. private _stopped;
  85552. private _actualFrame;
  85553. private _scaledUpdateSpeed;
  85554. private _vertexBufferSize;
  85555. /** @hidden */
  85556. _currentEmitRateGradient: Nullable<FactorGradient>;
  85557. /** @hidden */
  85558. _currentEmitRate1: number;
  85559. /** @hidden */
  85560. _currentEmitRate2: number;
  85561. /** @hidden */
  85562. _currentStartSizeGradient: Nullable<FactorGradient>;
  85563. /** @hidden */
  85564. _currentStartSize1: number;
  85565. /** @hidden */
  85566. _currentStartSize2: number;
  85567. private readonly _rawTextureWidth;
  85568. private _rampGradientsTexture;
  85569. private _useRampGradients;
  85570. /** Gets or sets a boolean indicating that ramp gradients must be used
  85571. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85572. */
  85573. useRampGradients: boolean;
  85574. /**
  85575. * 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.
  85576. * 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: [])
  85577. */
  85578. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85579. private _subEmitters;
  85580. /**
  85581. * @hidden
  85582. * If the particle systems emitter should be disposed when the particle system is disposed
  85583. */
  85584. _disposeEmitterOnDispose: boolean;
  85585. /**
  85586. * The current active Sub-systems, this property is used by the root particle system only.
  85587. */
  85588. activeSubSystems: Array<ParticleSystem>;
  85589. private _rootParticleSystem;
  85590. /**
  85591. * Gets the current list of active particles
  85592. */
  85593. readonly particles: Particle[];
  85594. /**
  85595. * Returns the string "ParticleSystem"
  85596. * @returns a string containing the class name
  85597. */
  85598. getClassName(): string;
  85599. /**
  85600. * Instantiates a particle system.
  85601. * 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.
  85602. * @param name The name of the particle system
  85603. * @param capacity The max number of particles alive at the same time
  85604. * @param scene The scene the particle system belongs to
  85605. * @param customEffect a custom effect used to change the way particles are rendered by default
  85606. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  85607. * @param epsilon Offset used to render the particles
  85608. */
  85609. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  85610. private _addFactorGradient;
  85611. private _removeFactorGradient;
  85612. /**
  85613. * Adds a new life time gradient
  85614. * @param gradient defines the gradient to use (between 0 and 1)
  85615. * @param factor defines the life time factor to affect to the specified gradient
  85616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85617. * @returns the current particle system
  85618. */
  85619. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85620. /**
  85621. * Remove a specific life time gradient
  85622. * @param gradient defines the gradient to remove
  85623. * @returns the current particle system
  85624. */
  85625. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85626. /**
  85627. * Adds a new size gradient
  85628. * @param gradient defines the gradient to use (between 0 and 1)
  85629. * @param factor defines the size factor to affect to the specified gradient
  85630. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85631. * @returns the current particle system
  85632. */
  85633. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85634. /**
  85635. * Remove a specific size gradient
  85636. * @param gradient defines the gradient to remove
  85637. * @returns the current particle system
  85638. */
  85639. removeSizeGradient(gradient: number): IParticleSystem;
  85640. /**
  85641. * Adds a new color remap gradient
  85642. * @param gradient defines the gradient to use (between 0 and 1)
  85643. * @param min defines the color remap minimal range
  85644. * @param max defines the color remap maximal range
  85645. * @returns the current particle system
  85646. */
  85647. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85648. /**
  85649. * Remove a specific color remap gradient
  85650. * @param gradient defines the gradient to remove
  85651. * @returns the current particle system
  85652. */
  85653. removeColorRemapGradient(gradient: number): IParticleSystem;
  85654. /**
  85655. * Adds a new alpha remap gradient
  85656. * @param gradient defines the gradient to use (between 0 and 1)
  85657. * @param min defines the alpha remap minimal range
  85658. * @param max defines the alpha remap maximal range
  85659. * @returns the current particle system
  85660. */
  85661. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85662. /**
  85663. * Remove a specific alpha remap gradient
  85664. * @param gradient defines the gradient to remove
  85665. * @returns the current particle system
  85666. */
  85667. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85668. /**
  85669. * Adds a new angular speed gradient
  85670. * @param gradient defines the gradient to use (between 0 and 1)
  85671. * @param factor defines the angular speed to affect to the specified gradient
  85672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85673. * @returns the current particle system
  85674. */
  85675. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85676. /**
  85677. * Remove a specific angular speed gradient
  85678. * @param gradient defines the gradient to remove
  85679. * @returns the current particle system
  85680. */
  85681. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85682. /**
  85683. * Adds a new velocity gradient
  85684. * @param gradient defines the gradient to use (between 0 and 1)
  85685. * @param factor defines the velocity to affect to the specified gradient
  85686. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85687. * @returns the current particle system
  85688. */
  85689. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85690. /**
  85691. * Remove a specific velocity gradient
  85692. * @param gradient defines the gradient to remove
  85693. * @returns the current particle system
  85694. */
  85695. removeVelocityGradient(gradient: number): IParticleSystem;
  85696. /**
  85697. * Adds a new limit velocity gradient
  85698. * @param gradient defines the gradient to use (between 0 and 1)
  85699. * @param factor defines the limit velocity value to affect to the specified gradient
  85700. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85701. * @returns the current particle system
  85702. */
  85703. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85704. /**
  85705. * Remove a specific limit velocity gradient
  85706. * @param gradient defines the gradient to remove
  85707. * @returns the current particle system
  85708. */
  85709. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85710. /**
  85711. * Adds a new drag gradient
  85712. * @param gradient defines the gradient to use (between 0 and 1)
  85713. * @param factor defines the drag value to affect to the specified gradient
  85714. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85715. * @returns the current particle system
  85716. */
  85717. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85718. /**
  85719. * Remove a specific drag gradient
  85720. * @param gradient defines the gradient to remove
  85721. * @returns the current particle system
  85722. */
  85723. removeDragGradient(gradient: number): IParticleSystem;
  85724. /**
  85725. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85726. * @param gradient defines the gradient to use (between 0 and 1)
  85727. * @param factor defines the emit rate value to affect to the specified gradient
  85728. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85729. * @returns the current particle system
  85730. */
  85731. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85732. /**
  85733. * Remove a specific emit rate gradient
  85734. * @param gradient defines the gradient to remove
  85735. * @returns the current particle system
  85736. */
  85737. removeEmitRateGradient(gradient: number): IParticleSystem;
  85738. /**
  85739. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85740. * @param gradient defines the gradient to use (between 0 and 1)
  85741. * @param factor defines the start size value to affect to the specified gradient
  85742. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85743. * @returns the current particle system
  85744. */
  85745. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85746. /**
  85747. * Remove a specific start size gradient
  85748. * @param gradient defines the gradient to remove
  85749. * @returns the current particle system
  85750. */
  85751. removeStartSizeGradient(gradient: number): IParticleSystem;
  85752. private _createRampGradientTexture;
  85753. /**
  85754. * Gets the current list of ramp gradients.
  85755. * You must use addRampGradient and removeRampGradient to udpate this list
  85756. * @returns the list of ramp gradients
  85757. */
  85758. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85759. /**
  85760. * Adds a new ramp gradient used to remap particle colors
  85761. * @param gradient defines the gradient to use (between 0 and 1)
  85762. * @param color defines the color to affect to the specified gradient
  85763. * @returns the current particle system
  85764. */
  85765. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85766. /**
  85767. * Remove a specific ramp gradient
  85768. * @param gradient defines the gradient to remove
  85769. * @returns the current particle system
  85770. */
  85771. removeRampGradient(gradient: number): ParticleSystem;
  85772. /**
  85773. * Adds a new color gradient
  85774. * @param gradient defines the gradient to use (between 0 and 1)
  85775. * @param color1 defines the color to affect to the specified gradient
  85776. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85777. * @returns this particle system
  85778. */
  85779. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85780. /**
  85781. * Remove a specific color gradient
  85782. * @param gradient defines the gradient to remove
  85783. * @returns this particle system
  85784. */
  85785. removeColorGradient(gradient: number): IParticleSystem;
  85786. private _fetchR;
  85787. protected _reset(): void;
  85788. private _resetEffect;
  85789. private _createVertexBuffers;
  85790. private _createIndexBuffer;
  85791. /**
  85792. * Gets the maximum number of particles active at the same time.
  85793. * @returns The max number of active particles.
  85794. */
  85795. getCapacity(): number;
  85796. /**
  85797. * Gets whether there are still active particles in the system.
  85798. * @returns True if it is alive, otherwise false.
  85799. */
  85800. isAlive(): boolean;
  85801. /**
  85802. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85803. * @returns True if it has been started, otherwise false.
  85804. */
  85805. isStarted(): boolean;
  85806. private _prepareSubEmitterInternalArray;
  85807. /**
  85808. * Starts the particle system and begins to emit
  85809. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85810. */
  85811. start(delay?: number): void;
  85812. /**
  85813. * Stops the particle system.
  85814. * @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.
  85815. */
  85816. stop(stopSubEmitters?: boolean): void;
  85817. /**
  85818. * Remove all active particles
  85819. */
  85820. reset(): void;
  85821. /**
  85822. * @hidden (for internal use only)
  85823. */
  85824. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85825. /**
  85826. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85827. * Its lifetime will start back at 0.
  85828. */
  85829. recycleParticle: (particle: Particle) => void;
  85830. private _stopSubEmitters;
  85831. private _createParticle;
  85832. private _removeFromRoot;
  85833. private _emitFromParticle;
  85834. private _update;
  85835. /** @hidden */
  85836. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85837. /** @hidden */
  85838. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85839. /** @hidden */
  85840. private _getEffect;
  85841. /**
  85842. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85843. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85844. */
  85845. animate(preWarmOnly?: boolean): void;
  85846. private _appendParticleVertices;
  85847. /**
  85848. * Rebuilds the particle system.
  85849. */
  85850. rebuild(): void;
  85851. /**
  85852. * Is this system ready to be used/rendered
  85853. * @return true if the system is ready
  85854. */
  85855. isReady(): boolean;
  85856. private _render;
  85857. /**
  85858. * Renders the particle system in its current state.
  85859. * @returns the current number of particles
  85860. */
  85861. render(): number;
  85862. /**
  85863. * Disposes the particle system and free the associated resources
  85864. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85865. */
  85866. dispose(disposeTexture?: boolean): void;
  85867. /**
  85868. * Clones the particle system.
  85869. * @param name The name of the cloned object
  85870. * @param newEmitter The new emitter to use
  85871. * @returns the cloned particle system
  85872. */
  85873. clone(name: string, newEmitter: any): ParticleSystem;
  85874. /**
  85875. * Serializes the particle system to a JSON object.
  85876. * @returns the JSON object
  85877. */
  85878. serialize(): any;
  85879. /** @hidden */
  85880. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85881. /** @hidden */
  85882. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85883. /**
  85884. * Parses a JSON object to create a particle system.
  85885. * @param parsedParticleSystem The JSON object to parse
  85886. * @param scene The scene to create the particle system in
  85887. * @param rootUrl The root url to use to load external dependencies like texture
  85888. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85889. * @returns the Parsed particle system
  85890. */
  85891. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85892. }
  85893. }
  85894. declare module BABYLON {
  85895. /**
  85896. * A particle represents one of the element emitted by a particle system.
  85897. * This is mainly define by its coordinates, direction, velocity and age.
  85898. */
  85899. export class Particle {
  85900. /**
  85901. * The particle system the particle belongs to.
  85902. */
  85903. particleSystem: ParticleSystem;
  85904. private static _Count;
  85905. /**
  85906. * Unique ID of the particle
  85907. */
  85908. id: number;
  85909. /**
  85910. * The world position of the particle in the scene.
  85911. */
  85912. position: Vector3;
  85913. /**
  85914. * The world direction of the particle in the scene.
  85915. */
  85916. direction: Vector3;
  85917. /**
  85918. * The color of the particle.
  85919. */
  85920. color: Color4;
  85921. /**
  85922. * The color change of the particle per step.
  85923. */
  85924. colorStep: Color4;
  85925. /**
  85926. * Defines how long will the life of the particle be.
  85927. */
  85928. lifeTime: number;
  85929. /**
  85930. * The current age of the particle.
  85931. */
  85932. age: number;
  85933. /**
  85934. * The current size of the particle.
  85935. */
  85936. size: number;
  85937. /**
  85938. * The current scale of the particle.
  85939. */
  85940. scale: Vector2;
  85941. /**
  85942. * The current angle of the particle.
  85943. */
  85944. angle: number;
  85945. /**
  85946. * Defines how fast is the angle changing.
  85947. */
  85948. angularSpeed: number;
  85949. /**
  85950. * Defines the cell index used by the particle to be rendered from a sprite.
  85951. */
  85952. cellIndex: number;
  85953. /**
  85954. * The information required to support color remapping
  85955. */
  85956. remapData: Vector4;
  85957. /** @hidden */
  85958. _randomCellOffset?: number;
  85959. /** @hidden */
  85960. _initialDirection: Nullable<Vector3>;
  85961. /** @hidden */
  85962. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85963. /** @hidden */
  85964. _initialStartSpriteCellID: number;
  85965. /** @hidden */
  85966. _initialEndSpriteCellID: number;
  85967. /** @hidden */
  85968. _currentColorGradient: Nullable<ColorGradient>;
  85969. /** @hidden */
  85970. _currentColor1: Color4;
  85971. /** @hidden */
  85972. _currentColor2: Color4;
  85973. /** @hidden */
  85974. _currentSizeGradient: Nullable<FactorGradient>;
  85975. /** @hidden */
  85976. _currentSize1: number;
  85977. /** @hidden */
  85978. _currentSize2: number;
  85979. /** @hidden */
  85980. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85981. /** @hidden */
  85982. _currentAngularSpeed1: number;
  85983. /** @hidden */
  85984. _currentAngularSpeed2: number;
  85985. /** @hidden */
  85986. _currentVelocityGradient: Nullable<FactorGradient>;
  85987. /** @hidden */
  85988. _currentVelocity1: number;
  85989. /** @hidden */
  85990. _currentVelocity2: number;
  85991. /** @hidden */
  85992. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85993. /** @hidden */
  85994. _currentLimitVelocity1: number;
  85995. /** @hidden */
  85996. _currentLimitVelocity2: number;
  85997. /** @hidden */
  85998. _currentDragGradient: Nullable<FactorGradient>;
  85999. /** @hidden */
  86000. _currentDrag1: number;
  86001. /** @hidden */
  86002. _currentDrag2: number;
  86003. /** @hidden */
  86004. _randomNoiseCoordinates1: Vector3;
  86005. /** @hidden */
  86006. _randomNoiseCoordinates2: Vector3;
  86007. /**
  86008. * Creates a new instance Particle
  86009. * @param particleSystem the particle system the particle belongs to
  86010. */
  86011. constructor(
  86012. /**
  86013. * The particle system the particle belongs to.
  86014. */
  86015. particleSystem: ParticleSystem);
  86016. private updateCellInfoFromSystem;
  86017. /**
  86018. * Defines how the sprite cell index is updated for the particle
  86019. */
  86020. updateCellIndex(): void;
  86021. /** @hidden */
  86022. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  86023. /** @hidden */
  86024. _inheritParticleInfoToSubEmitters(): void;
  86025. /** @hidden */
  86026. _reset(): void;
  86027. /**
  86028. * Copy the properties of particle to another one.
  86029. * @param other the particle to copy the information to.
  86030. */
  86031. copyTo(other: Particle): void;
  86032. }
  86033. }
  86034. declare module BABYLON {
  86035. /**
  86036. * Particle emitter represents a volume emitting particles.
  86037. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  86038. */
  86039. export interface IParticleEmitterType {
  86040. /**
  86041. * Called by the particle System when the direction is computed for the created particle.
  86042. * @param worldMatrix is the world matrix of the particle system
  86043. * @param directionToUpdate is the direction vector to update with the result
  86044. * @param particle is the particle we are computed the direction for
  86045. */
  86046. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86047. /**
  86048. * Called by the particle System when the position is computed for the created particle.
  86049. * @param worldMatrix is the world matrix of the particle system
  86050. * @param positionToUpdate is the position vector to update with the result
  86051. * @param particle is the particle we are computed the position for
  86052. */
  86053. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86054. /**
  86055. * Clones the current emitter and returns a copy of it
  86056. * @returns the new emitter
  86057. */
  86058. clone(): IParticleEmitterType;
  86059. /**
  86060. * Called by the GPUParticleSystem to setup the update shader
  86061. * @param effect defines the update shader
  86062. */
  86063. applyToShader(effect: Effect): void;
  86064. /**
  86065. * Returns a string to use to update the GPU particles update shader
  86066. * @returns the effect defines string
  86067. */
  86068. getEffectDefines(): string;
  86069. /**
  86070. * Returns a string representing the class name
  86071. * @returns a string containing the class name
  86072. */
  86073. getClassName(): string;
  86074. /**
  86075. * Serializes the particle system to a JSON object.
  86076. * @returns the JSON object
  86077. */
  86078. serialize(): any;
  86079. /**
  86080. * Parse properties from a JSON object
  86081. * @param serializationObject defines the JSON object
  86082. */
  86083. parse(serializationObject: any): void;
  86084. }
  86085. }
  86086. declare module BABYLON {
  86087. /**
  86088. * Particle emitter emitting particles from the inside of a box.
  86089. * It emits the particles randomly between 2 given directions.
  86090. */
  86091. export class BoxParticleEmitter implements IParticleEmitterType {
  86092. /**
  86093. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86094. */
  86095. direction1: Vector3;
  86096. /**
  86097. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86098. */
  86099. direction2: Vector3;
  86100. /**
  86101. * 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.
  86102. */
  86103. minEmitBox: Vector3;
  86104. /**
  86105. * 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.
  86106. */
  86107. maxEmitBox: Vector3;
  86108. /**
  86109. * Creates a new instance BoxParticleEmitter
  86110. */
  86111. constructor();
  86112. /**
  86113. * Called by the particle System when the direction is computed for the created particle.
  86114. * @param worldMatrix is the world matrix of the particle system
  86115. * @param directionToUpdate is the direction vector to update with the result
  86116. * @param particle is the particle we are computed the direction for
  86117. */
  86118. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86119. /**
  86120. * Called by the particle System when the position is computed for the created particle.
  86121. * @param worldMatrix is the world matrix of the particle system
  86122. * @param positionToUpdate is the position vector to update with the result
  86123. * @param particle is the particle we are computed the position for
  86124. */
  86125. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86126. /**
  86127. * Clones the current emitter and returns a copy of it
  86128. * @returns the new emitter
  86129. */
  86130. clone(): BoxParticleEmitter;
  86131. /**
  86132. * Called by the GPUParticleSystem to setup the update shader
  86133. * @param effect defines the update shader
  86134. */
  86135. applyToShader(effect: Effect): void;
  86136. /**
  86137. * Returns a string to use to update the GPU particles update shader
  86138. * @returns a string containng the defines string
  86139. */
  86140. getEffectDefines(): string;
  86141. /**
  86142. * Returns the string "BoxParticleEmitter"
  86143. * @returns a string containing the class name
  86144. */
  86145. getClassName(): string;
  86146. /**
  86147. * Serializes the particle system to a JSON object.
  86148. * @returns the JSON object
  86149. */
  86150. serialize(): any;
  86151. /**
  86152. * Parse properties from a JSON object
  86153. * @param serializationObject defines the JSON object
  86154. */
  86155. parse(serializationObject: any): void;
  86156. }
  86157. }
  86158. declare module BABYLON {
  86159. /**
  86160. * Particle emitter emitting particles from the inside of a cone.
  86161. * It emits the particles alongside the cone volume from the base to the particle.
  86162. * The emission direction might be randomized.
  86163. */
  86164. export class ConeParticleEmitter implements IParticleEmitterType {
  86165. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86166. directionRandomizer: number;
  86167. private _radius;
  86168. private _angle;
  86169. private _height;
  86170. /**
  86171. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  86172. */
  86173. radiusRange: number;
  86174. /**
  86175. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  86176. */
  86177. heightRange: number;
  86178. /**
  86179. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  86180. */
  86181. emitFromSpawnPointOnly: boolean;
  86182. /**
  86183. * Gets or sets the radius of the emission cone
  86184. */
  86185. radius: number;
  86186. /**
  86187. * Gets or sets the angle of the emission cone
  86188. */
  86189. angle: number;
  86190. private _buildHeight;
  86191. /**
  86192. * Creates a new instance ConeParticleEmitter
  86193. * @param radius the radius of the emission cone (1 by default)
  86194. * @param angle the cone base angle (PI by default)
  86195. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  86196. */
  86197. constructor(radius?: number, angle?: number,
  86198. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86199. directionRandomizer?: number);
  86200. /**
  86201. * Called by the particle System when the direction is computed for the created particle.
  86202. * @param worldMatrix is the world matrix of the particle system
  86203. * @param directionToUpdate is the direction vector to update with the result
  86204. * @param particle is the particle we are computed the direction for
  86205. */
  86206. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86207. /**
  86208. * Called by the particle System when the position is computed for the created particle.
  86209. * @param worldMatrix is the world matrix of the particle system
  86210. * @param positionToUpdate is the position vector to update with the result
  86211. * @param particle is the particle we are computed the position for
  86212. */
  86213. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86214. /**
  86215. * Clones the current emitter and returns a copy of it
  86216. * @returns the new emitter
  86217. */
  86218. clone(): ConeParticleEmitter;
  86219. /**
  86220. * Called by the GPUParticleSystem to setup the update shader
  86221. * @param effect defines the update shader
  86222. */
  86223. applyToShader(effect: Effect): void;
  86224. /**
  86225. * Returns a string to use to update the GPU particles update shader
  86226. * @returns a string containng the defines string
  86227. */
  86228. getEffectDefines(): string;
  86229. /**
  86230. * Returns the string "ConeParticleEmitter"
  86231. * @returns a string containing the class name
  86232. */
  86233. getClassName(): string;
  86234. /**
  86235. * Serializes the particle system to a JSON object.
  86236. * @returns the JSON object
  86237. */
  86238. serialize(): any;
  86239. /**
  86240. * Parse properties from a JSON object
  86241. * @param serializationObject defines the JSON object
  86242. */
  86243. parse(serializationObject: any): void;
  86244. }
  86245. }
  86246. declare module BABYLON {
  86247. /**
  86248. * Particle emitter emitting particles from the inside of a cylinder.
  86249. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  86250. */
  86251. export class CylinderParticleEmitter implements IParticleEmitterType {
  86252. /**
  86253. * The radius of the emission cylinder.
  86254. */
  86255. radius: number;
  86256. /**
  86257. * The height of the emission cylinder.
  86258. */
  86259. height: number;
  86260. /**
  86261. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86262. */
  86263. radiusRange: number;
  86264. /**
  86265. * How much to randomize the particle direction [0-1].
  86266. */
  86267. directionRandomizer: number;
  86268. /**
  86269. * Creates a new instance CylinderParticleEmitter
  86270. * @param radius the radius of the emission cylinder (1 by default)
  86271. * @param height the height of the emission cylinder (1 by default)
  86272. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86273. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86274. */
  86275. constructor(
  86276. /**
  86277. * The radius of the emission cylinder.
  86278. */
  86279. radius?: number,
  86280. /**
  86281. * The height of the emission cylinder.
  86282. */
  86283. height?: 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. * Called by the particle System when the direction is computed for the created particle.
  86294. * @param worldMatrix is the world matrix of the particle system
  86295. * @param directionToUpdate is the direction vector to update with the result
  86296. * @param particle is the particle we are computed the direction for
  86297. */
  86298. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86299. /**
  86300. * Called by the particle System when the position is computed for the created particle.
  86301. * @param worldMatrix is the world matrix of the particle system
  86302. * @param positionToUpdate is the position vector to update with the result
  86303. * @param particle is the particle we are computed the position for
  86304. */
  86305. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86306. /**
  86307. * Clones the current emitter and returns a copy of it
  86308. * @returns the new emitter
  86309. */
  86310. clone(): CylinderParticleEmitter;
  86311. /**
  86312. * Called by the GPUParticleSystem to setup the update shader
  86313. * @param effect defines the update shader
  86314. */
  86315. applyToShader(effect: Effect): void;
  86316. /**
  86317. * Returns a string to use to update the GPU particles update shader
  86318. * @returns a string containng the defines string
  86319. */
  86320. getEffectDefines(): string;
  86321. /**
  86322. * Returns the string "CylinderParticleEmitter"
  86323. * @returns a string containing the class name
  86324. */
  86325. getClassName(): string;
  86326. /**
  86327. * Serializes the particle system to a JSON object.
  86328. * @returns the JSON object
  86329. */
  86330. serialize(): any;
  86331. /**
  86332. * Parse properties from a JSON object
  86333. * @param serializationObject defines the JSON object
  86334. */
  86335. parse(serializationObject: any): void;
  86336. }
  86337. /**
  86338. * Particle emitter emitting particles from the inside of a cylinder.
  86339. * It emits the particles randomly between two vectors.
  86340. */
  86341. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  86342. /**
  86343. * The min limit of the emission direction.
  86344. */
  86345. direction1: Vector3;
  86346. /**
  86347. * The max limit of the emission direction.
  86348. */
  86349. direction2: Vector3;
  86350. /**
  86351. * Creates a new instance CylinderDirectedParticleEmitter
  86352. * @param radius the radius of the emission cylinder (1 by default)
  86353. * @param height the height of the emission cylinder (1 by default)
  86354. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86355. * @param direction1 the min limit of the emission direction (up vector by default)
  86356. * @param direction2 the max limit of the emission direction (up vector by default)
  86357. */
  86358. constructor(radius?: number, height?: number, radiusRange?: number,
  86359. /**
  86360. * The min limit of the emission direction.
  86361. */
  86362. direction1?: Vector3,
  86363. /**
  86364. * The max limit of the emission direction.
  86365. */
  86366. direction2?: Vector3);
  86367. /**
  86368. * Called by the particle System when the direction is computed for the created particle.
  86369. * @param worldMatrix is the world matrix of the particle system
  86370. * @param directionToUpdate is the direction vector to update with the result
  86371. * @param particle is the particle we are computed the direction for
  86372. */
  86373. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86374. /**
  86375. * Clones the current emitter and returns a copy of it
  86376. * @returns the new emitter
  86377. */
  86378. clone(): CylinderDirectedParticleEmitter;
  86379. /**
  86380. * Called by the GPUParticleSystem to setup the update shader
  86381. * @param effect defines the update shader
  86382. */
  86383. applyToShader(effect: Effect): void;
  86384. /**
  86385. * Returns a string to use to update the GPU particles update shader
  86386. * @returns a string containng the defines string
  86387. */
  86388. getEffectDefines(): string;
  86389. /**
  86390. * Returns the string "CylinderDirectedParticleEmitter"
  86391. * @returns a string containing the class name
  86392. */
  86393. getClassName(): string;
  86394. /**
  86395. * Serializes the particle system to a JSON object.
  86396. * @returns the JSON object
  86397. */
  86398. serialize(): any;
  86399. /**
  86400. * Parse properties from a JSON object
  86401. * @param serializationObject defines the JSON object
  86402. */
  86403. parse(serializationObject: any): void;
  86404. }
  86405. }
  86406. declare module BABYLON {
  86407. /**
  86408. * Particle emitter emitting particles from the inside of a hemisphere.
  86409. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86410. */
  86411. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86412. /**
  86413. * The radius of the emission hemisphere.
  86414. */
  86415. radius: number;
  86416. /**
  86417. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86418. */
  86419. radiusRange: number;
  86420. /**
  86421. * How much to randomize the particle direction [0-1].
  86422. */
  86423. directionRandomizer: number;
  86424. /**
  86425. * Creates a new instance HemisphericParticleEmitter
  86426. * @param radius the radius of the emission hemisphere (1 by default)
  86427. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86428. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86429. */
  86430. constructor(
  86431. /**
  86432. * The radius of the emission hemisphere.
  86433. */
  86434. radius?: number,
  86435. /**
  86436. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86437. */
  86438. radiusRange?: number,
  86439. /**
  86440. * How much to randomize the particle direction [0-1].
  86441. */
  86442. directionRandomizer?: number);
  86443. /**
  86444. * Called by the particle System when the direction is computed for the created particle.
  86445. * @param worldMatrix is the world matrix of the particle system
  86446. * @param directionToUpdate is the direction vector to update with the result
  86447. * @param particle is the particle we are computed the direction for
  86448. */
  86449. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86450. /**
  86451. * Called by the particle System when the position is computed for the created particle.
  86452. * @param worldMatrix is the world matrix of the particle system
  86453. * @param positionToUpdate is the position vector to update with the result
  86454. * @param particle is the particle we are computed the position for
  86455. */
  86456. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86457. /**
  86458. * Clones the current emitter and returns a copy of it
  86459. * @returns the new emitter
  86460. */
  86461. clone(): HemisphericParticleEmitter;
  86462. /**
  86463. * Called by the GPUParticleSystem to setup the update shader
  86464. * @param effect defines the update shader
  86465. */
  86466. applyToShader(effect: Effect): void;
  86467. /**
  86468. * Returns a string to use to update the GPU particles update shader
  86469. * @returns a string containng the defines string
  86470. */
  86471. getEffectDefines(): string;
  86472. /**
  86473. * Returns the string "HemisphericParticleEmitter"
  86474. * @returns a string containing the class name
  86475. */
  86476. getClassName(): string;
  86477. /**
  86478. * Serializes the particle system to a JSON object.
  86479. * @returns the JSON object
  86480. */
  86481. serialize(): any;
  86482. /**
  86483. * Parse properties from a JSON object
  86484. * @param serializationObject defines the JSON object
  86485. */
  86486. parse(serializationObject: any): void;
  86487. }
  86488. }
  86489. declare module BABYLON {
  86490. /**
  86491. * Particle emitter emitting particles from a point.
  86492. * It emits the particles randomly between 2 given directions.
  86493. */
  86494. export class PointParticleEmitter implements IParticleEmitterType {
  86495. /**
  86496. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86497. */
  86498. direction1: Vector3;
  86499. /**
  86500. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86501. */
  86502. direction2: Vector3;
  86503. /**
  86504. * Creates a new instance PointParticleEmitter
  86505. */
  86506. constructor();
  86507. /**
  86508. * Called by the particle System when the direction is computed for the created particle.
  86509. * @param worldMatrix is the world matrix of the particle system
  86510. * @param directionToUpdate is the direction vector to update with the result
  86511. * @param particle is the particle we are computed the direction for
  86512. */
  86513. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86514. /**
  86515. * Called by the particle System when the position is computed for the created particle.
  86516. * @param worldMatrix is the world matrix of the particle system
  86517. * @param positionToUpdate is the position vector to update with the result
  86518. * @param particle is the particle we are computed the position for
  86519. */
  86520. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86521. /**
  86522. * Clones the current emitter and returns a copy of it
  86523. * @returns the new emitter
  86524. */
  86525. clone(): PointParticleEmitter;
  86526. /**
  86527. * Called by the GPUParticleSystem to setup the update shader
  86528. * @param effect defines the update shader
  86529. */
  86530. applyToShader(effect: Effect): void;
  86531. /**
  86532. * Returns a string to use to update the GPU particles update shader
  86533. * @returns a string containng the defines string
  86534. */
  86535. getEffectDefines(): string;
  86536. /**
  86537. * Returns the string "PointParticleEmitter"
  86538. * @returns a string containing the class name
  86539. */
  86540. getClassName(): string;
  86541. /**
  86542. * Serializes the particle system to a JSON object.
  86543. * @returns the JSON object
  86544. */
  86545. serialize(): any;
  86546. /**
  86547. * Parse properties from a JSON object
  86548. * @param serializationObject defines the JSON object
  86549. */
  86550. parse(serializationObject: any): void;
  86551. }
  86552. }
  86553. declare module BABYLON {
  86554. /**
  86555. * Particle emitter emitting particles from the inside of a sphere.
  86556. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86557. */
  86558. export class SphereParticleEmitter implements IParticleEmitterType {
  86559. /**
  86560. * The radius of the emission sphere.
  86561. */
  86562. radius: number;
  86563. /**
  86564. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86565. */
  86566. radiusRange: number;
  86567. /**
  86568. * How much to randomize the particle direction [0-1].
  86569. */
  86570. directionRandomizer: number;
  86571. /**
  86572. * Creates a new instance SphereParticleEmitter
  86573. * @param radius the radius of the emission sphere (1 by default)
  86574. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86575. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86576. */
  86577. constructor(
  86578. /**
  86579. * The radius of the emission sphere.
  86580. */
  86581. radius?: number,
  86582. /**
  86583. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86584. */
  86585. radiusRange?: number,
  86586. /**
  86587. * How much to randomize the particle direction [0-1].
  86588. */
  86589. directionRandomizer?: number);
  86590. /**
  86591. * Called by the particle System when the direction is computed for the created particle.
  86592. * @param worldMatrix is the world matrix of the particle system
  86593. * @param directionToUpdate is the direction vector to update with the result
  86594. * @param particle is the particle we are computed the direction for
  86595. */
  86596. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86597. /**
  86598. * Called by the particle System when the position is computed for the created particle.
  86599. * @param worldMatrix is the world matrix of the particle system
  86600. * @param positionToUpdate is the position vector to update with the result
  86601. * @param particle is the particle we are computed the position for
  86602. */
  86603. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86604. /**
  86605. * Clones the current emitter and returns a copy of it
  86606. * @returns the new emitter
  86607. */
  86608. clone(): SphereParticleEmitter;
  86609. /**
  86610. * Called by the GPUParticleSystem to setup the update shader
  86611. * @param effect defines the update shader
  86612. */
  86613. applyToShader(effect: Effect): void;
  86614. /**
  86615. * Returns a string to use to update the GPU particles update shader
  86616. * @returns a string containng the defines string
  86617. */
  86618. getEffectDefines(): string;
  86619. /**
  86620. * Returns the string "SphereParticleEmitter"
  86621. * @returns a string containing the class name
  86622. */
  86623. getClassName(): string;
  86624. /**
  86625. * Serializes the particle system to a JSON object.
  86626. * @returns the JSON object
  86627. */
  86628. serialize(): any;
  86629. /**
  86630. * Parse properties from a JSON object
  86631. * @param serializationObject defines the JSON object
  86632. */
  86633. parse(serializationObject: any): void;
  86634. }
  86635. /**
  86636. * Particle emitter emitting particles from the inside of a sphere.
  86637. * It emits the particles randomly between two vectors.
  86638. */
  86639. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  86640. /**
  86641. * The min limit of the emission direction.
  86642. */
  86643. direction1: Vector3;
  86644. /**
  86645. * The max limit of the emission direction.
  86646. */
  86647. direction2: Vector3;
  86648. /**
  86649. * Creates a new instance SphereDirectedParticleEmitter
  86650. * @param radius the radius of the emission sphere (1 by default)
  86651. * @param direction1 the min limit of the emission direction (up vector by default)
  86652. * @param direction2 the max limit of the emission direction (up vector by default)
  86653. */
  86654. constructor(radius?: number,
  86655. /**
  86656. * The min limit of the emission direction.
  86657. */
  86658. direction1?: Vector3,
  86659. /**
  86660. * The max limit of the emission direction.
  86661. */
  86662. direction2?: Vector3);
  86663. /**
  86664. * Called by the particle System when the direction is computed for the created particle.
  86665. * @param worldMatrix is the world matrix of the particle system
  86666. * @param directionToUpdate is the direction vector to update with the result
  86667. * @param particle is the particle we are computed the direction for
  86668. */
  86669. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86670. /**
  86671. * Clones the current emitter and returns a copy of it
  86672. * @returns the new emitter
  86673. */
  86674. clone(): SphereDirectedParticleEmitter;
  86675. /**
  86676. * Called by the GPUParticleSystem to setup the update shader
  86677. * @param effect defines the update shader
  86678. */
  86679. applyToShader(effect: Effect): void;
  86680. /**
  86681. * Returns a string to use to update the GPU particles update shader
  86682. * @returns a string containng the defines string
  86683. */
  86684. getEffectDefines(): string;
  86685. /**
  86686. * Returns the string "SphereDirectedParticleEmitter"
  86687. * @returns a string containing the class name
  86688. */
  86689. getClassName(): string;
  86690. /**
  86691. * Serializes the particle system to a JSON object.
  86692. * @returns the JSON object
  86693. */
  86694. serialize(): any;
  86695. /**
  86696. * Parse properties from a JSON object
  86697. * @param serializationObject defines the JSON object
  86698. */
  86699. parse(serializationObject: any): void;
  86700. }
  86701. }
  86702. declare module BABYLON {
  86703. /**
  86704. * Interface representing a particle system in Babylon.js.
  86705. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86706. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86707. */
  86708. export interface IParticleSystem {
  86709. /**
  86710. * List of animations used by the particle system.
  86711. */
  86712. animations: Animation[];
  86713. /**
  86714. * The id of the Particle system.
  86715. */
  86716. id: string;
  86717. /**
  86718. * The name of the Particle system.
  86719. */
  86720. name: string;
  86721. /**
  86722. * The emitter represents the Mesh or position we are attaching the particle system to.
  86723. */
  86724. emitter: Nullable<AbstractMesh | Vector3>;
  86725. /**
  86726. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86727. */
  86728. isBillboardBased: boolean;
  86729. /**
  86730. * The rendering group used by the Particle system to chose when to render.
  86731. */
  86732. renderingGroupId: number;
  86733. /**
  86734. * The layer mask we are rendering the particles through.
  86735. */
  86736. layerMask: number;
  86737. /**
  86738. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86739. */
  86740. updateSpeed: number;
  86741. /**
  86742. * The amount of time the particle system is running (depends of the overall update speed).
  86743. */
  86744. targetStopDuration: number;
  86745. /**
  86746. * The texture used to render each particle. (this can be a spritesheet)
  86747. */
  86748. particleTexture: Nullable<Texture>;
  86749. /**
  86750. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86751. */
  86752. blendMode: number;
  86753. /**
  86754. * Minimum life time of emitting particles.
  86755. */
  86756. minLifeTime: number;
  86757. /**
  86758. * Maximum life time of emitting particles.
  86759. */
  86760. maxLifeTime: number;
  86761. /**
  86762. * Minimum Size of emitting particles.
  86763. */
  86764. minSize: number;
  86765. /**
  86766. * Maximum Size of emitting particles.
  86767. */
  86768. maxSize: number;
  86769. /**
  86770. * Minimum scale of emitting particles on X axis.
  86771. */
  86772. minScaleX: number;
  86773. /**
  86774. * Maximum scale of emitting particles on X axis.
  86775. */
  86776. maxScaleX: number;
  86777. /**
  86778. * Minimum scale of emitting particles on Y axis.
  86779. */
  86780. minScaleY: number;
  86781. /**
  86782. * Maximum scale of emitting particles on Y axis.
  86783. */
  86784. maxScaleY: number;
  86785. /**
  86786. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86787. */
  86788. color1: Color4;
  86789. /**
  86790. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86791. */
  86792. color2: Color4;
  86793. /**
  86794. * Color the particle will have at the end of its lifetime.
  86795. */
  86796. colorDead: Color4;
  86797. /**
  86798. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86799. */
  86800. emitRate: number;
  86801. /**
  86802. * You can use gravity if you want to give an orientation to your particles.
  86803. */
  86804. gravity: Vector3;
  86805. /**
  86806. * Minimum power of emitting particles.
  86807. */
  86808. minEmitPower: number;
  86809. /**
  86810. * Maximum power of emitting particles.
  86811. */
  86812. maxEmitPower: number;
  86813. /**
  86814. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86815. */
  86816. minAngularSpeed: number;
  86817. /**
  86818. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86819. */
  86820. maxAngularSpeed: number;
  86821. /**
  86822. * Gets or sets the minimal initial rotation in radians.
  86823. */
  86824. minInitialRotation: number;
  86825. /**
  86826. * Gets or sets the maximal initial rotation in radians.
  86827. */
  86828. maxInitialRotation: number;
  86829. /**
  86830. * The particle emitter type defines the emitter used by the particle system.
  86831. * It can be for example box, sphere, or cone...
  86832. */
  86833. particleEmitterType: Nullable<IParticleEmitterType>;
  86834. /**
  86835. * Defines the delay in milliseconds before starting the system (0 by default)
  86836. */
  86837. startDelay: number;
  86838. /**
  86839. * 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
  86840. */
  86841. preWarmCycles: number;
  86842. /**
  86843. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86844. */
  86845. preWarmStepOffset: number;
  86846. /**
  86847. * 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)
  86848. */
  86849. spriteCellChangeSpeed: number;
  86850. /**
  86851. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86852. */
  86853. startSpriteCellID: number;
  86854. /**
  86855. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86856. */
  86857. endSpriteCellID: number;
  86858. /**
  86859. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86860. */
  86861. spriteCellWidth: number;
  86862. /**
  86863. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86864. */
  86865. spriteCellHeight: number;
  86866. /**
  86867. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86868. */
  86869. spriteRandomStartCell: boolean;
  86870. /**
  86871. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86872. */
  86873. isAnimationSheetEnabled: boolean;
  86874. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86875. translationPivot: Vector2;
  86876. /**
  86877. * Gets or sets a texture used to add random noise to particle positions
  86878. */
  86879. noiseTexture: Nullable<BaseTexture>;
  86880. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86881. noiseStrength: Vector3;
  86882. /**
  86883. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86884. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86885. */
  86886. billboardMode: number;
  86887. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86888. limitVelocityDamping: number;
  86889. /**
  86890. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86891. */
  86892. beginAnimationOnStart: boolean;
  86893. /**
  86894. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86895. */
  86896. beginAnimationFrom: number;
  86897. /**
  86898. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86899. */
  86900. beginAnimationTo: number;
  86901. /**
  86902. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86903. */
  86904. beginAnimationLoop: boolean;
  86905. /**
  86906. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86907. */
  86908. disposeOnStop: boolean;
  86909. /**
  86910. * Gets the maximum number of particles active at the same time.
  86911. * @returns The max number of active particles.
  86912. */
  86913. getCapacity(): number;
  86914. /**
  86915. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86916. * @returns True if it has been started, otherwise false.
  86917. */
  86918. isStarted(): boolean;
  86919. /**
  86920. * Animates the particle system for this frame.
  86921. */
  86922. animate(): void;
  86923. /**
  86924. * Renders the particle system in its current state.
  86925. * @returns the current number of particles
  86926. */
  86927. render(): number;
  86928. /**
  86929. * Dispose the particle system and frees its associated resources.
  86930. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86931. */
  86932. dispose(disposeTexture?: boolean): void;
  86933. /**
  86934. * Clones the particle system.
  86935. * @param name The name of the cloned object
  86936. * @param newEmitter The new emitter to use
  86937. * @returns the cloned particle system
  86938. */
  86939. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86940. /**
  86941. * Serializes the particle system to a JSON object.
  86942. * @returns the JSON object
  86943. */
  86944. serialize(): any;
  86945. /**
  86946. * Rebuild the particle system
  86947. */
  86948. rebuild(): void;
  86949. /**
  86950. * Starts the particle system and begins to emit
  86951. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86952. */
  86953. start(delay?: number): void;
  86954. /**
  86955. * Stops the particle system.
  86956. */
  86957. stop(): void;
  86958. /**
  86959. * Remove all active particles
  86960. */
  86961. reset(): void;
  86962. /**
  86963. * Is this system ready to be used/rendered
  86964. * @return true if the system is ready
  86965. */
  86966. isReady(): boolean;
  86967. /**
  86968. * Adds a new color gradient
  86969. * @param gradient defines the gradient to use (between 0 and 1)
  86970. * @param color1 defines the color to affect to the specified gradient
  86971. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86972. * @returns the current particle system
  86973. */
  86974. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86975. /**
  86976. * Remove a specific color gradient
  86977. * @param gradient defines the gradient to remove
  86978. * @returns the current particle system
  86979. */
  86980. removeColorGradient(gradient: number): IParticleSystem;
  86981. /**
  86982. * Adds a new size gradient
  86983. * @param gradient defines the gradient to use (between 0 and 1)
  86984. * @param factor defines the size factor to affect to the specified gradient
  86985. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86986. * @returns the current particle system
  86987. */
  86988. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86989. /**
  86990. * Remove a specific size gradient
  86991. * @param gradient defines the gradient to remove
  86992. * @returns the current particle system
  86993. */
  86994. removeSizeGradient(gradient: number): IParticleSystem;
  86995. /**
  86996. * Gets the current list of color gradients.
  86997. * You must use addColorGradient and removeColorGradient to udpate this list
  86998. * @returns the list of color gradients
  86999. */
  87000. getColorGradients(): Nullable<Array<ColorGradient>>;
  87001. /**
  87002. * Gets the current list of size gradients.
  87003. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87004. * @returns the list of size gradients
  87005. */
  87006. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87007. /**
  87008. * Gets the current list of angular speed gradients.
  87009. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87010. * @returns the list of angular speed gradients
  87011. */
  87012. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87013. /**
  87014. * Adds a new angular speed gradient
  87015. * @param gradient defines the gradient to use (between 0 and 1)
  87016. * @param factor defines the angular speed to affect to the specified gradient
  87017. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87018. * @returns the current particle system
  87019. */
  87020. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87021. /**
  87022. * Remove a specific angular speed gradient
  87023. * @param gradient defines the gradient to remove
  87024. * @returns the current particle system
  87025. */
  87026. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87027. /**
  87028. * Gets the current list of velocity gradients.
  87029. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87030. * @returns the list of velocity gradients
  87031. */
  87032. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87033. /**
  87034. * Adds a new velocity gradient
  87035. * @param gradient defines the gradient to use (between 0 and 1)
  87036. * @param factor defines the velocity to affect to the specified gradient
  87037. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87038. * @returns the current particle system
  87039. */
  87040. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87041. /**
  87042. * Remove a specific velocity gradient
  87043. * @param gradient defines the gradient to remove
  87044. * @returns the current particle system
  87045. */
  87046. removeVelocityGradient(gradient: number): IParticleSystem;
  87047. /**
  87048. * Gets the current list of limit velocity gradients.
  87049. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87050. * @returns the list of limit velocity gradients
  87051. */
  87052. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87053. /**
  87054. * Adds a new limit velocity gradient
  87055. * @param gradient defines the gradient to use (between 0 and 1)
  87056. * @param factor defines the limit velocity to affect to the specified gradient
  87057. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87058. * @returns the current particle system
  87059. */
  87060. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87061. /**
  87062. * Remove a specific limit velocity gradient
  87063. * @param gradient defines the gradient to remove
  87064. * @returns the current particle system
  87065. */
  87066. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87067. /**
  87068. * Adds a new drag gradient
  87069. * @param gradient defines the gradient to use (between 0 and 1)
  87070. * @param factor defines the drag to affect to the specified gradient
  87071. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87072. * @returns the current particle system
  87073. */
  87074. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87075. /**
  87076. * Remove a specific drag gradient
  87077. * @param gradient defines the gradient to remove
  87078. * @returns the current particle system
  87079. */
  87080. removeDragGradient(gradient: number): IParticleSystem;
  87081. /**
  87082. * Gets the current list of drag gradients.
  87083. * You must use addDragGradient and removeDragGradient to udpate this list
  87084. * @returns the list of drag gradients
  87085. */
  87086. getDragGradients(): Nullable<Array<FactorGradient>>;
  87087. /**
  87088. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87089. * @param gradient defines the gradient to use (between 0 and 1)
  87090. * @param factor defines the emit rate to affect to the specified gradient
  87091. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87092. * @returns the current particle system
  87093. */
  87094. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87095. /**
  87096. * Remove a specific emit rate gradient
  87097. * @param gradient defines the gradient to remove
  87098. * @returns the current particle system
  87099. */
  87100. removeEmitRateGradient(gradient: number): IParticleSystem;
  87101. /**
  87102. * Gets the current list of emit rate gradients.
  87103. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87104. * @returns the list of emit rate gradients
  87105. */
  87106. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87107. /**
  87108. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87109. * @param gradient defines the gradient to use (between 0 and 1)
  87110. * @param factor defines the start size to affect to the specified gradient
  87111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87112. * @returns the current particle system
  87113. */
  87114. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87115. /**
  87116. * Remove a specific start size gradient
  87117. * @param gradient defines the gradient to remove
  87118. * @returns the current particle system
  87119. */
  87120. removeStartSizeGradient(gradient: number): IParticleSystem;
  87121. /**
  87122. * Gets the current list of start size gradients.
  87123. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87124. * @returns the list of start size gradients
  87125. */
  87126. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87127. /**
  87128. * Adds a new life time gradient
  87129. * @param gradient defines the gradient to use (between 0 and 1)
  87130. * @param factor defines the life time factor to affect to the specified gradient
  87131. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87132. * @returns the current particle system
  87133. */
  87134. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87135. /**
  87136. * Remove a specific life time gradient
  87137. * @param gradient defines the gradient to remove
  87138. * @returns the current particle system
  87139. */
  87140. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87141. /**
  87142. * Gets the current list of life time gradients.
  87143. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87144. * @returns the list of life time gradients
  87145. */
  87146. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87147. /**
  87148. * Gets the current list of color gradients.
  87149. * You must use addColorGradient and removeColorGradient to udpate this list
  87150. * @returns the list of color gradients
  87151. */
  87152. getColorGradients(): Nullable<Array<ColorGradient>>;
  87153. /**
  87154. * Adds a new ramp gradient used to remap particle colors
  87155. * @param gradient defines the gradient to use (between 0 and 1)
  87156. * @param color defines the color to affect to the specified gradient
  87157. * @returns the current particle system
  87158. */
  87159. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  87160. /**
  87161. * Gets the current list of ramp gradients.
  87162. * You must use addRampGradient and removeRampGradient to udpate this list
  87163. * @returns the list of ramp gradients
  87164. */
  87165. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87166. /** Gets or sets a boolean indicating that ramp gradients must be used
  87167. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87168. */
  87169. useRampGradients: boolean;
  87170. /**
  87171. * Adds a new color remap gradient
  87172. * @param gradient defines the gradient to use (between 0 and 1)
  87173. * @param min defines the color remap minimal range
  87174. * @param max defines the color remap maximal range
  87175. * @returns the current particle system
  87176. */
  87177. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87178. /**
  87179. * Gets the current list of color remap gradients.
  87180. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87181. * @returns the list of color remap gradients
  87182. */
  87183. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87184. /**
  87185. * Adds a new alpha remap gradient
  87186. * @param gradient defines the gradient to use (between 0 and 1)
  87187. * @param min defines the alpha remap minimal range
  87188. * @param max defines the alpha remap maximal range
  87189. * @returns the current particle system
  87190. */
  87191. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87192. /**
  87193. * Gets the current list of alpha remap gradients.
  87194. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87195. * @returns the list of alpha remap gradients
  87196. */
  87197. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87198. /**
  87199. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87200. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87201. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87202. * @returns the emitter
  87203. */
  87204. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87205. /**
  87206. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87207. * @param radius The radius of the hemisphere to emit from
  87208. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87209. * @returns the emitter
  87210. */
  87211. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  87212. /**
  87213. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87214. * @param radius The radius of the sphere to emit from
  87215. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87216. * @returns the emitter
  87217. */
  87218. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  87219. /**
  87220. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87221. * @param radius The radius of the sphere to emit from
  87222. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87223. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87224. * @returns the emitter
  87225. */
  87226. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87227. /**
  87228. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87229. * @param radius The radius of the emission cylinder
  87230. * @param height The height of the emission cylinder
  87231. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87232. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87233. * @returns the emitter
  87234. */
  87235. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87236. /**
  87237. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87238. * @param radius The radius of the cylinder to emit from
  87239. * @param height The height of the emission cylinder
  87240. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87241. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87242. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87243. * @returns the emitter
  87244. */
  87245. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87246. /**
  87247. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87248. * @param radius The radius of the cone to emit from
  87249. * @param angle The base angle of the cone
  87250. * @returns the emitter
  87251. */
  87252. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87253. /**
  87254. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87255. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87256. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87257. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87258. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87259. * @returns the emitter
  87260. */
  87261. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87262. /**
  87263. * Get hosting scene
  87264. * @returns the scene
  87265. */
  87266. getScene(): Scene;
  87267. }
  87268. }
  87269. declare module BABYLON {
  87270. /**
  87271. * Creates an instance based on a source mesh.
  87272. */
  87273. export class InstancedMesh extends AbstractMesh {
  87274. private _sourceMesh;
  87275. private _currentLOD;
  87276. /** @hidden */
  87277. _indexInSourceMeshInstanceArray: number;
  87278. constructor(name: string, source: Mesh);
  87279. /**
  87280. * Returns the string "InstancedMesh".
  87281. */
  87282. getClassName(): string;
  87283. /** Gets the list of lights affecting that mesh */
  87284. readonly lightSources: Light[];
  87285. _resyncLightSources(): void;
  87286. _resyncLighSource(light: Light): void;
  87287. _removeLightSource(light: Light, dispose: boolean): void;
  87288. /**
  87289. * If the source mesh receives shadows
  87290. */
  87291. readonly receiveShadows: boolean;
  87292. /**
  87293. * The material of the source mesh
  87294. */
  87295. readonly material: Nullable<Material>;
  87296. /**
  87297. * Visibility of the source mesh
  87298. */
  87299. readonly visibility: number;
  87300. /**
  87301. * Skeleton of the source mesh
  87302. */
  87303. readonly skeleton: Nullable<Skeleton>;
  87304. /**
  87305. * Rendering ground id of the source mesh
  87306. */
  87307. renderingGroupId: number;
  87308. /**
  87309. * Returns the total number of vertices (integer).
  87310. */
  87311. getTotalVertices(): number;
  87312. /**
  87313. * Returns a positive integer : the total number of indices in this mesh geometry.
  87314. * @returns the numner of indices or zero if the mesh has no geometry.
  87315. */
  87316. getTotalIndices(): number;
  87317. /**
  87318. * The source mesh of the instance
  87319. */
  87320. readonly sourceMesh: Mesh;
  87321. /**
  87322. * Is this node ready to be used/rendered
  87323. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87324. * @return {boolean} is it ready
  87325. */
  87326. isReady(completeCheck?: boolean): boolean;
  87327. /**
  87328. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87329. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  87330. * @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.
  87331. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  87332. */
  87333. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  87334. /**
  87335. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87336. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87337. * The `data` are either a numeric array either a Float32Array.
  87338. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  87339. * 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).
  87340. * Note that a new underlying VertexBuffer object is created each call.
  87341. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87342. *
  87343. * Possible `kind` values :
  87344. * - VertexBuffer.PositionKind
  87345. * - VertexBuffer.UVKind
  87346. * - VertexBuffer.UV2Kind
  87347. * - VertexBuffer.UV3Kind
  87348. * - VertexBuffer.UV4Kind
  87349. * - VertexBuffer.UV5Kind
  87350. * - VertexBuffer.UV6Kind
  87351. * - VertexBuffer.ColorKind
  87352. * - VertexBuffer.MatricesIndicesKind
  87353. * - VertexBuffer.MatricesIndicesExtraKind
  87354. * - VertexBuffer.MatricesWeightsKind
  87355. * - VertexBuffer.MatricesWeightsExtraKind
  87356. *
  87357. * Returns the Mesh.
  87358. */
  87359. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87360. /**
  87361. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87362. * If the mesh has no geometry, it is simply returned as it is.
  87363. * The `data` are either a numeric array either a Float32Array.
  87364. * No new underlying VertexBuffer object is created.
  87365. * 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.
  87366. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  87367. *
  87368. * Possible `kind` values :
  87369. * - VertexBuffer.PositionKind
  87370. * - VertexBuffer.UVKind
  87371. * - VertexBuffer.UV2Kind
  87372. * - VertexBuffer.UV3Kind
  87373. * - VertexBuffer.UV4Kind
  87374. * - VertexBuffer.UV5Kind
  87375. * - VertexBuffer.UV6Kind
  87376. * - VertexBuffer.ColorKind
  87377. * - VertexBuffer.MatricesIndicesKind
  87378. * - VertexBuffer.MatricesIndicesExtraKind
  87379. * - VertexBuffer.MatricesWeightsKind
  87380. * - VertexBuffer.MatricesWeightsExtraKind
  87381. *
  87382. * Returns the Mesh.
  87383. */
  87384. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  87385. /**
  87386. * Sets the mesh indices.
  87387. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  87388. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87389. * This method creates a new index buffer each call.
  87390. * Returns the Mesh.
  87391. */
  87392. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  87393. /**
  87394. * Boolean : True if the mesh owns the requested kind of data.
  87395. */
  87396. isVerticesDataPresent(kind: string): boolean;
  87397. /**
  87398. * Returns an array of indices (IndicesArray).
  87399. */
  87400. getIndices(): Nullable<IndicesArray>;
  87401. readonly _positions: Nullable<Vector3[]>;
  87402. /**
  87403. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87404. * This means the mesh underlying bounding box and sphere are recomputed.
  87405. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87406. * @returns the current mesh
  87407. */
  87408. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  87409. /** @hidden */
  87410. _preActivate(): InstancedMesh;
  87411. /** @hidden */
  87412. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87413. /** @hidden */
  87414. _postActivate(): void;
  87415. getWorldMatrix(): Matrix;
  87416. readonly isAnInstance: boolean;
  87417. /**
  87418. * Returns the current associated LOD AbstractMesh.
  87419. */
  87420. getLOD(camera: Camera): AbstractMesh;
  87421. /** @hidden */
  87422. _syncSubMeshes(): InstancedMesh;
  87423. /** @hidden */
  87424. _generatePointsArray(): boolean;
  87425. /**
  87426. * Creates a new InstancedMesh from the current mesh.
  87427. * - name (string) : the cloned mesh name
  87428. * - newParent (optional Node) : the optional Node to parent the clone to.
  87429. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  87430. *
  87431. * Returns the clone.
  87432. */
  87433. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87434. /**
  87435. * Disposes the InstancedMesh.
  87436. * Returns nothing.
  87437. */
  87438. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87439. }
  87440. interface Mesh {
  87441. /**
  87442. * Register a custom buffer that will be instanced
  87443. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87444. * @param kind defines the buffer kind
  87445. * @param stride defines the stride in floats
  87446. */
  87447. registerInstancedBuffer(kind: string, stride: number): void;
  87448. /** @hidden */
  87449. _userInstancedBuffersStorage: {
  87450. data: {
  87451. [key: string]: Float32Array;
  87452. };
  87453. sizes: {
  87454. [key: string]: number;
  87455. };
  87456. vertexBuffers: {
  87457. [key: string]: Nullable<VertexBuffer>;
  87458. };
  87459. strides: {
  87460. [key: string]: number;
  87461. };
  87462. };
  87463. }
  87464. interface AbstractMesh {
  87465. /**
  87466. * Object used to store instanced buffers defined by user
  87467. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87468. */
  87469. instancedBuffers: {
  87470. [key: string]: any;
  87471. };
  87472. }
  87473. }
  87474. declare module BABYLON {
  87475. /**
  87476. * Defines the options associated with the creation of a shader material.
  87477. */
  87478. export interface IShaderMaterialOptions {
  87479. /**
  87480. * Does the material work in alpha blend mode
  87481. */
  87482. needAlphaBlending: boolean;
  87483. /**
  87484. * Does the material work in alpha test mode
  87485. */
  87486. needAlphaTesting: boolean;
  87487. /**
  87488. * The list of attribute names used in the shader
  87489. */
  87490. attributes: string[];
  87491. /**
  87492. * The list of unifrom names used in the shader
  87493. */
  87494. uniforms: string[];
  87495. /**
  87496. * The list of UBO names used in the shader
  87497. */
  87498. uniformBuffers: string[];
  87499. /**
  87500. * The list of sampler names used in the shader
  87501. */
  87502. samplers: string[];
  87503. /**
  87504. * The list of defines used in the shader
  87505. */
  87506. defines: string[];
  87507. }
  87508. /**
  87509. * 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.
  87510. *
  87511. * This returned material effects how the mesh will look based on the code in the shaders.
  87512. *
  87513. * @see http://doc.babylonjs.com/how_to/shader_material
  87514. */
  87515. export class ShaderMaterial extends Material {
  87516. private _shaderPath;
  87517. private _options;
  87518. private _textures;
  87519. private _textureArrays;
  87520. private _floats;
  87521. private _ints;
  87522. private _floatsArrays;
  87523. private _colors3;
  87524. private _colors3Arrays;
  87525. private _colors4;
  87526. private _colors4Arrays;
  87527. private _vectors2;
  87528. private _vectors3;
  87529. private _vectors4;
  87530. private _matrices;
  87531. private _matrixArrays;
  87532. private _matrices3x3;
  87533. private _matrices2x2;
  87534. private _vectors2Arrays;
  87535. private _vectors3Arrays;
  87536. private _vectors4Arrays;
  87537. private _cachedWorldViewMatrix;
  87538. private _cachedWorldViewProjectionMatrix;
  87539. private _renderId;
  87540. private _multiview;
  87541. /**
  87542. * Instantiate a new shader material.
  87543. * 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.
  87544. * This returned material effects how the mesh will look based on the code in the shaders.
  87545. * @see http://doc.babylonjs.com/how_to/shader_material
  87546. * @param name Define the name of the material in the scene
  87547. * @param scene Define the scene the material belongs to
  87548. * @param shaderPath Defines the route to the shader code in one of three ways:
  87549. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  87550. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  87551. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  87552. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  87553. * @param options Define the options used to create the shader
  87554. */
  87555. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  87556. /**
  87557. * Gets the shader path used to define the shader code
  87558. * It can be modified to trigger a new compilation
  87559. */
  87560. /**
  87561. * Sets the shader path used to define the shader code
  87562. * It can be modified to trigger a new compilation
  87563. */
  87564. shaderPath: any;
  87565. /**
  87566. * Gets the options used to compile the shader.
  87567. * They can be modified to trigger a new compilation
  87568. */
  87569. readonly options: IShaderMaterialOptions;
  87570. /**
  87571. * Gets the current class name of the material e.g. "ShaderMaterial"
  87572. * Mainly use in serialization.
  87573. * @returns the class name
  87574. */
  87575. getClassName(): string;
  87576. /**
  87577. * Specifies if the material will require alpha blending
  87578. * @returns a boolean specifying if alpha blending is needed
  87579. */
  87580. needAlphaBlending(): boolean;
  87581. /**
  87582. * Specifies if this material should be rendered in alpha test mode
  87583. * @returns a boolean specifying if an alpha test is needed.
  87584. */
  87585. needAlphaTesting(): boolean;
  87586. private _checkUniform;
  87587. /**
  87588. * Set a texture in the shader.
  87589. * @param name Define the name of the uniform samplers as defined in the shader
  87590. * @param texture Define the texture to bind to this sampler
  87591. * @return the material itself allowing "fluent" like uniform updates
  87592. */
  87593. setTexture(name: string, texture: Texture): ShaderMaterial;
  87594. /**
  87595. * Set a texture array in the shader.
  87596. * @param name Define the name of the uniform sampler array as defined in the shader
  87597. * @param textures Define the list of textures to bind to this sampler
  87598. * @return the material itself allowing "fluent" like uniform updates
  87599. */
  87600. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  87601. /**
  87602. * Set a float in the shader.
  87603. * @param name Define the name of the uniform as defined in the shader
  87604. * @param value Define the value to give to the uniform
  87605. * @return the material itself allowing "fluent" like uniform updates
  87606. */
  87607. setFloat(name: string, value: number): ShaderMaterial;
  87608. /**
  87609. * Set a int in the shader.
  87610. * @param name Define the name of the uniform as defined in the shader
  87611. * @param value Define the value to give to the uniform
  87612. * @return the material itself allowing "fluent" like uniform updates
  87613. */
  87614. setInt(name: string, value: number): ShaderMaterial;
  87615. /**
  87616. * Set an array of floats in the shader.
  87617. * @param name Define the name of the uniform as defined in the shader
  87618. * @param value Define the value to give to the uniform
  87619. * @return the material itself allowing "fluent" like uniform updates
  87620. */
  87621. setFloats(name: string, value: number[]): ShaderMaterial;
  87622. /**
  87623. * Set a vec3 in the shader from a Color3.
  87624. * @param name Define the name of the uniform as defined in the shader
  87625. * @param value Define the value to give to the uniform
  87626. * @return the material itself allowing "fluent" like uniform updates
  87627. */
  87628. setColor3(name: string, value: Color3): ShaderMaterial;
  87629. /**
  87630. * Set a vec3 array in the shader from a Color3 array.
  87631. * @param name Define the name of the uniform as defined in the shader
  87632. * @param value Define the value to give to the uniform
  87633. * @return the material itself allowing "fluent" like uniform updates
  87634. */
  87635. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  87636. /**
  87637. * Set a vec4 in the shader from a Color4.
  87638. * @param name Define the name of the uniform as defined in the shader
  87639. * @param value Define the value to give to the uniform
  87640. * @return the material itself allowing "fluent" like uniform updates
  87641. */
  87642. setColor4(name: string, value: Color4): ShaderMaterial;
  87643. /**
  87644. * Set a vec4 array in the shader from a Color4 array.
  87645. * @param name Define the name of the uniform as defined in the shader
  87646. * @param value Define the value to give to the uniform
  87647. * @return the material itself allowing "fluent" like uniform updates
  87648. */
  87649. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  87650. /**
  87651. * Set a vec2 in the shader from a Vector2.
  87652. * @param name Define the name of the uniform as defined in the shader
  87653. * @param value Define the value to give to the uniform
  87654. * @return the material itself allowing "fluent" like uniform updates
  87655. */
  87656. setVector2(name: string, value: Vector2): ShaderMaterial;
  87657. /**
  87658. * Set a vec3 in the shader from a Vector3.
  87659. * @param name Define the name of the uniform as defined in the shader
  87660. * @param value Define the value to give to the uniform
  87661. * @return the material itself allowing "fluent" like uniform updates
  87662. */
  87663. setVector3(name: string, value: Vector3): ShaderMaterial;
  87664. /**
  87665. * Set a vec4 in the shader from a Vector4.
  87666. * @param name Define the name of the uniform as defined in the shader
  87667. * @param value Define the value to give to the uniform
  87668. * @return the material itself allowing "fluent" like uniform updates
  87669. */
  87670. setVector4(name: string, value: Vector4): ShaderMaterial;
  87671. /**
  87672. * Set a mat4 in the shader from a Matrix.
  87673. * @param name Define the name of the uniform as defined in the shader
  87674. * @param value Define the value to give to the uniform
  87675. * @return the material itself allowing "fluent" like uniform updates
  87676. */
  87677. setMatrix(name: string, value: Matrix): ShaderMaterial;
  87678. /**
  87679. * Set a float32Array in the shader from a matrix array.
  87680. * @param name Define the name of the uniform as defined in the shader
  87681. * @param value Define the value to give to the uniform
  87682. * @return the material itself allowing "fluent" like uniform updates
  87683. */
  87684. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  87685. /**
  87686. * Set a mat3 in the shader from a Float32Array.
  87687. * @param name Define the name of the uniform as defined in the shader
  87688. * @param value Define the value to give to the uniform
  87689. * @return the material itself allowing "fluent" like uniform updates
  87690. */
  87691. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  87692. /**
  87693. * Set a mat2 in the shader from a Float32Array.
  87694. * @param name Define the name of the uniform as defined in the shader
  87695. * @param value Define the value to give to the uniform
  87696. * @return the material itself allowing "fluent" like uniform updates
  87697. */
  87698. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  87699. /**
  87700. * Set a vec2 array in the shader from a number array.
  87701. * @param name Define the name of the uniform as defined in the shader
  87702. * @param value Define the value to give to the uniform
  87703. * @return the material itself allowing "fluent" like uniform updates
  87704. */
  87705. setArray2(name: string, value: number[]): ShaderMaterial;
  87706. /**
  87707. * Set a vec3 array in the shader from a number array.
  87708. * @param name Define the name of the uniform as defined in the shader
  87709. * @param value Define the value to give to the uniform
  87710. * @return the material itself allowing "fluent" like uniform updates
  87711. */
  87712. setArray3(name: string, value: number[]): ShaderMaterial;
  87713. /**
  87714. * Set a vec4 array in the shader from a number array.
  87715. * @param name Define the name of the uniform as defined in the shader
  87716. * @param value Define the value to give to the uniform
  87717. * @return the material itself allowing "fluent" like uniform updates
  87718. */
  87719. setArray4(name: string, value: number[]): ShaderMaterial;
  87720. private _checkCache;
  87721. /**
  87722. * Specifies that the submesh is ready to be used
  87723. * @param mesh defines the mesh to check
  87724. * @param subMesh defines which submesh to check
  87725. * @param useInstances specifies that instances should be used
  87726. * @returns a boolean indicating that the submesh is ready or not
  87727. */
  87728. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87729. /**
  87730. * Checks if the material is ready to render the requested mesh
  87731. * @param mesh Define the mesh to render
  87732. * @param useInstances Define whether or not the material is used with instances
  87733. * @returns true if ready, otherwise false
  87734. */
  87735. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87736. /**
  87737. * Binds the world matrix to the material
  87738. * @param world defines the world transformation matrix
  87739. */
  87740. bindOnlyWorldMatrix(world: Matrix): void;
  87741. /**
  87742. * Binds the material to the mesh
  87743. * @param world defines the world transformation matrix
  87744. * @param mesh defines the mesh to bind the material to
  87745. */
  87746. bind(world: Matrix, mesh?: Mesh): void;
  87747. /**
  87748. * Gets the active textures from the material
  87749. * @returns an array of textures
  87750. */
  87751. getActiveTextures(): BaseTexture[];
  87752. /**
  87753. * Specifies if the material uses a texture
  87754. * @param texture defines the texture to check against the material
  87755. * @returns a boolean specifying if the material uses the texture
  87756. */
  87757. hasTexture(texture: BaseTexture): boolean;
  87758. /**
  87759. * Makes a duplicate of the material, and gives it a new name
  87760. * @param name defines the new name for the duplicated material
  87761. * @returns the cloned material
  87762. */
  87763. clone(name: string): ShaderMaterial;
  87764. /**
  87765. * Disposes the material
  87766. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87767. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87768. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87769. */
  87770. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87771. /**
  87772. * Serializes this material in a JSON representation
  87773. * @returns the serialized material object
  87774. */
  87775. serialize(): any;
  87776. /**
  87777. * Creates a shader material from parsed shader material data
  87778. * @param source defines the JSON represnetation of the material
  87779. * @param scene defines the hosting scene
  87780. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87781. * @returns a new material
  87782. */
  87783. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  87784. }
  87785. }
  87786. declare module BABYLON {
  87787. /** @hidden */
  87788. export var colorPixelShader: {
  87789. name: string;
  87790. shader: string;
  87791. };
  87792. }
  87793. declare module BABYLON {
  87794. /** @hidden */
  87795. export var colorVertexShader: {
  87796. name: string;
  87797. shader: string;
  87798. };
  87799. }
  87800. declare module BABYLON {
  87801. /**
  87802. * Line mesh
  87803. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  87804. */
  87805. export class LinesMesh extends Mesh {
  87806. /**
  87807. * If vertex color should be applied to the mesh
  87808. */
  87809. readonly useVertexColor?: boolean | undefined;
  87810. /**
  87811. * If vertex alpha should be applied to the mesh
  87812. */
  87813. readonly useVertexAlpha?: boolean | undefined;
  87814. /**
  87815. * Color of the line (Default: White)
  87816. */
  87817. color: Color3;
  87818. /**
  87819. * Alpha of the line (Default: 1)
  87820. */
  87821. alpha: number;
  87822. /**
  87823. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87824. * This margin is expressed in world space coordinates, so its value may vary.
  87825. * Default value is 0.1
  87826. */
  87827. intersectionThreshold: number;
  87828. private _colorShader;
  87829. private color4;
  87830. /**
  87831. * Creates a new LinesMesh
  87832. * @param name defines the name
  87833. * @param scene defines the hosting scene
  87834. * @param parent defines the parent mesh if any
  87835. * @param source defines the optional source LinesMesh used to clone data from
  87836. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87837. * When false, achieved by calling a clone(), also passing False.
  87838. * This will make creation of children, recursive.
  87839. * @param useVertexColor defines if this LinesMesh supports vertex color
  87840. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  87841. */
  87842. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  87843. /**
  87844. * If vertex color should be applied to the mesh
  87845. */
  87846. useVertexColor?: boolean | undefined,
  87847. /**
  87848. * If vertex alpha should be applied to the mesh
  87849. */
  87850. useVertexAlpha?: boolean | undefined);
  87851. private _addClipPlaneDefine;
  87852. private _removeClipPlaneDefine;
  87853. isReady(): boolean;
  87854. /**
  87855. * Returns the string "LineMesh"
  87856. */
  87857. getClassName(): string;
  87858. /**
  87859. * @hidden
  87860. */
  87861. /**
  87862. * @hidden
  87863. */
  87864. material: Material;
  87865. /**
  87866. * @hidden
  87867. */
  87868. readonly checkCollisions: boolean;
  87869. /** @hidden */
  87870. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  87871. /** @hidden */
  87872. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  87873. /**
  87874. * Disposes of the line mesh
  87875. * @param doNotRecurse If children should be disposed
  87876. */
  87877. dispose(doNotRecurse?: boolean): void;
  87878. /**
  87879. * Returns a new LineMesh object cloned from the current one.
  87880. */
  87881. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87882. /**
  87883. * Creates a new InstancedLinesMesh object from the mesh model.
  87884. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87885. * @param name defines the name of the new instance
  87886. * @returns a new InstancedLinesMesh
  87887. */
  87888. createInstance(name: string): InstancedLinesMesh;
  87889. }
  87890. /**
  87891. * Creates an instance based on a source LinesMesh
  87892. */
  87893. export class InstancedLinesMesh extends InstancedMesh {
  87894. /**
  87895. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87896. * This margin is expressed in world space coordinates, so its value may vary.
  87897. * Initilized with the intersectionThreshold value of the source LinesMesh
  87898. */
  87899. intersectionThreshold: number;
  87900. constructor(name: string, source: LinesMesh);
  87901. /**
  87902. * Returns the string "InstancedLinesMesh".
  87903. */
  87904. getClassName(): string;
  87905. }
  87906. }
  87907. declare module BABYLON {
  87908. /** @hidden */
  87909. export var linePixelShader: {
  87910. name: string;
  87911. shader: string;
  87912. };
  87913. }
  87914. declare module BABYLON {
  87915. /** @hidden */
  87916. export var lineVertexShader: {
  87917. name: string;
  87918. shader: string;
  87919. };
  87920. }
  87921. declare module BABYLON {
  87922. interface AbstractMesh {
  87923. /**
  87924. * Gets the edgesRenderer associated with the mesh
  87925. */
  87926. edgesRenderer: Nullable<EdgesRenderer>;
  87927. }
  87928. interface LinesMesh {
  87929. /**
  87930. * Enables the edge rendering mode on the mesh.
  87931. * This mode makes the mesh edges visible
  87932. * @param epsilon defines the maximal distance between two angles to detect a face
  87933. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87934. * @returns the currentAbstractMesh
  87935. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87936. */
  87937. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87938. }
  87939. interface InstancedLinesMesh {
  87940. /**
  87941. * Enables the edge rendering mode on the mesh.
  87942. * This mode makes the mesh edges visible
  87943. * @param epsilon defines the maximal distance between two angles to detect a face
  87944. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87945. * @returns the current InstancedLinesMesh
  87946. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87947. */
  87948. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  87949. }
  87950. /**
  87951. * Defines the minimum contract an Edges renderer should follow.
  87952. */
  87953. export interface IEdgesRenderer extends IDisposable {
  87954. /**
  87955. * Gets or sets a boolean indicating if the edgesRenderer is active
  87956. */
  87957. isEnabled: boolean;
  87958. /**
  87959. * Renders the edges of the attached mesh,
  87960. */
  87961. render(): void;
  87962. /**
  87963. * Checks wether or not the edges renderer is ready to render.
  87964. * @return true if ready, otherwise false.
  87965. */
  87966. isReady(): boolean;
  87967. }
  87968. /**
  87969. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  87970. */
  87971. export class EdgesRenderer implements IEdgesRenderer {
  87972. /**
  87973. * Define the size of the edges with an orthographic camera
  87974. */
  87975. edgesWidthScalerForOrthographic: number;
  87976. /**
  87977. * Define the size of the edges with a perspective camera
  87978. */
  87979. edgesWidthScalerForPerspective: number;
  87980. protected _source: AbstractMesh;
  87981. protected _linesPositions: number[];
  87982. protected _linesNormals: number[];
  87983. protected _linesIndices: number[];
  87984. protected _epsilon: number;
  87985. protected _indicesCount: number;
  87986. protected _lineShader: ShaderMaterial;
  87987. protected _ib: DataBuffer;
  87988. protected _buffers: {
  87989. [key: string]: Nullable<VertexBuffer>;
  87990. };
  87991. protected _checkVerticesInsteadOfIndices: boolean;
  87992. private _meshRebuildObserver;
  87993. private _meshDisposeObserver;
  87994. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  87995. isEnabled: boolean;
  87996. /**
  87997. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  87998. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  87999. * @param source Mesh used to create edges
  88000. * @param epsilon sum of angles in adjacency to check for edge
  88001. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  88002. * @param generateEdgesLines - should generate Lines or only prepare resources.
  88003. */
  88004. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  88005. protected _prepareRessources(): void;
  88006. /** @hidden */
  88007. _rebuild(): void;
  88008. /**
  88009. * Releases the required resources for the edges renderer
  88010. */
  88011. dispose(): void;
  88012. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  88013. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  88014. /**
  88015. * Checks if the pair of p0 and p1 is en edge
  88016. * @param faceIndex
  88017. * @param edge
  88018. * @param faceNormals
  88019. * @param p0
  88020. * @param p1
  88021. * @private
  88022. */
  88023. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  88024. /**
  88025. * push line into the position, normal and index buffer
  88026. * @protected
  88027. */
  88028. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  88029. /**
  88030. * Generates lines edges from adjacencjes
  88031. * @private
  88032. */
  88033. _generateEdgesLines(): void;
  88034. /**
  88035. * Checks wether or not the edges renderer is ready to render.
  88036. * @return true if ready, otherwise false.
  88037. */
  88038. isReady(): boolean;
  88039. /**
  88040. * Renders the edges of the attached mesh,
  88041. */
  88042. render(): void;
  88043. }
  88044. /**
  88045. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  88046. */
  88047. export class LineEdgesRenderer extends EdgesRenderer {
  88048. /**
  88049. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  88050. * @param source LineMesh used to generate edges
  88051. * @param epsilon not important (specified angle for edge detection)
  88052. * @param checkVerticesInsteadOfIndices not important for LineMesh
  88053. */
  88054. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  88055. /**
  88056. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  88057. */
  88058. _generateEdgesLines(): void;
  88059. }
  88060. }
  88061. declare module BABYLON {
  88062. /**
  88063. * This represents the object necessary to create a rendering group.
  88064. * This is exclusively used and created by the rendering manager.
  88065. * To modify the behavior, you use the available helpers in your scene or meshes.
  88066. * @hidden
  88067. */
  88068. export class RenderingGroup {
  88069. index: number;
  88070. private static _zeroVector;
  88071. private _scene;
  88072. private _opaqueSubMeshes;
  88073. private _transparentSubMeshes;
  88074. private _alphaTestSubMeshes;
  88075. private _depthOnlySubMeshes;
  88076. private _particleSystems;
  88077. private _spriteManagers;
  88078. private _opaqueSortCompareFn;
  88079. private _alphaTestSortCompareFn;
  88080. private _transparentSortCompareFn;
  88081. private _renderOpaque;
  88082. private _renderAlphaTest;
  88083. private _renderTransparent;
  88084. /** @hidden */
  88085. _edgesRenderers: SmartArray<IEdgesRenderer>;
  88086. onBeforeTransparentRendering: () => void;
  88087. /**
  88088. * Set the opaque sort comparison function.
  88089. * If null the sub meshes will be render in the order they were created
  88090. */
  88091. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88092. /**
  88093. * Set the alpha test sort comparison function.
  88094. * If null the sub meshes will be render in the order they were created
  88095. */
  88096. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88097. /**
  88098. * Set the transparent sort comparison function.
  88099. * If null the sub meshes will be render in the order they were created
  88100. */
  88101. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88102. /**
  88103. * Creates a new rendering group.
  88104. * @param index The rendering group index
  88105. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  88106. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  88107. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  88108. */
  88109. 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>);
  88110. /**
  88111. * Render all the sub meshes contained in the group.
  88112. * @param customRenderFunction Used to override the default render behaviour of the group.
  88113. * @returns true if rendered some submeshes.
  88114. */
  88115. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  88116. /**
  88117. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  88118. * @param subMeshes The submeshes to render
  88119. */
  88120. private renderOpaqueSorted;
  88121. /**
  88122. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  88123. * @param subMeshes The submeshes to render
  88124. */
  88125. private renderAlphaTestSorted;
  88126. /**
  88127. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  88128. * @param subMeshes The submeshes to render
  88129. */
  88130. private renderTransparentSorted;
  88131. /**
  88132. * Renders the submeshes in a specified order.
  88133. * @param subMeshes The submeshes to sort before render
  88134. * @param sortCompareFn The comparison function use to sort
  88135. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  88136. * @param transparent Specifies to activate blending if true
  88137. */
  88138. private static renderSorted;
  88139. /**
  88140. * Renders the submeshes in the order they were dispatched (no sort applied).
  88141. * @param subMeshes The submeshes to render
  88142. */
  88143. private static renderUnsorted;
  88144. /**
  88145. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88146. * are rendered back to front if in the same alpha index.
  88147. *
  88148. * @param a The first submesh
  88149. * @param b The second submesh
  88150. * @returns The result of the comparison
  88151. */
  88152. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  88153. /**
  88154. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88155. * are rendered back to front.
  88156. *
  88157. * @param a The first submesh
  88158. * @param b The second submesh
  88159. * @returns The result of the comparison
  88160. */
  88161. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  88162. /**
  88163. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88164. * are rendered front to back (prevent overdraw).
  88165. *
  88166. * @param a The first submesh
  88167. * @param b The second submesh
  88168. * @returns The result of the comparison
  88169. */
  88170. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  88171. /**
  88172. * Resets the different lists of submeshes to prepare a new frame.
  88173. */
  88174. prepare(): void;
  88175. dispose(): void;
  88176. /**
  88177. * Inserts the submesh in its correct queue depending on its material.
  88178. * @param subMesh The submesh to dispatch
  88179. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88180. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88181. */
  88182. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88183. dispatchSprites(spriteManager: ISpriteManager): void;
  88184. dispatchParticles(particleSystem: IParticleSystem): void;
  88185. private _renderParticles;
  88186. private _renderSprites;
  88187. }
  88188. }
  88189. declare module BABYLON {
  88190. /**
  88191. * Interface describing the different options available in the rendering manager
  88192. * regarding Auto Clear between groups.
  88193. */
  88194. export interface IRenderingManagerAutoClearSetup {
  88195. /**
  88196. * Defines whether or not autoclear is enable.
  88197. */
  88198. autoClear: boolean;
  88199. /**
  88200. * Defines whether or not to autoclear the depth buffer.
  88201. */
  88202. depth: boolean;
  88203. /**
  88204. * Defines whether or not to autoclear the stencil buffer.
  88205. */
  88206. stencil: boolean;
  88207. }
  88208. /**
  88209. * This class is used by the onRenderingGroupObservable
  88210. */
  88211. export class RenderingGroupInfo {
  88212. /**
  88213. * The Scene that being rendered
  88214. */
  88215. scene: Scene;
  88216. /**
  88217. * The camera currently used for the rendering pass
  88218. */
  88219. camera: Nullable<Camera>;
  88220. /**
  88221. * The ID of the renderingGroup being processed
  88222. */
  88223. renderingGroupId: number;
  88224. }
  88225. /**
  88226. * This is the manager responsible of all the rendering for meshes sprites and particles.
  88227. * It is enable to manage the different groups as well as the different necessary sort functions.
  88228. * This should not be used directly aside of the few static configurations
  88229. */
  88230. export class RenderingManager {
  88231. /**
  88232. * The max id used for rendering groups (not included)
  88233. */
  88234. static MAX_RENDERINGGROUPS: number;
  88235. /**
  88236. * The min id used for rendering groups (included)
  88237. */
  88238. static MIN_RENDERINGGROUPS: number;
  88239. /**
  88240. * Used to globally prevent autoclearing scenes.
  88241. */
  88242. static AUTOCLEAR: boolean;
  88243. /**
  88244. * @hidden
  88245. */
  88246. _useSceneAutoClearSetup: boolean;
  88247. private _scene;
  88248. private _renderingGroups;
  88249. private _depthStencilBufferAlreadyCleaned;
  88250. private _autoClearDepthStencil;
  88251. private _customOpaqueSortCompareFn;
  88252. private _customAlphaTestSortCompareFn;
  88253. private _customTransparentSortCompareFn;
  88254. private _renderingGroupInfo;
  88255. /**
  88256. * Instantiates a new rendering group for a particular scene
  88257. * @param scene Defines the scene the groups belongs to
  88258. */
  88259. constructor(scene: Scene);
  88260. private _clearDepthStencilBuffer;
  88261. /**
  88262. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  88263. * @hidden
  88264. */
  88265. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  88266. /**
  88267. * Resets the different information of the group to prepare a new frame
  88268. * @hidden
  88269. */
  88270. reset(): void;
  88271. /**
  88272. * Dispose and release the group and its associated resources.
  88273. * @hidden
  88274. */
  88275. dispose(): void;
  88276. /**
  88277. * Clear the info related to rendering groups preventing retention points during dispose.
  88278. */
  88279. freeRenderingGroups(): void;
  88280. private _prepareRenderingGroup;
  88281. /**
  88282. * Add a sprite manager to the rendering manager in order to render it this frame.
  88283. * @param spriteManager Define the sprite manager to render
  88284. */
  88285. dispatchSprites(spriteManager: ISpriteManager): void;
  88286. /**
  88287. * Add a particle system to the rendering manager in order to render it this frame.
  88288. * @param particleSystem Define the particle system to render
  88289. */
  88290. dispatchParticles(particleSystem: IParticleSystem): void;
  88291. /**
  88292. * Add a submesh to the manager in order to render it this frame
  88293. * @param subMesh The submesh to dispatch
  88294. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88295. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88296. */
  88297. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88298. /**
  88299. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88300. * This allowed control for front to back rendering or reversly depending of the special needs.
  88301. *
  88302. * @param renderingGroupId The rendering group id corresponding to its index
  88303. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88304. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88305. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88306. */
  88307. 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;
  88308. /**
  88309. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88310. *
  88311. * @param renderingGroupId The rendering group id corresponding to its index
  88312. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88313. * @param depth Automatically clears depth between groups if true and autoClear is true.
  88314. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  88315. */
  88316. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  88317. /**
  88318. * Gets the current auto clear configuration for one rendering group of the rendering
  88319. * manager.
  88320. * @param index the rendering group index to get the information for
  88321. * @returns The auto clear setup for the requested rendering group
  88322. */
  88323. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  88324. }
  88325. }
  88326. declare module BABYLON {
  88327. /**
  88328. * This Helps creating a texture that will be created from a camera in your scene.
  88329. * It is basically a dynamic texture that could be used to create special effects for instance.
  88330. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  88331. */
  88332. export class RenderTargetTexture extends Texture {
  88333. isCube: boolean;
  88334. /**
  88335. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  88336. */
  88337. static readonly REFRESHRATE_RENDER_ONCE: number;
  88338. /**
  88339. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  88340. */
  88341. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  88342. /**
  88343. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  88344. * the central point of your effect and can save a lot of performances.
  88345. */
  88346. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  88347. /**
  88348. * Use this predicate to dynamically define the list of mesh you want to render.
  88349. * If set, the renderList property will be overwritten.
  88350. */
  88351. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  88352. private _renderList;
  88353. /**
  88354. * Use this list to define the list of mesh you want to render.
  88355. */
  88356. renderList: Nullable<Array<AbstractMesh>>;
  88357. private _hookArray;
  88358. /**
  88359. * Define if particles should be rendered in your texture.
  88360. */
  88361. renderParticles: boolean;
  88362. /**
  88363. * Define if sprites should be rendered in your texture.
  88364. */
  88365. renderSprites: boolean;
  88366. /**
  88367. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  88368. */
  88369. coordinatesMode: number;
  88370. /**
  88371. * Define the camera used to render the texture.
  88372. */
  88373. activeCamera: Nullable<Camera>;
  88374. /**
  88375. * Override the render function of the texture with your own one.
  88376. */
  88377. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  88378. /**
  88379. * Define if camera post processes should be use while rendering the texture.
  88380. */
  88381. useCameraPostProcesses: boolean;
  88382. /**
  88383. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  88384. */
  88385. ignoreCameraViewport: boolean;
  88386. private _postProcessManager;
  88387. private _postProcesses;
  88388. private _resizeObserver;
  88389. /**
  88390. * An event triggered when the texture is unbind.
  88391. */
  88392. onBeforeBindObservable: Observable<RenderTargetTexture>;
  88393. /**
  88394. * An event triggered when the texture is unbind.
  88395. */
  88396. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  88397. private _onAfterUnbindObserver;
  88398. /**
  88399. * Set a after unbind callback in the texture.
  88400. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  88401. */
  88402. onAfterUnbind: () => void;
  88403. /**
  88404. * An event triggered before rendering the texture
  88405. */
  88406. onBeforeRenderObservable: Observable<number>;
  88407. private _onBeforeRenderObserver;
  88408. /**
  88409. * Set a before render callback in the texture.
  88410. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  88411. */
  88412. onBeforeRender: (faceIndex: number) => void;
  88413. /**
  88414. * An event triggered after rendering the texture
  88415. */
  88416. onAfterRenderObservable: Observable<number>;
  88417. private _onAfterRenderObserver;
  88418. /**
  88419. * Set a after render callback in the texture.
  88420. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  88421. */
  88422. onAfterRender: (faceIndex: number) => void;
  88423. /**
  88424. * An event triggered after the texture clear
  88425. */
  88426. onClearObservable: Observable<Engine>;
  88427. private _onClearObserver;
  88428. /**
  88429. * Set a clear callback in the texture.
  88430. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  88431. */
  88432. onClear: (Engine: Engine) => void;
  88433. /**
  88434. * An event triggered when the texture is resized.
  88435. */
  88436. onResizeObservable: Observable<RenderTargetTexture>;
  88437. /**
  88438. * Define the clear color of the Render Target if it should be different from the scene.
  88439. */
  88440. clearColor: Color4;
  88441. protected _size: number | {
  88442. width: number;
  88443. height: number;
  88444. };
  88445. protected _initialSizeParameter: number | {
  88446. width: number;
  88447. height: number;
  88448. } | {
  88449. ratio: number;
  88450. };
  88451. protected _sizeRatio: Nullable<number>;
  88452. /** @hidden */
  88453. _generateMipMaps: boolean;
  88454. protected _renderingManager: RenderingManager;
  88455. /** @hidden */
  88456. _waitingRenderList: string[];
  88457. protected _doNotChangeAspectRatio: boolean;
  88458. protected _currentRefreshId: number;
  88459. protected _refreshRate: number;
  88460. protected _textureMatrix: Matrix;
  88461. protected _samples: number;
  88462. protected _renderTargetOptions: RenderTargetCreationOptions;
  88463. /**
  88464. * Gets render target creation options that were used.
  88465. */
  88466. readonly renderTargetOptions: RenderTargetCreationOptions;
  88467. protected _engine: Engine;
  88468. protected _onRatioRescale(): void;
  88469. /**
  88470. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  88471. * It must define where the camera used to render the texture is set
  88472. */
  88473. boundingBoxPosition: Vector3;
  88474. private _boundingBoxSize;
  88475. /**
  88476. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  88477. * When defined, the cubemap will switch to local mode
  88478. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88479. * @example https://www.babylonjs-playground.com/#RNASML
  88480. */
  88481. boundingBoxSize: Vector3;
  88482. /**
  88483. * In case the RTT has been created with a depth texture, get the associated
  88484. * depth texture.
  88485. * Otherwise, return null.
  88486. */
  88487. depthStencilTexture: Nullable<InternalTexture>;
  88488. /**
  88489. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  88490. * or used a shadow, depth texture...
  88491. * @param name The friendly name of the texture
  88492. * @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)
  88493. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  88494. * @param generateMipMaps True if mip maps need to be generated after render.
  88495. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  88496. * @param type The type of the buffer in the RTT (int, half float, float...)
  88497. * @param isCube True if a cube texture needs to be created
  88498. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  88499. * @param generateDepthBuffer True to generate a depth buffer
  88500. * @param generateStencilBuffer True to generate a stencil buffer
  88501. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  88502. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  88503. * @param delayAllocation if the texture allocation should be delayed (default: false)
  88504. */
  88505. constructor(name: string, size: number | {
  88506. width: number;
  88507. height: number;
  88508. } | {
  88509. ratio: number;
  88510. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  88511. /**
  88512. * Creates a depth stencil texture.
  88513. * This is only available in WebGL 2 or with the depth texture extension available.
  88514. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  88515. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  88516. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  88517. */
  88518. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  88519. private _processSizeParameter;
  88520. /**
  88521. * Define the number of samples to use in case of MSAA.
  88522. * It defaults to one meaning no MSAA has been enabled.
  88523. */
  88524. samples: number;
  88525. /**
  88526. * Resets the refresh counter of the texture and start bak from scratch.
  88527. * Could be useful to regenerate the texture if it is setup to render only once.
  88528. */
  88529. resetRefreshCounter(): void;
  88530. /**
  88531. * Define the refresh rate of the texture or the rendering frequency.
  88532. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  88533. */
  88534. refreshRate: number;
  88535. /**
  88536. * Adds a post process to the render target rendering passes.
  88537. * @param postProcess define the post process to add
  88538. */
  88539. addPostProcess(postProcess: PostProcess): void;
  88540. /**
  88541. * Clear all the post processes attached to the render target
  88542. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  88543. */
  88544. clearPostProcesses(dispose?: boolean): void;
  88545. /**
  88546. * Remove one of the post process from the list of attached post processes to the texture
  88547. * @param postProcess define the post process to remove from the list
  88548. */
  88549. removePostProcess(postProcess: PostProcess): void;
  88550. /** @hidden */
  88551. _shouldRender(): boolean;
  88552. /**
  88553. * Gets the actual render size of the texture.
  88554. * @returns the width of the render size
  88555. */
  88556. getRenderSize(): number;
  88557. /**
  88558. * Gets the actual render width of the texture.
  88559. * @returns the width of the render size
  88560. */
  88561. getRenderWidth(): number;
  88562. /**
  88563. * Gets the actual render height of the texture.
  88564. * @returns the height of the render size
  88565. */
  88566. getRenderHeight(): number;
  88567. /**
  88568. * Get if the texture can be rescaled or not.
  88569. */
  88570. readonly canRescale: boolean;
  88571. /**
  88572. * Resize the texture using a ratio.
  88573. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  88574. */
  88575. scale(ratio: number): void;
  88576. /**
  88577. * Get the texture reflection matrix used to rotate/transform the reflection.
  88578. * @returns the reflection matrix
  88579. */
  88580. getReflectionTextureMatrix(): Matrix;
  88581. /**
  88582. * Resize the texture to a new desired size.
  88583. * Be carrefull as it will recreate all the data in the new texture.
  88584. * @param size Define the new size. It can be:
  88585. * - a number for squared texture,
  88586. * - an object containing { width: number, height: number }
  88587. * - or an object containing a ratio { ratio: number }
  88588. */
  88589. resize(size: number | {
  88590. width: number;
  88591. height: number;
  88592. } | {
  88593. ratio: number;
  88594. }): void;
  88595. /**
  88596. * Renders all the objects from the render list into the texture.
  88597. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  88598. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  88599. */
  88600. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  88601. private _bestReflectionRenderTargetDimension;
  88602. /**
  88603. * @hidden
  88604. * @param faceIndex face index to bind to if this is a cubetexture
  88605. */
  88606. _bindFrameBuffer(faceIndex?: number): void;
  88607. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  88608. private renderToTarget;
  88609. /**
  88610. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88611. * This allowed control for front to back rendering or reversly depending of the special needs.
  88612. *
  88613. * @param renderingGroupId The rendering group id corresponding to its index
  88614. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88615. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88616. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88617. */
  88618. 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;
  88619. /**
  88620. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88621. *
  88622. * @param renderingGroupId The rendering group id corresponding to its index
  88623. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88624. */
  88625. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  88626. /**
  88627. * Clones the texture.
  88628. * @returns the cloned texture
  88629. */
  88630. clone(): RenderTargetTexture;
  88631. /**
  88632. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  88633. * @returns The JSON representation of the texture
  88634. */
  88635. serialize(): any;
  88636. /**
  88637. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  88638. */
  88639. disposeFramebufferObjects(): void;
  88640. /**
  88641. * Dispose the texture and release its associated resources.
  88642. */
  88643. dispose(): void;
  88644. /** @hidden */
  88645. _rebuild(): void;
  88646. /**
  88647. * Clear the info related to rendering groups preventing retention point in material dispose.
  88648. */
  88649. freeRenderingGroups(): void;
  88650. /**
  88651. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  88652. * @returns the view count
  88653. */
  88654. getViewCount(): number;
  88655. }
  88656. }
  88657. declare module BABYLON {
  88658. /**
  88659. * Options for compiling materials.
  88660. */
  88661. export interface IMaterialCompilationOptions {
  88662. /**
  88663. * Defines whether clip planes are enabled.
  88664. */
  88665. clipPlane: boolean;
  88666. /**
  88667. * Defines whether instances are enabled.
  88668. */
  88669. useInstances: boolean;
  88670. }
  88671. /**
  88672. * Base class for the main features of a material in Babylon.js
  88673. */
  88674. export class Material implements IAnimatable {
  88675. /**
  88676. * Returns the triangle fill mode
  88677. */
  88678. static readonly TriangleFillMode: number;
  88679. /**
  88680. * Returns the wireframe mode
  88681. */
  88682. static readonly WireFrameFillMode: number;
  88683. /**
  88684. * Returns the point fill mode
  88685. */
  88686. static readonly PointFillMode: number;
  88687. /**
  88688. * Returns the point list draw mode
  88689. */
  88690. static readonly PointListDrawMode: number;
  88691. /**
  88692. * Returns the line list draw mode
  88693. */
  88694. static readonly LineListDrawMode: number;
  88695. /**
  88696. * Returns the line loop draw mode
  88697. */
  88698. static readonly LineLoopDrawMode: number;
  88699. /**
  88700. * Returns the line strip draw mode
  88701. */
  88702. static readonly LineStripDrawMode: number;
  88703. /**
  88704. * Returns the triangle strip draw mode
  88705. */
  88706. static readonly TriangleStripDrawMode: number;
  88707. /**
  88708. * Returns the triangle fan draw mode
  88709. */
  88710. static readonly TriangleFanDrawMode: number;
  88711. /**
  88712. * Stores the clock-wise side orientation
  88713. */
  88714. static readonly ClockWiseSideOrientation: number;
  88715. /**
  88716. * Stores the counter clock-wise side orientation
  88717. */
  88718. static readonly CounterClockWiseSideOrientation: number;
  88719. /**
  88720. * The dirty texture flag value
  88721. */
  88722. static readonly TextureDirtyFlag: number;
  88723. /**
  88724. * The dirty light flag value
  88725. */
  88726. static readonly LightDirtyFlag: number;
  88727. /**
  88728. * The dirty fresnel flag value
  88729. */
  88730. static readonly FresnelDirtyFlag: number;
  88731. /**
  88732. * The dirty attribute flag value
  88733. */
  88734. static readonly AttributesDirtyFlag: number;
  88735. /**
  88736. * The dirty misc flag value
  88737. */
  88738. static readonly MiscDirtyFlag: number;
  88739. /**
  88740. * The all dirty flag value
  88741. */
  88742. static readonly AllDirtyFlag: number;
  88743. /**
  88744. * The ID of the material
  88745. */
  88746. id: string;
  88747. /**
  88748. * Gets or sets the unique id of the material
  88749. */
  88750. uniqueId: number;
  88751. /**
  88752. * The name of the material
  88753. */
  88754. name: string;
  88755. /**
  88756. * Gets or sets user defined metadata
  88757. */
  88758. metadata: any;
  88759. /**
  88760. * For internal use only. Please do not use.
  88761. */
  88762. reservedDataStore: any;
  88763. /**
  88764. * Specifies if the ready state should be checked on each call
  88765. */
  88766. checkReadyOnEveryCall: boolean;
  88767. /**
  88768. * Specifies if the ready state should be checked once
  88769. */
  88770. checkReadyOnlyOnce: boolean;
  88771. /**
  88772. * The state of the material
  88773. */
  88774. state: string;
  88775. /**
  88776. * The alpha value of the material
  88777. */
  88778. protected _alpha: number;
  88779. /**
  88780. * List of inspectable custom properties (used by the Inspector)
  88781. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88782. */
  88783. inspectableCustomProperties: IInspectable[];
  88784. /**
  88785. * Sets the alpha value of the material
  88786. */
  88787. /**
  88788. * Gets the alpha value of the material
  88789. */
  88790. alpha: number;
  88791. /**
  88792. * Specifies if back face culling is enabled
  88793. */
  88794. protected _backFaceCulling: boolean;
  88795. /**
  88796. * Sets the back-face culling state
  88797. */
  88798. /**
  88799. * Gets the back-face culling state
  88800. */
  88801. backFaceCulling: boolean;
  88802. /**
  88803. * Stores the value for side orientation
  88804. */
  88805. sideOrientation: number;
  88806. /**
  88807. * Callback triggered when the material is compiled
  88808. */
  88809. onCompiled: Nullable<(effect: Effect) => void>;
  88810. /**
  88811. * Callback triggered when an error occurs
  88812. */
  88813. onError: Nullable<(effect: Effect, errors: string) => void>;
  88814. /**
  88815. * Callback triggered to get the render target textures
  88816. */
  88817. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  88818. /**
  88819. * Gets a boolean indicating that current material needs to register RTT
  88820. */
  88821. readonly hasRenderTargetTextures: boolean;
  88822. /**
  88823. * Specifies if the material should be serialized
  88824. */
  88825. doNotSerialize: boolean;
  88826. /**
  88827. * @hidden
  88828. */
  88829. _storeEffectOnSubMeshes: boolean;
  88830. /**
  88831. * Stores the animations for the material
  88832. */
  88833. animations: Nullable<Array<Animation>>;
  88834. /**
  88835. * An event triggered when the material is disposed
  88836. */
  88837. onDisposeObservable: Observable<Material>;
  88838. /**
  88839. * An observer which watches for dispose events
  88840. */
  88841. private _onDisposeObserver;
  88842. private _onUnBindObservable;
  88843. /**
  88844. * Called during a dispose event
  88845. */
  88846. onDispose: () => void;
  88847. private _onBindObservable;
  88848. /**
  88849. * An event triggered when the material is bound
  88850. */
  88851. readonly onBindObservable: Observable<AbstractMesh>;
  88852. /**
  88853. * An observer which watches for bind events
  88854. */
  88855. private _onBindObserver;
  88856. /**
  88857. * Called during a bind event
  88858. */
  88859. onBind: (Mesh: AbstractMesh) => void;
  88860. /**
  88861. * An event triggered when the material is unbound
  88862. */
  88863. readonly onUnBindObservable: Observable<Material>;
  88864. /**
  88865. * Stores the value of the alpha mode
  88866. */
  88867. private _alphaMode;
  88868. /**
  88869. * Sets the value of the alpha mode.
  88870. *
  88871. * | Value | Type | Description |
  88872. * | --- | --- | --- |
  88873. * | 0 | ALPHA_DISABLE | |
  88874. * | 1 | ALPHA_ADD | |
  88875. * | 2 | ALPHA_COMBINE | |
  88876. * | 3 | ALPHA_SUBTRACT | |
  88877. * | 4 | ALPHA_MULTIPLY | |
  88878. * | 5 | ALPHA_MAXIMIZED | |
  88879. * | 6 | ALPHA_ONEONE | |
  88880. * | 7 | ALPHA_PREMULTIPLIED | |
  88881. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  88882. * | 9 | ALPHA_INTERPOLATE | |
  88883. * | 10 | ALPHA_SCREENMODE | |
  88884. *
  88885. */
  88886. /**
  88887. * Gets the value of the alpha mode
  88888. */
  88889. alphaMode: number;
  88890. /**
  88891. * Stores the state of the need depth pre-pass value
  88892. */
  88893. private _needDepthPrePass;
  88894. /**
  88895. * Sets the need depth pre-pass value
  88896. */
  88897. /**
  88898. * Gets the depth pre-pass value
  88899. */
  88900. needDepthPrePass: boolean;
  88901. /**
  88902. * Specifies if depth writing should be disabled
  88903. */
  88904. disableDepthWrite: boolean;
  88905. /**
  88906. * Specifies if depth writing should be forced
  88907. */
  88908. forceDepthWrite: boolean;
  88909. /**
  88910. * Specifies the depth function that should be used. 0 means the default engine function
  88911. */
  88912. depthFunction: number;
  88913. /**
  88914. * Specifies if there should be a separate pass for culling
  88915. */
  88916. separateCullingPass: boolean;
  88917. /**
  88918. * Stores the state specifing if fog should be enabled
  88919. */
  88920. private _fogEnabled;
  88921. /**
  88922. * Sets the state for enabling fog
  88923. */
  88924. /**
  88925. * Gets the value of the fog enabled state
  88926. */
  88927. fogEnabled: boolean;
  88928. /**
  88929. * Stores the size of points
  88930. */
  88931. pointSize: number;
  88932. /**
  88933. * Stores the z offset value
  88934. */
  88935. zOffset: number;
  88936. /**
  88937. * Gets a value specifying if wireframe mode is enabled
  88938. */
  88939. /**
  88940. * Sets the state of wireframe mode
  88941. */
  88942. wireframe: boolean;
  88943. /**
  88944. * Gets the value specifying if point clouds are enabled
  88945. */
  88946. /**
  88947. * Sets the state of point cloud mode
  88948. */
  88949. pointsCloud: boolean;
  88950. /**
  88951. * Gets the material fill mode
  88952. */
  88953. /**
  88954. * Sets the material fill mode
  88955. */
  88956. fillMode: number;
  88957. /**
  88958. * @hidden
  88959. * Stores the effects for the material
  88960. */
  88961. _effect: Nullable<Effect>;
  88962. /**
  88963. * @hidden
  88964. * Specifies if the material was previously ready
  88965. */
  88966. _wasPreviouslyReady: boolean;
  88967. /**
  88968. * Specifies if uniform buffers should be used
  88969. */
  88970. private _useUBO;
  88971. /**
  88972. * Stores a reference to the scene
  88973. */
  88974. private _scene;
  88975. /**
  88976. * Stores the fill mode state
  88977. */
  88978. private _fillMode;
  88979. /**
  88980. * Specifies if the depth write state should be cached
  88981. */
  88982. private _cachedDepthWriteState;
  88983. /**
  88984. * Specifies if the depth function state should be cached
  88985. */
  88986. private _cachedDepthFunctionState;
  88987. /**
  88988. * Stores the uniform buffer
  88989. */
  88990. protected _uniformBuffer: UniformBuffer;
  88991. /** @hidden */
  88992. _indexInSceneMaterialArray: number;
  88993. /** @hidden */
  88994. meshMap: Nullable<{
  88995. [id: string]: AbstractMesh | undefined;
  88996. }>;
  88997. /**
  88998. * Creates a material instance
  88999. * @param name defines the name of the material
  89000. * @param scene defines the scene to reference
  89001. * @param doNotAdd specifies if the material should be added to the scene
  89002. */
  89003. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  89004. /**
  89005. * Returns a string representation of the current material
  89006. * @param fullDetails defines a boolean indicating which levels of logging is desired
  89007. * @returns a string with material information
  89008. */
  89009. toString(fullDetails?: boolean): string;
  89010. /**
  89011. * Gets the class name of the material
  89012. * @returns a string with the class name of the material
  89013. */
  89014. getClassName(): string;
  89015. /**
  89016. * Specifies if updates for the material been locked
  89017. */
  89018. readonly isFrozen: boolean;
  89019. /**
  89020. * Locks updates for the material
  89021. */
  89022. freeze(): void;
  89023. /**
  89024. * Unlocks updates for the material
  89025. */
  89026. unfreeze(): void;
  89027. /**
  89028. * Specifies if the material is ready to be used
  89029. * @param mesh defines the mesh to check
  89030. * @param useInstances specifies if instances should be used
  89031. * @returns a boolean indicating if the material is ready to be used
  89032. */
  89033. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  89034. /**
  89035. * Specifies that the submesh is ready to be used
  89036. * @param mesh defines the mesh to check
  89037. * @param subMesh defines which submesh to check
  89038. * @param useInstances specifies that instances should be used
  89039. * @returns a boolean indicating that the submesh is ready or not
  89040. */
  89041. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89042. /**
  89043. * Returns the material effect
  89044. * @returns the effect associated with the material
  89045. */
  89046. getEffect(): Nullable<Effect>;
  89047. /**
  89048. * Returns the current scene
  89049. * @returns a Scene
  89050. */
  89051. getScene(): Scene;
  89052. /**
  89053. * Specifies if the material will require alpha blending
  89054. * @returns a boolean specifying if alpha blending is needed
  89055. */
  89056. needAlphaBlending(): boolean;
  89057. /**
  89058. * Specifies if the mesh will require alpha blending
  89059. * @param mesh defines the mesh to check
  89060. * @returns a boolean specifying if alpha blending is needed for the mesh
  89061. */
  89062. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  89063. /**
  89064. * Specifies if this material should be rendered in alpha test mode
  89065. * @returns a boolean specifying if an alpha test is needed.
  89066. */
  89067. needAlphaTesting(): boolean;
  89068. /**
  89069. * Gets the texture used for the alpha test
  89070. * @returns the texture to use for alpha testing
  89071. */
  89072. getAlphaTestTexture(): Nullable<BaseTexture>;
  89073. /**
  89074. * Marks the material to indicate that it needs to be re-calculated
  89075. */
  89076. markDirty(): void;
  89077. /** @hidden */
  89078. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  89079. /**
  89080. * Binds the material to the mesh
  89081. * @param world defines the world transformation matrix
  89082. * @param mesh defines the mesh to bind the material to
  89083. */
  89084. bind(world: Matrix, mesh?: Mesh): void;
  89085. /**
  89086. * Binds the submesh to the material
  89087. * @param world defines the world transformation matrix
  89088. * @param mesh defines the mesh containing the submesh
  89089. * @param subMesh defines the submesh to bind the material to
  89090. */
  89091. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  89092. /**
  89093. * Binds the world matrix to the material
  89094. * @param world defines the world transformation matrix
  89095. */
  89096. bindOnlyWorldMatrix(world: Matrix): void;
  89097. /**
  89098. * Binds the scene's uniform buffer to the effect.
  89099. * @param effect defines the effect to bind to the scene uniform buffer
  89100. * @param sceneUbo defines the uniform buffer storing scene data
  89101. */
  89102. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  89103. /**
  89104. * Binds the view matrix to the effect
  89105. * @param effect defines the effect to bind the view matrix to
  89106. */
  89107. bindView(effect: Effect): void;
  89108. /**
  89109. * Binds the view projection matrix to the effect
  89110. * @param effect defines the effect to bind the view projection matrix to
  89111. */
  89112. bindViewProjection(effect: Effect): void;
  89113. /**
  89114. * Specifies if material alpha testing should be turned on for the mesh
  89115. * @param mesh defines the mesh to check
  89116. */
  89117. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  89118. /**
  89119. * Processes to execute after binding the material to a mesh
  89120. * @param mesh defines the rendered mesh
  89121. */
  89122. protected _afterBind(mesh?: Mesh): void;
  89123. /**
  89124. * Unbinds the material from the mesh
  89125. */
  89126. unbind(): void;
  89127. /**
  89128. * Gets the active textures from the material
  89129. * @returns an array of textures
  89130. */
  89131. getActiveTextures(): BaseTexture[];
  89132. /**
  89133. * Specifies if the material uses a texture
  89134. * @param texture defines the texture to check against the material
  89135. * @returns a boolean specifying if the material uses the texture
  89136. */
  89137. hasTexture(texture: BaseTexture): boolean;
  89138. /**
  89139. * Makes a duplicate of the material, and gives it a new name
  89140. * @param name defines the new name for the duplicated material
  89141. * @returns the cloned material
  89142. */
  89143. clone(name: string): Nullable<Material>;
  89144. /**
  89145. * Gets the meshes bound to the material
  89146. * @returns an array of meshes bound to the material
  89147. */
  89148. getBindedMeshes(): AbstractMesh[];
  89149. /**
  89150. * Force shader compilation
  89151. * @param mesh defines the mesh associated with this material
  89152. * @param onCompiled defines a function to execute once the material is compiled
  89153. * @param options defines the options to configure the compilation
  89154. * @param onError defines a function to execute if the material fails compiling
  89155. */
  89156. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  89157. /**
  89158. * Force shader compilation
  89159. * @param mesh defines the mesh that will use this material
  89160. * @param options defines additional options for compiling the shaders
  89161. * @returns a promise that resolves when the compilation completes
  89162. */
  89163. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  89164. private static readonly _AllDirtyCallBack;
  89165. private static readonly _ImageProcessingDirtyCallBack;
  89166. private static readonly _TextureDirtyCallBack;
  89167. private static readonly _FresnelDirtyCallBack;
  89168. private static readonly _MiscDirtyCallBack;
  89169. private static readonly _LightsDirtyCallBack;
  89170. private static readonly _AttributeDirtyCallBack;
  89171. private static _FresnelAndMiscDirtyCallBack;
  89172. private static _TextureAndMiscDirtyCallBack;
  89173. private static readonly _DirtyCallbackArray;
  89174. private static readonly _RunDirtyCallBacks;
  89175. /**
  89176. * Marks a define in the material to indicate that it needs to be re-computed
  89177. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  89178. */
  89179. markAsDirty(flag: number): void;
  89180. /**
  89181. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  89182. * @param func defines a function which checks material defines against the submeshes
  89183. */
  89184. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  89185. /**
  89186. * Indicates that we need to re-calculated for all submeshes
  89187. */
  89188. protected _markAllSubMeshesAsAllDirty(): void;
  89189. /**
  89190. * Indicates that image processing needs to be re-calculated for all submeshes
  89191. */
  89192. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  89193. /**
  89194. * Indicates that textures need to be re-calculated for all submeshes
  89195. */
  89196. protected _markAllSubMeshesAsTexturesDirty(): void;
  89197. /**
  89198. * Indicates that fresnel needs to be re-calculated for all submeshes
  89199. */
  89200. protected _markAllSubMeshesAsFresnelDirty(): void;
  89201. /**
  89202. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  89203. */
  89204. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  89205. /**
  89206. * Indicates that lights need to be re-calculated for all submeshes
  89207. */
  89208. protected _markAllSubMeshesAsLightsDirty(): void;
  89209. /**
  89210. * Indicates that attributes need to be re-calculated for all submeshes
  89211. */
  89212. protected _markAllSubMeshesAsAttributesDirty(): void;
  89213. /**
  89214. * Indicates that misc needs to be re-calculated for all submeshes
  89215. */
  89216. protected _markAllSubMeshesAsMiscDirty(): void;
  89217. /**
  89218. * Indicates that textures and misc need to be re-calculated for all submeshes
  89219. */
  89220. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  89221. /**
  89222. * Disposes the material
  89223. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89224. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89225. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89226. */
  89227. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89228. /** @hidden */
  89229. private releaseVertexArrayObject;
  89230. /**
  89231. * Serializes this material
  89232. * @returns the serialized material object
  89233. */
  89234. serialize(): any;
  89235. /**
  89236. * Creates a material from parsed material data
  89237. * @param parsedMaterial defines parsed material data
  89238. * @param scene defines the hosting scene
  89239. * @param rootUrl defines the root URL to use to load textures
  89240. * @returns a new material
  89241. */
  89242. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  89243. }
  89244. }
  89245. declare module BABYLON {
  89246. /**
  89247. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89248. * separate meshes. This can be use to improve performances.
  89249. * @see http://doc.babylonjs.com/how_to/multi_materials
  89250. */
  89251. export class MultiMaterial extends Material {
  89252. private _subMaterials;
  89253. /**
  89254. * Gets or Sets the list of Materials used within the multi material.
  89255. * They need to be ordered according to the submeshes order in the associated mesh
  89256. */
  89257. subMaterials: Nullable<Material>[];
  89258. /**
  89259. * Function used to align with Node.getChildren()
  89260. * @returns the list of Materials used within the multi material
  89261. */
  89262. getChildren(): Nullable<Material>[];
  89263. /**
  89264. * Instantiates a new Multi Material
  89265. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89266. * separate meshes. This can be use to improve performances.
  89267. * @see http://doc.babylonjs.com/how_to/multi_materials
  89268. * @param name Define the name in the scene
  89269. * @param scene Define the scene the material belongs to
  89270. */
  89271. constructor(name: string, scene: Scene);
  89272. private _hookArray;
  89273. /**
  89274. * Get one of the submaterial by its index in the submaterials array
  89275. * @param index The index to look the sub material at
  89276. * @returns The Material if the index has been defined
  89277. */
  89278. getSubMaterial(index: number): Nullable<Material>;
  89279. /**
  89280. * Get the list of active textures for the whole sub materials list.
  89281. * @returns All the textures that will be used during the rendering
  89282. */
  89283. getActiveTextures(): BaseTexture[];
  89284. /**
  89285. * Gets the current class name of the material e.g. "MultiMaterial"
  89286. * Mainly use in serialization.
  89287. * @returns the class name
  89288. */
  89289. getClassName(): string;
  89290. /**
  89291. * Checks if the material is ready to render the requested sub mesh
  89292. * @param mesh Define the mesh the submesh belongs to
  89293. * @param subMesh Define the sub mesh to look readyness for
  89294. * @param useInstances Define whether or not the material is used with instances
  89295. * @returns true if ready, otherwise false
  89296. */
  89297. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89298. /**
  89299. * Clones the current material and its related sub materials
  89300. * @param name Define the name of the newly cloned material
  89301. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  89302. * @returns the cloned material
  89303. */
  89304. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  89305. /**
  89306. * Serializes the materials into a JSON representation.
  89307. * @returns the JSON representation
  89308. */
  89309. serialize(): any;
  89310. /**
  89311. * Dispose the material and release its associated resources
  89312. * @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)
  89313. * @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)
  89314. * @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)
  89315. */
  89316. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  89317. /**
  89318. * Creates a MultiMaterial from parsed MultiMaterial data.
  89319. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  89320. * @param scene defines the hosting scene
  89321. * @returns a new MultiMaterial
  89322. */
  89323. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  89324. }
  89325. }
  89326. declare module BABYLON {
  89327. /**
  89328. * Base class for submeshes
  89329. */
  89330. export class BaseSubMesh {
  89331. /** @hidden */
  89332. _materialDefines: Nullable<MaterialDefines>;
  89333. /** @hidden */
  89334. _materialEffect: Nullable<Effect>;
  89335. /**
  89336. * Gets associated effect
  89337. */
  89338. readonly effect: Nullable<Effect>;
  89339. /**
  89340. * Sets associated effect (effect used to render this submesh)
  89341. * @param effect defines the effect to associate with
  89342. * @param defines defines the set of defines used to compile this effect
  89343. */
  89344. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  89345. }
  89346. /**
  89347. * Defines a subdivision inside a mesh
  89348. */
  89349. export class SubMesh extends BaseSubMesh implements ICullable {
  89350. /** the material index to use */
  89351. materialIndex: number;
  89352. /** vertex index start */
  89353. verticesStart: number;
  89354. /** vertices count */
  89355. verticesCount: number;
  89356. /** index start */
  89357. indexStart: number;
  89358. /** indices count */
  89359. indexCount: number;
  89360. /** @hidden */
  89361. _linesIndexCount: number;
  89362. private _mesh;
  89363. private _renderingMesh;
  89364. private _boundingInfo;
  89365. private _linesIndexBuffer;
  89366. /** @hidden */
  89367. _lastColliderWorldVertices: Nullable<Vector3[]>;
  89368. /** @hidden */
  89369. _trianglePlanes: Plane[];
  89370. /** @hidden */
  89371. _lastColliderTransformMatrix: Nullable<Matrix>;
  89372. /** @hidden */
  89373. _renderId: number;
  89374. /** @hidden */
  89375. _alphaIndex: number;
  89376. /** @hidden */
  89377. _distanceToCamera: number;
  89378. /** @hidden */
  89379. _id: number;
  89380. private _currentMaterial;
  89381. /**
  89382. * Add a new submesh to a mesh
  89383. * @param materialIndex defines the material index to use
  89384. * @param verticesStart defines vertex index start
  89385. * @param verticesCount defines vertices count
  89386. * @param indexStart defines index start
  89387. * @param indexCount defines indices count
  89388. * @param mesh defines the parent mesh
  89389. * @param renderingMesh defines an optional rendering mesh
  89390. * @param createBoundingBox defines if bounding box should be created for this submesh
  89391. * @returns the new submesh
  89392. */
  89393. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  89394. /**
  89395. * Creates a new submesh
  89396. * @param materialIndex defines the material index to use
  89397. * @param verticesStart defines vertex index start
  89398. * @param verticesCount defines vertices count
  89399. * @param indexStart defines index start
  89400. * @param indexCount defines indices count
  89401. * @param mesh defines the parent mesh
  89402. * @param renderingMesh defines an optional rendering mesh
  89403. * @param createBoundingBox defines if bounding box should be created for this submesh
  89404. */
  89405. constructor(
  89406. /** the material index to use */
  89407. materialIndex: number,
  89408. /** vertex index start */
  89409. verticesStart: number,
  89410. /** vertices count */
  89411. verticesCount: number,
  89412. /** index start */
  89413. indexStart: number,
  89414. /** indices count */
  89415. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  89416. /**
  89417. * Returns true if this submesh covers the entire parent mesh
  89418. * @ignorenaming
  89419. */
  89420. readonly IsGlobal: boolean;
  89421. /**
  89422. * Returns the submesh BoudingInfo object
  89423. * @returns current bounding info (or mesh's one if the submesh is global)
  89424. */
  89425. getBoundingInfo(): BoundingInfo;
  89426. /**
  89427. * Sets the submesh BoundingInfo
  89428. * @param boundingInfo defines the new bounding info to use
  89429. * @returns the SubMesh
  89430. */
  89431. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  89432. /**
  89433. * Returns the mesh of the current submesh
  89434. * @return the parent mesh
  89435. */
  89436. getMesh(): AbstractMesh;
  89437. /**
  89438. * Returns the rendering mesh of the submesh
  89439. * @returns the rendering mesh (could be different from parent mesh)
  89440. */
  89441. getRenderingMesh(): Mesh;
  89442. /**
  89443. * Returns the submesh material
  89444. * @returns null or the current material
  89445. */
  89446. getMaterial(): Nullable<Material>;
  89447. /**
  89448. * Sets a new updated BoundingInfo object to the submesh
  89449. * @param data defines an optional position array to use to determine the bounding info
  89450. * @returns the SubMesh
  89451. */
  89452. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  89453. /** @hidden */
  89454. _checkCollision(collider: Collider): boolean;
  89455. /**
  89456. * Updates the submesh BoundingInfo
  89457. * @param world defines the world matrix to use to update the bounding info
  89458. * @returns the submesh
  89459. */
  89460. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  89461. /**
  89462. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  89463. * @param frustumPlanes defines the frustum planes
  89464. * @returns true if the submesh is intersecting with the frustum
  89465. */
  89466. isInFrustum(frustumPlanes: Plane[]): boolean;
  89467. /**
  89468. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  89469. * @param frustumPlanes defines the frustum planes
  89470. * @returns true if the submesh is inside the frustum
  89471. */
  89472. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  89473. /**
  89474. * Renders the submesh
  89475. * @param enableAlphaMode defines if alpha needs to be used
  89476. * @returns the submesh
  89477. */
  89478. render(enableAlphaMode: boolean): SubMesh;
  89479. /**
  89480. * @hidden
  89481. */
  89482. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  89483. /**
  89484. * Checks if the submesh intersects with a ray
  89485. * @param ray defines the ray to test
  89486. * @returns true is the passed ray intersects the submesh bounding box
  89487. */
  89488. canIntersects(ray: Ray): boolean;
  89489. /**
  89490. * Intersects current submesh with a ray
  89491. * @param ray defines the ray to test
  89492. * @param positions defines mesh's positions array
  89493. * @param indices defines mesh's indices array
  89494. * @param fastCheck defines if only bounding info should be used
  89495. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  89496. * @returns intersection info or null if no intersection
  89497. */
  89498. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  89499. /** @hidden */
  89500. private _intersectLines;
  89501. /** @hidden */
  89502. private _intersectUnIndexedLines;
  89503. /** @hidden */
  89504. private _intersectTriangles;
  89505. /** @hidden */
  89506. private _intersectUnIndexedTriangles;
  89507. /** @hidden */
  89508. _rebuild(): void;
  89509. /**
  89510. * Creates a new submesh from the passed mesh
  89511. * @param newMesh defines the new hosting mesh
  89512. * @param newRenderingMesh defines an optional rendering mesh
  89513. * @returns the new submesh
  89514. */
  89515. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  89516. /**
  89517. * Release associated resources
  89518. */
  89519. dispose(): void;
  89520. /**
  89521. * Gets the class name
  89522. * @returns the string "SubMesh".
  89523. */
  89524. getClassName(): string;
  89525. /**
  89526. * Creates a new submesh from indices data
  89527. * @param materialIndex the index of the main mesh material
  89528. * @param startIndex the index where to start the copy in the mesh indices array
  89529. * @param indexCount the number of indices to copy then from the startIndex
  89530. * @param mesh the main mesh to create the submesh from
  89531. * @param renderingMesh the optional rendering mesh
  89532. * @returns a new submesh
  89533. */
  89534. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  89535. }
  89536. }
  89537. declare module BABYLON {
  89538. /**
  89539. * Class used to represent data loading progression
  89540. */
  89541. export class SceneLoaderFlags {
  89542. private static _ForceFullSceneLoadingForIncremental;
  89543. private static _ShowLoadingScreen;
  89544. private static _CleanBoneMatrixWeights;
  89545. private static _loggingLevel;
  89546. /**
  89547. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  89548. */
  89549. static ForceFullSceneLoadingForIncremental: boolean;
  89550. /**
  89551. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  89552. */
  89553. static ShowLoadingScreen: boolean;
  89554. /**
  89555. * Defines the current logging level (while loading the scene)
  89556. * @ignorenaming
  89557. */
  89558. static loggingLevel: number;
  89559. /**
  89560. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  89561. */
  89562. static CleanBoneMatrixWeights: boolean;
  89563. }
  89564. }
  89565. declare module BABYLON {
  89566. /**
  89567. * Class used to store geometry data (vertex buffers + index buffer)
  89568. */
  89569. export class Geometry implements IGetSetVerticesData {
  89570. /**
  89571. * Gets or sets the ID of the geometry
  89572. */
  89573. id: string;
  89574. /**
  89575. * Gets or sets the unique ID of the geometry
  89576. */
  89577. uniqueId: number;
  89578. /**
  89579. * Gets the delay loading state of the geometry (none by default which means not delayed)
  89580. */
  89581. delayLoadState: number;
  89582. /**
  89583. * Gets the file containing the data to load when running in delay load state
  89584. */
  89585. delayLoadingFile: Nullable<string>;
  89586. /**
  89587. * Callback called when the geometry is updated
  89588. */
  89589. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  89590. private _scene;
  89591. private _engine;
  89592. private _meshes;
  89593. private _totalVertices;
  89594. /** @hidden */
  89595. _indices: IndicesArray;
  89596. /** @hidden */
  89597. _vertexBuffers: {
  89598. [key: string]: VertexBuffer;
  89599. };
  89600. private _isDisposed;
  89601. private _extend;
  89602. private _boundingBias;
  89603. /** @hidden */
  89604. _delayInfo: Array<string>;
  89605. private _indexBuffer;
  89606. private _indexBufferIsUpdatable;
  89607. /** @hidden */
  89608. _boundingInfo: Nullable<BoundingInfo>;
  89609. /** @hidden */
  89610. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  89611. /** @hidden */
  89612. _softwareSkinningFrameId: number;
  89613. private _vertexArrayObjects;
  89614. private _updatable;
  89615. /** @hidden */
  89616. _positions: Nullable<Vector3[]>;
  89617. /**
  89618. * 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
  89619. */
  89620. /**
  89621. * 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
  89622. */
  89623. boundingBias: Vector2;
  89624. /**
  89625. * Static function used to attach a new empty geometry to a mesh
  89626. * @param mesh defines the mesh to attach the geometry to
  89627. * @returns the new Geometry
  89628. */
  89629. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  89630. /**
  89631. * Creates a new geometry
  89632. * @param id defines the unique ID
  89633. * @param scene defines the hosting scene
  89634. * @param vertexData defines the VertexData used to get geometry data
  89635. * @param updatable defines if geometry must be updatable (false by default)
  89636. * @param mesh defines the mesh that will be associated with the geometry
  89637. */
  89638. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  89639. /**
  89640. * Gets the current extend of the geometry
  89641. */
  89642. readonly extend: {
  89643. minimum: Vector3;
  89644. maximum: Vector3;
  89645. };
  89646. /**
  89647. * Gets the hosting scene
  89648. * @returns the hosting Scene
  89649. */
  89650. getScene(): Scene;
  89651. /**
  89652. * Gets the hosting engine
  89653. * @returns the hosting Engine
  89654. */
  89655. getEngine(): Engine;
  89656. /**
  89657. * Defines if the geometry is ready to use
  89658. * @returns true if the geometry is ready to be used
  89659. */
  89660. isReady(): boolean;
  89661. /**
  89662. * Gets a value indicating that the geometry should not be serialized
  89663. */
  89664. readonly doNotSerialize: boolean;
  89665. /** @hidden */
  89666. _rebuild(): void;
  89667. /**
  89668. * Affects all geometry data in one call
  89669. * @param vertexData defines the geometry data
  89670. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  89671. */
  89672. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  89673. /**
  89674. * Set specific vertex data
  89675. * @param kind defines the data kind (Position, normal, etc...)
  89676. * @param data defines the vertex data to use
  89677. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89678. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89679. */
  89680. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  89681. /**
  89682. * Removes a specific vertex data
  89683. * @param kind defines the data kind (Position, normal, etc...)
  89684. */
  89685. removeVerticesData(kind: string): void;
  89686. /**
  89687. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  89688. * @param buffer defines the vertex buffer to use
  89689. * @param totalVertices defines the total number of vertices for position kind (could be null)
  89690. */
  89691. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  89692. /**
  89693. * Update a specific vertex buffer
  89694. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  89695. * It will do nothing if the buffer is not updatable
  89696. * @param kind defines the data kind (Position, normal, etc...)
  89697. * @param data defines the data to use
  89698. * @param offset defines the offset in the target buffer where to store the data
  89699. * @param useBytes set to true if the offset is in bytes
  89700. */
  89701. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  89702. /**
  89703. * Update a specific vertex buffer
  89704. * This function will create a new buffer if the current one is not updatable
  89705. * @param kind defines the data kind (Position, normal, etc...)
  89706. * @param data defines the data to use
  89707. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  89708. */
  89709. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  89710. private _updateBoundingInfo;
  89711. /** @hidden */
  89712. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  89713. /**
  89714. * Gets total number of vertices
  89715. * @returns the total number of vertices
  89716. */
  89717. getTotalVertices(): number;
  89718. /**
  89719. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89720. * @param kind defines the data kind (Position, normal, etc...)
  89721. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89722. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89723. * @returns a float array containing vertex data
  89724. */
  89725. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89726. /**
  89727. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  89728. * @param kind defines the data kind (Position, normal, etc...)
  89729. * @returns true if the vertex buffer with the specified kind is updatable
  89730. */
  89731. isVertexBufferUpdatable(kind: string): boolean;
  89732. /**
  89733. * Gets a specific vertex buffer
  89734. * @param kind defines the data kind (Position, normal, etc...)
  89735. * @returns a VertexBuffer
  89736. */
  89737. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89738. /**
  89739. * Returns all vertex buffers
  89740. * @return an object holding all vertex buffers indexed by kind
  89741. */
  89742. getVertexBuffers(): Nullable<{
  89743. [key: string]: VertexBuffer;
  89744. }>;
  89745. /**
  89746. * Gets a boolean indicating if specific vertex buffer is present
  89747. * @param kind defines the data kind (Position, normal, etc...)
  89748. * @returns true if data is present
  89749. */
  89750. isVerticesDataPresent(kind: string): boolean;
  89751. /**
  89752. * Gets a list of all attached data kinds (Position, normal, etc...)
  89753. * @returns a list of string containing all kinds
  89754. */
  89755. getVerticesDataKinds(): string[];
  89756. /**
  89757. * Update index buffer
  89758. * @param indices defines the indices to store in the index buffer
  89759. * @param offset defines the offset in the target buffer where to store the data
  89760. * @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)
  89761. */
  89762. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  89763. /**
  89764. * Creates a new index buffer
  89765. * @param indices defines the indices to store in the index buffer
  89766. * @param totalVertices defines the total number of vertices (could be null)
  89767. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89768. */
  89769. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  89770. /**
  89771. * Return the total number of indices
  89772. * @returns the total number of indices
  89773. */
  89774. getTotalIndices(): number;
  89775. /**
  89776. * Gets the index buffer array
  89777. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89778. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89779. * @returns the index buffer array
  89780. */
  89781. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89782. /**
  89783. * Gets the index buffer
  89784. * @return the index buffer
  89785. */
  89786. getIndexBuffer(): Nullable<DataBuffer>;
  89787. /** @hidden */
  89788. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  89789. /**
  89790. * Release the associated resources for a specific mesh
  89791. * @param mesh defines the source mesh
  89792. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  89793. */
  89794. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  89795. /**
  89796. * Apply current geometry to a given mesh
  89797. * @param mesh defines the mesh to apply geometry to
  89798. */
  89799. applyToMesh(mesh: Mesh): void;
  89800. private _updateExtend;
  89801. private _applyToMesh;
  89802. private notifyUpdate;
  89803. /**
  89804. * Load the geometry if it was flagged as delay loaded
  89805. * @param scene defines the hosting scene
  89806. * @param onLoaded defines a callback called when the geometry is loaded
  89807. */
  89808. load(scene: Scene, onLoaded?: () => void): void;
  89809. private _queueLoad;
  89810. /**
  89811. * Invert the geometry to move from a right handed system to a left handed one.
  89812. */
  89813. toLeftHanded(): void;
  89814. /** @hidden */
  89815. _resetPointsArrayCache(): void;
  89816. /** @hidden */
  89817. _generatePointsArray(): boolean;
  89818. /**
  89819. * Gets a value indicating if the geometry is disposed
  89820. * @returns true if the geometry was disposed
  89821. */
  89822. isDisposed(): boolean;
  89823. private _disposeVertexArrayObjects;
  89824. /**
  89825. * Free all associated resources
  89826. */
  89827. dispose(): void;
  89828. /**
  89829. * Clone the current geometry into a new geometry
  89830. * @param id defines the unique ID of the new geometry
  89831. * @returns a new geometry object
  89832. */
  89833. copy(id: string): Geometry;
  89834. /**
  89835. * Serialize the current geometry info (and not the vertices data) into a JSON object
  89836. * @return a JSON representation of the current geometry data (without the vertices data)
  89837. */
  89838. serialize(): any;
  89839. private toNumberArray;
  89840. /**
  89841. * Serialize all vertices data into a JSON oject
  89842. * @returns a JSON representation of the current geometry data
  89843. */
  89844. serializeVerticeData(): any;
  89845. /**
  89846. * Extracts a clone of a mesh geometry
  89847. * @param mesh defines the source mesh
  89848. * @param id defines the unique ID of the new geometry object
  89849. * @returns the new geometry object
  89850. */
  89851. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  89852. /**
  89853. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  89854. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89855. * Be aware Math.random() could cause collisions, but:
  89856. * "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"
  89857. * @returns a string containing a new GUID
  89858. */
  89859. static RandomId(): string;
  89860. /** @hidden */
  89861. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  89862. private static _CleanMatricesWeights;
  89863. /**
  89864. * Create a new geometry from persisted data (Using .babylon file format)
  89865. * @param parsedVertexData defines the persisted data
  89866. * @param scene defines the hosting scene
  89867. * @param rootUrl defines the root url to use to load assets (like delayed data)
  89868. * @returns the new geometry object
  89869. */
  89870. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  89871. }
  89872. }
  89873. declare module BABYLON {
  89874. /**
  89875. * Define an interface for all classes that will get and set the data on vertices
  89876. */
  89877. export interface IGetSetVerticesData {
  89878. /**
  89879. * Gets a boolean indicating if specific vertex data is present
  89880. * @param kind defines the vertex data kind to use
  89881. * @returns true is data kind is present
  89882. */
  89883. isVerticesDataPresent(kind: string): boolean;
  89884. /**
  89885. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89886. * @param kind defines the data kind (Position, normal, etc...)
  89887. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89888. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89889. * @returns a float array containing vertex data
  89890. */
  89891. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89892. /**
  89893. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89894. * @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.
  89895. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89896. * @returns the indices array or an empty array if the mesh has no geometry
  89897. */
  89898. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89899. /**
  89900. * Set specific vertex data
  89901. * @param kind defines the data kind (Position, normal, etc...)
  89902. * @param data defines the vertex data to use
  89903. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89904. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89905. */
  89906. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  89907. /**
  89908. * Update a specific associated vertex buffer
  89909. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89910. * - VertexBuffer.PositionKind
  89911. * - VertexBuffer.UVKind
  89912. * - VertexBuffer.UV2Kind
  89913. * - VertexBuffer.UV3Kind
  89914. * - VertexBuffer.UV4Kind
  89915. * - VertexBuffer.UV5Kind
  89916. * - VertexBuffer.UV6Kind
  89917. * - VertexBuffer.ColorKind
  89918. * - VertexBuffer.MatricesIndicesKind
  89919. * - VertexBuffer.MatricesIndicesExtraKind
  89920. * - VertexBuffer.MatricesWeightsKind
  89921. * - VertexBuffer.MatricesWeightsExtraKind
  89922. * @param data defines the data source
  89923. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89924. * @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)
  89925. */
  89926. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  89927. /**
  89928. * Creates a new index buffer
  89929. * @param indices defines the indices to store in the index buffer
  89930. * @param totalVertices defines the total number of vertices (could be null)
  89931. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89932. */
  89933. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  89934. }
  89935. /**
  89936. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  89937. */
  89938. export class VertexData {
  89939. /**
  89940. * Mesh side orientation : usually the external or front surface
  89941. */
  89942. static readonly FRONTSIDE: number;
  89943. /**
  89944. * Mesh side orientation : usually the internal or back surface
  89945. */
  89946. static readonly BACKSIDE: number;
  89947. /**
  89948. * Mesh side orientation : both internal and external or front and back surfaces
  89949. */
  89950. static readonly DOUBLESIDE: number;
  89951. /**
  89952. * Mesh side orientation : by default, `FRONTSIDE`
  89953. */
  89954. static readonly DEFAULTSIDE: number;
  89955. /**
  89956. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  89957. */
  89958. positions: Nullable<FloatArray>;
  89959. /**
  89960. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  89961. */
  89962. normals: Nullable<FloatArray>;
  89963. /**
  89964. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  89965. */
  89966. tangents: Nullable<FloatArray>;
  89967. /**
  89968. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89969. */
  89970. uvs: Nullable<FloatArray>;
  89971. /**
  89972. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89973. */
  89974. uvs2: Nullable<FloatArray>;
  89975. /**
  89976. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89977. */
  89978. uvs3: Nullable<FloatArray>;
  89979. /**
  89980. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89981. */
  89982. uvs4: Nullable<FloatArray>;
  89983. /**
  89984. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89985. */
  89986. uvs5: Nullable<FloatArray>;
  89987. /**
  89988. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89989. */
  89990. uvs6: Nullable<FloatArray>;
  89991. /**
  89992. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  89993. */
  89994. colors: Nullable<FloatArray>;
  89995. /**
  89996. * 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).
  89997. */
  89998. matricesIndices: Nullable<FloatArray>;
  89999. /**
  90000. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  90001. */
  90002. matricesWeights: Nullable<FloatArray>;
  90003. /**
  90004. * An array extending the number of possible indices
  90005. */
  90006. matricesIndicesExtra: Nullable<FloatArray>;
  90007. /**
  90008. * An array extending the number of possible weights when the number of indices is extended
  90009. */
  90010. matricesWeightsExtra: Nullable<FloatArray>;
  90011. /**
  90012. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  90013. */
  90014. indices: Nullable<IndicesArray>;
  90015. /**
  90016. * Uses the passed data array to set the set the values for the specified kind of data
  90017. * @param data a linear array of floating numbers
  90018. * @param kind the type of data that is being set, eg positions, colors etc
  90019. */
  90020. set(data: FloatArray, kind: string): void;
  90021. /**
  90022. * Associates the vertexData to the passed Mesh.
  90023. * Sets it as updatable or not (default `false`)
  90024. * @param mesh the mesh the vertexData is applied to
  90025. * @param updatable when used and having the value true allows new data to update the vertexData
  90026. * @returns the VertexData
  90027. */
  90028. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  90029. /**
  90030. * Associates the vertexData to the passed Geometry.
  90031. * Sets it as updatable or not (default `false`)
  90032. * @param geometry the geometry the vertexData is applied to
  90033. * @param updatable when used and having the value true allows new data to update the vertexData
  90034. * @returns VertexData
  90035. */
  90036. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  90037. /**
  90038. * Updates the associated mesh
  90039. * @param mesh the mesh to be updated
  90040. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90041. * @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
  90042. * @returns VertexData
  90043. */
  90044. updateMesh(mesh: Mesh): VertexData;
  90045. /**
  90046. * Updates the associated geometry
  90047. * @param geometry the geometry to be updated
  90048. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90049. * @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
  90050. * @returns VertexData.
  90051. */
  90052. updateGeometry(geometry: Geometry): VertexData;
  90053. private _applyTo;
  90054. private _update;
  90055. /**
  90056. * Transforms each position and each normal of the vertexData according to the passed Matrix
  90057. * @param matrix the transforming matrix
  90058. * @returns the VertexData
  90059. */
  90060. transform(matrix: Matrix): VertexData;
  90061. /**
  90062. * Merges the passed VertexData into the current one
  90063. * @param other the VertexData to be merged into the current one
  90064. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  90065. * @returns the modified VertexData
  90066. */
  90067. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  90068. private _mergeElement;
  90069. private _validate;
  90070. /**
  90071. * Serializes the VertexData
  90072. * @returns a serialized object
  90073. */
  90074. serialize(): any;
  90075. /**
  90076. * Extracts the vertexData from a mesh
  90077. * @param mesh the mesh from which to extract the VertexData
  90078. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  90079. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90080. * @returns the object VertexData associated to the passed mesh
  90081. */
  90082. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  90083. /**
  90084. * Extracts the vertexData from the geometry
  90085. * @param geometry the geometry from which to extract the VertexData
  90086. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  90087. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90088. * @returns the object VertexData associated to the passed mesh
  90089. */
  90090. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  90091. private static _ExtractFrom;
  90092. /**
  90093. * Creates the VertexData for a Ribbon
  90094. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  90095. * * pathArray array of paths, each of which an array of successive Vector3
  90096. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  90097. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  90098. * * 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
  90099. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90100. * * 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)
  90101. * * 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)
  90102. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  90103. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  90104. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  90105. * @returns the VertexData of the ribbon
  90106. */
  90107. static CreateRibbon(options: {
  90108. pathArray: Vector3[][];
  90109. closeArray?: boolean;
  90110. closePath?: boolean;
  90111. offset?: number;
  90112. sideOrientation?: number;
  90113. frontUVs?: Vector4;
  90114. backUVs?: Vector4;
  90115. invertUV?: boolean;
  90116. uvs?: Vector2[];
  90117. colors?: Color4[];
  90118. }): VertexData;
  90119. /**
  90120. * Creates the VertexData for a box
  90121. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90122. * * size sets the width, height and depth of the box to the value of size, optional default 1
  90123. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  90124. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  90125. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  90126. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90127. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90128. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90129. * * 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)
  90130. * * 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)
  90131. * @returns the VertexData of the box
  90132. */
  90133. static CreateBox(options: {
  90134. size?: number;
  90135. width?: number;
  90136. height?: number;
  90137. depth?: number;
  90138. faceUV?: Vector4[];
  90139. faceColors?: Color4[];
  90140. sideOrientation?: number;
  90141. frontUVs?: Vector4;
  90142. backUVs?: Vector4;
  90143. }): VertexData;
  90144. /**
  90145. * Creates the VertexData for a tiled box
  90146. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90147. * * faceTiles sets the pattern, tile size and number of tiles for a face
  90148. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90149. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90150. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90151. * @returns the VertexData of the box
  90152. */
  90153. static CreateTiledBox(options: {
  90154. pattern?: number;
  90155. width?: number;
  90156. height?: number;
  90157. depth?: number;
  90158. tileSize?: number;
  90159. tileWidth?: number;
  90160. tileHeight?: number;
  90161. alignHorizontal?: number;
  90162. alignVertical?: number;
  90163. faceUV?: Vector4[];
  90164. faceColors?: Color4[];
  90165. sideOrientation?: number;
  90166. }): VertexData;
  90167. /**
  90168. * Creates the VertexData for a tiled plane
  90169. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90170. * * pattern a limited pattern arrangement depending on the number
  90171. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  90172. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  90173. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  90174. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90175. * * 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)
  90176. * * 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)
  90177. * @returns the VertexData of the tiled plane
  90178. */
  90179. static CreateTiledPlane(options: {
  90180. pattern?: number;
  90181. tileSize?: number;
  90182. tileWidth?: number;
  90183. tileHeight?: number;
  90184. size?: number;
  90185. width?: number;
  90186. height?: number;
  90187. alignHorizontal?: number;
  90188. alignVertical?: number;
  90189. sideOrientation?: number;
  90190. frontUVs?: Vector4;
  90191. backUVs?: Vector4;
  90192. }): VertexData;
  90193. /**
  90194. * Creates the VertexData for an ellipsoid, defaults to a sphere
  90195. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90196. * * segments sets the number of horizontal strips optional, default 32
  90197. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  90198. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  90199. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  90200. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  90201. * * 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
  90202. * * 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
  90203. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90204. * * 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)
  90205. * * 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)
  90206. * @returns the VertexData of the ellipsoid
  90207. */
  90208. static CreateSphere(options: {
  90209. segments?: number;
  90210. diameter?: number;
  90211. diameterX?: number;
  90212. diameterY?: number;
  90213. diameterZ?: number;
  90214. arc?: number;
  90215. slice?: number;
  90216. sideOrientation?: number;
  90217. frontUVs?: Vector4;
  90218. backUVs?: Vector4;
  90219. }): VertexData;
  90220. /**
  90221. * Creates the VertexData for a cylinder, cone or prism
  90222. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90223. * * height sets the height (y direction) of the cylinder, optional, default 2
  90224. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  90225. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  90226. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  90227. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90228. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  90229. * * 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
  90230. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90231. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90232. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  90233. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  90234. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90235. * * 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)
  90236. * * 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)
  90237. * @returns the VertexData of the cylinder, cone or prism
  90238. */
  90239. static CreateCylinder(options: {
  90240. height?: number;
  90241. diameterTop?: number;
  90242. diameterBottom?: number;
  90243. diameter?: number;
  90244. tessellation?: number;
  90245. subdivisions?: number;
  90246. arc?: number;
  90247. faceColors?: Color4[];
  90248. faceUV?: Vector4[];
  90249. hasRings?: boolean;
  90250. enclose?: boolean;
  90251. sideOrientation?: number;
  90252. frontUVs?: Vector4;
  90253. backUVs?: Vector4;
  90254. }): VertexData;
  90255. /**
  90256. * Creates the VertexData for a torus
  90257. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90258. * * diameter the diameter of the torus, optional default 1
  90259. * * thickness the diameter of the tube forming the torus, optional default 0.5
  90260. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90261. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90262. * * 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)
  90263. * * 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)
  90264. * @returns the VertexData of the torus
  90265. */
  90266. static CreateTorus(options: {
  90267. diameter?: number;
  90268. thickness?: number;
  90269. tessellation?: number;
  90270. sideOrientation?: number;
  90271. frontUVs?: Vector4;
  90272. backUVs?: Vector4;
  90273. }): VertexData;
  90274. /**
  90275. * Creates the VertexData of the LineSystem
  90276. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  90277. * - lines an array of lines, each line being an array of successive Vector3
  90278. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  90279. * @returns the VertexData of the LineSystem
  90280. */
  90281. static CreateLineSystem(options: {
  90282. lines: Vector3[][];
  90283. colors?: Nullable<Color4[][]>;
  90284. }): VertexData;
  90285. /**
  90286. * Create the VertexData for a DashedLines
  90287. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  90288. * - points an array successive Vector3
  90289. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  90290. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  90291. * - dashNb the intended total number of dashes, optional, default 200
  90292. * @returns the VertexData for the DashedLines
  90293. */
  90294. static CreateDashedLines(options: {
  90295. points: Vector3[];
  90296. dashSize?: number;
  90297. gapSize?: number;
  90298. dashNb?: number;
  90299. }): VertexData;
  90300. /**
  90301. * Creates the VertexData for a Ground
  90302. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90303. * - width the width (x direction) of the ground, optional, default 1
  90304. * - height the height (z direction) of the ground, optional, default 1
  90305. * - subdivisions the number of subdivisions per side, optional, default 1
  90306. * @returns the VertexData of the Ground
  90307. */
  90308. static CreateGround(options: {
  90309. width?: number;
  90310. height?: number;
  90311. subdivisions?: number;
  90312. subdivisionsX?: number;
  90313. subdivisionsY?: number;
  90314. }): VertexData;
  90315. /**
  90316. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  90317. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90318. * * xmin the ground minimum X coordinate, optional, default -1
  90319. * * zmin the ground minimum Z coordinate, optional, default -1
  90320. * * xmax the ground maximum X coordinate, optional, default 1
  90321. * * zmax the ground maximum Z coordinate, optional, default 1
  90322. * * 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}
  90323. * * 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}
  90324. * @returns the VertexData of the TiledGround
  90325. */
  90326. static CreateTiledGround(options: {
  90327. xmin: number;
  90328. zmin: number;
  90329. xmax: number;
  90330. zmax: number;
  90331. subdivisions?: {
  90332. w: number;
  90333. h: number;
  90334. };
  90335. precision?: {
  90336. w: number;
  90337. h: number;
  90338. };
  90339. }): VertexData;
  90340. /**
  90341. * Creates the VertexData of the Ground designed from a heightmap
  90342. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  90343. * * width the width (x direction) of the ground
  90344. * * height the height (z direction) of the ground
  90345. * * subdivisions the number of subdivisions per side
  90346. * * minHeight the minimum altitude on the ground, optional, default 0
  90347. * * maxHeight the maximum altitude on the ground, optional default 1
  90348. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  90349. * * buffer the array holding the image color data
  90350. * * bufferWidth the width of image
  90351. * * bufferHeight the height of image
  90352. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  90353. * @returns the VertexData of the Ground designed from a heightmap
  90354. */
  90355. static CreateGroundFromHeightMap(options: {
  90356. width: number;
  90357. height: number;
  90358. subdivisions: number;
  90359. minHeight: number;
  90360. maxHeight: number;
  90361. colorFilter: Color3;
  90362. buffer: Uint8Array;
  90363. bufferWidth: number;
  90364. bufferHeight: number;
  90365. alphaFilter: number;
  90366. }): VertexData;
  90367. /**
  90368. * Creates the VertexData for a Plane
  90369. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  90370. * * size sets the width and height of the plane to the value of size, optional default 1
  90371. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  90372. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  90373. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90374. * * 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)
  90375. * * 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)
  90376. * @returns the VertexData of the box
  90377. */
  90378. static CreatePlane(options: {
  90379. size?: number;
  90380. width?: number;
  90381. height?: number;
  90382. sideOrientation?: number;
  90383. frontUVs?: Vector4;
  90384. backUVs?: Vector4;
  90385. }): VertexData;
  90386. /**
  90387. * Creates the VertexData of the Disc or regular Polygon
  90388. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  90389. * * radius the radius of the disc, optional default 0.5
  90390. * * tessellation the number of polygon sides, optional, default 64
  90391. * * 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
  90392. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90393. * * 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)
  90394. * * 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)
  90395. * @returns the VertexData of the box
  90396. */
  90397. static CreateDisc(options: {
  90398. radius?: number;
  90399. tessellation?: number;
  90400. arc?: number;
  90401. sideOrientation?: number;
  90402. frontUVs?: Vector4;
  90403. backUVs?: Vector4;
  90404. }): VertexData;
  90405. /**
  90406. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  90407. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  90408. * @param polygon a mesh built from polygonTriangulation.build()
  90409. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90410. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90411. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90412. * @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)
  90413. * @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)
  90414. * @returns the VertexData of the Polygon
  90415. */
  90416. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  90417. /**
  90418. * Creates the VertexData of the IcoSphere
  90419. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  90420. * * radius the radius of the IcoSphere, optional default 1
  90421. * * radiusX allows stretching in the x direction, optional, default radius
  90422. * * radiusY allows stretching in the y direction, optional, default radius
  90423. * * radiusZ allows stretching in the z direction, optional, default radius
  90424. * * flat when true creates a flat shaded mesh, optional, default true
  90425. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90426. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90427. * * 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)
  90428. * * 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)
  90429. * @returns the VertexData of the IcoSphere
  90430. */
  90431. static CreateIcoSphere(options: {
  90432. radius?: number;
  90433. radiusX?: number;
  90434. radiusY?: number;
  90435. radiusZ?: number;
  90436. flat?: boolean;
  90437. subdivisions?: number;
  90438. sideOrientation?: number;
  90439. frontUVs?: Vector4;
  90440. backUVs?: Vector4;
  90441. }): VertexData;
  90442. /**
  90443. * Creates the VertexData for a Polyhedron
  90444. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  90445. * * type provided types are:
  90446. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  90447. * * 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)
  90448. * * size the size of the IcoSphere, optional default 1
  90449. * * sizeX allows stretching in the x direction, optional, default size
  90450. * * sizeY allows stretching in the y direction, optional, default size
  90451. * * sizeZ allows stretching in the z direction, optional, default size
  90452. * * 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
  90453. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90454. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90455. * * flat when true creates a flat shaded mesh, optional, default true
  90456. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90457. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90458. * * 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)
  90459. * * 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)
  90460. * @returns the VertexData of the Polyhedron
  90461. */
  90462. static CreatePolyhedron(options: {
  90463. type?: number;
  90464. size?: number;
  90465. sizeX?: number;
  90466. sizeY?: number;
  90467. sizeZ?: number;
  90468. custom?: any;
  90469. faceUV?: Vector4[];
  90470. faceColors?: Color4[];
  90471. flat?: boolean;
  90472. sideOrientation?: number;
  90473. frontUVs?: Vector4;
  90474. backUVs?: Vector4;
  90475. }): VertexData;
  90476. /**
  90477. * Creates the VertexData for a TorusKnot
  90478. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  90479. * * radius the radius of the torus knot, optional, default 2
  90480. * * tube the thickness of the tube, optional, default 0.5
  90481. * * radialSegments the number of sides on each tube segments, optional, default 32
  90482. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  90483. * * p the number of windings around the z axis, optional, default 2
  90484. * * q the number of windings around the x axis, optional, default 3
  90485. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90486. * * 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)
  90487. * * 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)
  90488. * @returns the VertexData of the Torus Knot
  90489. */
  90490. static CreateTorusKnot(options: {
  90491. radius?: number;
  90492. tube?: number;
  90493. radialSegments?: number;
  90494. tubularSegments?: number;
  90495. p?: number;
  90496. q?: number;
  90497. sideOrientation?: number;
  90498. frontUVs?: Vector4;
  90499. backUVs?: Vector4;
  90500. }): VertexData;
  90501. /**
  90502. * Compute normals for given positions and indices
  90503. * @param positions an array of vertex positions, [...., x, y, z, ......]
  90504. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  90505. * @param normals an array of vertex normals, [...., x, y, z, ......]
  90506. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  90507. * * facetNormals : optional array of facet normals (vector3)
  90508. * * facetPositions : optional array of facet positions (vector3)
  90509. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  90510. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  90511. * * bInfo : optional bounding info, required for facetPartitioning computation
  90512. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  90513. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  90514. * * useRightHandedSystem: optional boolean to for right handed system computation
  90515. * * depthSort : optional boolean to enable the facet depth sort computation
  90516. * * distanceTo : optional Vector3 to compute the facet depth from this location
  90517. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  90518. */
  90519. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  90520. facetNormals?: any;
  90521. facetPositions?: any;
  90522. facetPartitioning?: any;
  90523. ratio?: number;
  90524. bInfo?: any;
  90525. bbSize?: Vector3;
  90526. subDiv?: any;
  90527. useRightHandedSystem?: boolean;
  90528. depthSort?: boolean;
  90529. distanceTo?: Vector3;
  90530. depthSortedFacets?: any;
  90531. }): void;
  90532. /** @hidden */
  90533. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  90534. /**
  90535. * Applies VertexData created from the imported parameters to the geometry
  90536. * @param parsedVertexData the parsed data from an imported file
  90537. * @param geometry the geometry to apply the VertexData to
  90538. */
  90539. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  90540. }
  90541. }
  90542. declare module BABYLON {
  90543. /**
  90544. * Defines a target to use with MorphTargetManager
  90545. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90546. */
  90547. export class MorphTarget implements IAnimatable {
  90548. /** defines the name of the target */
  90549. name: string;
  90550. /**
  90551. * Gets or sets the list of animations
  90552. */
  90553. animations: Animation[];
  90554. private _scene;
  90555. private _positions;
  90556. private _normals;
  90557. private _tangents;
  90558. private _uvs;
  90559. private _influence;
  90560. private _uniqueId;
  90561. /**
  90562. * Observable raised when the influence changes
  90563. */
  90564. onInfluenceChanged: Observable<boolean>;
  90565. /** @hidden */
  90566. _onDataLayoutChanged: Observable<void>;
  90567. /**
  90568. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  90569. */
  90570. influence: number;
  90571. /**
  90572. * Gets or sets the id of the morph Target
  90573. */
  90574. id: string;
  90575. private _animationPropertiesOverride;
  90576. /**
  90577. * Gets or sets the animation properties override
  90578. */
  90579. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90580. /**
  90581. * Creates a new MorphTarget
  90582. * @param name defines the name of the target
  90583. * @param influence defines the influence to use
  90584. * @param scene defines the scene the morphtarget belongs to
  90585. */
  90586. constructor(
  90587. /** defines the name of the target */
  90588. name: string, influence?: number, scene?: Nullable<Scene>);
  90589. /**
  90590. * Gets the unique ID of this manager
  90591. */
  90592. readonly uniqueId: number;
  90593. /**
  90594. * Gets a boolean defining if the target contains position data
  90595. */
  90596. readonly hasPositions: boolean;
  90597. /**
  90598. * Gets a boolean defining if the target contains normal data
  90599. */
  90600. readonly hasNormals: boolean;
  90601. /**
  90602. * Gets a boolean defining if the target contains tangent data
  90603. */
  90604. readonly hasTangents: boolean;
  90605. /**
  90606. * Gets a boolean defining if the target contains texture coordinates data
  90607. */
  90608. readonly hasUVs: boolean;
  90609. /**
  90610. * Affects position data to this target
  90611. * @param data defines the position data to use
  90612. */
  90613. setPositions(data: Nullable<FloatArray>): void;
  90614. /**
  90615. * Gets the position data stored in this target
  90616. * @returns a FloatArray containing the position data (or null if not present)
  90617. */
  90618. getPositions(): Nullable<FloatArray>;
  90619. /**
  90620. * Affects normal data to this target
  90621. * @param data defines the normal data to use
  90622. */
  90623. setNormals(data: Nullable<FloatArray>): void;
  90624. /**
  90625. * Gets the normal data stored in this target
  90626. * @returns a FloatArray containing the normal data (or null if not present)
  90627. */
  90628. getNormals(): Nullable<FloatArray>;
  90629. /**
  90630. * Affects tangent data to this target
  90631. * @param data defines the tangent data to use
  90632. */
  90633. setTangents(data: Nullable<FloatArray>): void;
  90634. /**
  90635. * Gets the tangent data stored in this target
  90636. * @returns a FloatArray containing the tangent data (or null if not present)
  90637. */
  90638. getTangents(): Nullable<FloatArray>;
  90639. /**
  90640. * Affects texture coordinates data to this target
  90641. * @param data defines the texture coordinates data to use
  90642. */
  90643. setUVs(data: Nullable<FloatArray>): void;
  90644. /**
  90645. * Gets the texture coordinates data stored in this target
  90646. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  90647. */
  90648. getUVs(): Nullable<FloatArray>;
  90649. /**
  90650. * Clone the current target
  90651. * @returns a new MorphTarget
  90652. */
  90653. clone(): MorphTarget;
  90654. /**
  90655. * Serializes the current target into a Serialization object
  90656. * @returns the serialized object
  90657. */
  90658. serialize(): any;
  90659. /**
  90660. * Returns the string "MorphTarget"
  90661. * @returns "MorphTarget"
  90662. */
  90663. getClassName(): string;
  90664. /**
  90665. * Creates a new target from serialized data
  90666. * @param serializationObject defines the serialized data to use
  90667. * @returns a new MorphTarget
  90668. */
  90669. static Parse(serializationObject: any): MorphTarget;
  90670. /**
  90671. * Creates a MorphTarget from mesh data
  90672. * @param mesh defines the source mesh
  90673. * @param name defines the name to use for the new target
  90674. * @param influence defines the influence to attach to the target
  90675. * @returns a new MorphTarget
  90676. */
  90677. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  90678. }
  90679. }
  90680. declare module BABYLON {
  90681. /**
  90682. * This class is used to deform meshes using morphing between different targets
  90683. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90684. */
  90685. export class MorphTargetManager {
  90686. private _targets;
  90687. private _targetInfluenceChangedObservers;
  90688. private _targetDataLayoutChangedObservers;
  90689. private _activeTargets;
  90690. private _scene;
  90691. private _influences;
  90692. private _supportsNormals;
  90693. private _supportsTangents;
  90694. private _supportsUVs;
  90695. private _vertexCount;
  90696. private _uniqueId;
  90697. private _tempInfluences;
  90698. /**
  90699. * Gets or sets a boolean indicating if normals must be morphed
  90700. */
  90701. enableNormalMorphing: boolean;
  90702. /**
  90703. * Gets or sets a boolean indicating if tangents must be morphed
  90704. */
  90705. enableTangentMorphing: boolean;
  90706. /**
  90707. * Gets or sets a boolean indicating if UV must be morphed
  90708. */
  90709. enableUVMorphing: boolean;
  90710. /**
  90711. * Creates a new MorphTargetManager
  90712. * @param scene defines the current scene
  90713. */
  90714. constructor(scene?: Nullable<Scene>);
  90715. /**
  90716. * Gets the unique ID of this manager
  90717. */
  90718. readonly uniqueId: number;
  90719. /**
  90720. * Gets the number of vertices handled by this manager
  90721. */
  90722. readonly vertexCount: number;
  90723. /**
  90724. * Gets a boolean indicating if this manager supports morphing of normals
  90725. */
  90726. readonly supportsNormals: boolean;
  90727. /**
  90728. * Gets a boolean indicating if this manager supports morphing of tangents
  90729. */
  90730. readonly supportsTangents: boolean;
  90731. /**
  90732. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  90733. */
  90734. readonly supportsUVs: boolean;
  90735. /**
  90736. * Gets the number of targets stored in this manager
  90737. */
  90738. readonly numTargets: number;
  90739. /**
  90740. * Gets the number of influencers (ie. the number of targets with influences > 0)
  90741. */
  90742. readonly numInfluencers: number;
  90743. /**
  90744. * Gets the list of influences (one per target)
  90745. */
  90746. readonly influences: Float32Array;
  90747. /**
  90748. * Gets the active target at specified index. An active target is a target with an influence > 0
  90749. * @param index defines the index to check
  90750. * @returns the requested target
  90751. */
  90752. getActiveTarget(index: number): MorphTarget;
  90753. /**
  90754. * Gets the target at specified index
  90755. * @param index defines the index to check
  90756. * @returns the requested target
  90757. */
  90758. getTarget(index: number): MorphTarget;
  90759. /**
  90760. * Add a new target to this manager
  90761. * @param target defines the target to add
  90762. */
  90763. addTarget(target: MorphTarget): void;
  90764. /**
  90765. * Removes a target from the manager
  90766. * @param target defines the target to remove
  90767. */
  90768. removeTarget(target: MorphTarget): void;
  90769. /**
  90770. * Clone the current manager
  90771. * @returns a new MorphTargetManager
  90772. */
  90773. clone(): MorphTargetManager;
  90774. /**
  90775. * Serializes the current manager into a Serialization object
  90776. * @returns the serialized object
  90777. */
  90778. serialize(): any;
  90779. private _syncActiveTargets;
  90780. /**
  90781. * Syncrhonize the targets with all the meshes using this morph target manager
  90782. */
  90783. synchronize(): void;
  90784. /**
  90785. * Creates a new MorphTargetManager from serialized data
  90786. * @param serializationObject defines the serialized data
  90787. * @param scene defines the hosting scene
  90788. * @returns the new MorphTargetManager
  90789. */
  90790. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  90791. }
  90792. }
  90793. declare module BABYLON {
  90794. /**
  90795. * Class used to represent a specific level of detail of a mesh
  90796. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90797. */
  90798. export class MeshLODLevel {
  90799. /** Defines the distance where this level should start being displayed */
  90800. distance: number;
  90801. /** Defines the mesh to use to render this level */
  90802. mesh: Nullable<Mesh>;
  90803. /**
  90804. * Creates a new LOD level
  90805. * @param distance defines the distance where this level should star being displayed
  90806. * @param mesh defines the mesh to use to render this level
  90807. */
  90808. constructor(
  90809. /** Defines the distance where this level should start being displayed */
  90810. distance: number,
  90811. /** Defines the mesh to use to render this level */
  90812. mesh: Nullable<Mesh>);
  90813. }
  90814. }
  90815. declare module BABYLON {
  90816. /**
  90817. * Mesh representing the gorund
  90818. */
  90819. export class GroundMesh extends Mesh {
  90820. /** If octree should be generated */
  90821. generateOctree: boolean;
  90822. private _heightQuads;
  90823. /** @hidden */
  90824. _subdivisionsX: number;
  90825. /** @hidden */
  90826. _subdivisionsY: number;
  90827. /** @hidden */
  90828. _width: number;
  90829. /** @hidden */
  90830. _height: number;
  90831. /** @hidden */
  90832. _minX: number;
  90833. /** @hidden */
  90834. _maxX: number;
  90835. /** @hidden */
  90836. _minZ: number;
  90837. /** @hidden */
  90838. _maxZ: number;
  90839. constructor(name: string, scene: Scene);
  90840. /**
  90841. * "GroundMesh"
  90842. * @returns "GroundMesh"
  90843. */
  90844. getClassName(): string;
  90845. /**
  90846. * The minimum of x and y subdivisions
  90847. */
  90848. readonly subdivisions: number;
  90849. /**
  90850. * X subdivisions
  90851. */
  90852. readonly subdivisionsX: number;
  90853. /**
  90854. * Y subdivisions
  90855. */
  90856. readonly subdivisionsY: number;
  90857. /**
  90858. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  90859. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  90860. * @param chunksCount the number of subdivisions for x and y
  90861. * @param octreeBlocksSize (Default: 32)
  90862. */
  90863. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  90864. /**
  90865. * Returns a height (y) value in the Worl system :
  90866. * the ground altitude at the coordinates (x, z) expressed in the World system.
  90867. * @param x x coordinate
  90868. * @param z z coordinate
  90869. * @returns the ground y position if (x, z) are outside the ground surface.
  90870. */
  90871. getHeightAtCoordinates(x: number, z: number): number;
  90872. /**
  90873. * Returns a normalized vector (Vector3) orthogonal to the ground
  90874. * at the ground coordinates (x, z) expressed in the World system.
  90875. * @param x x coordinate
  90876. * @param z z coordinate
  90877. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  90878. */
  90879. getNormalAtCoordinates(x: number, z: number): Vector3;
  90880. /**
  90881. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  90882. * at the ground coordinates (x, z) expressed in the World system.
  90883. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  90884. * @param x x coordinate
  90885. * @param z z coordinate
  90886. * @param ref vector to store the result
  90887. * @returns the GroundMesh.
  90888. */
  90889. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  90890. /**
  90891. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  90892. * if the ground has been updated.
  90893. * This can be used in the render loop.
  90894. * @returns the GroundMesh.
  90895. */
  90896. updateCoordinateHeights(): GroundMesh;
  90897. private _getFacetAt;
  90898. private _initHeightQuads;
  90899. private _computeHeightQuads;
  90900. /**
  90901. * Serializes this ground mesh
  90902. * @param serializationObject object to write serialization to
  90903. */
  90904. serialize(serializationObject: any): void;
  90905. /**
  90906. * Parses a serialized ground mesh
  90907. * @param parsedMesh the serialized mesh
  90908. * @param scene the scene to create the ground mesh in
  90909. * @returns the created ground mesh
  90910. */
  90911. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  90912. }
  90913. }
  90914. declare module BABYLON {
  90915. /**
  90916. * Interface for Physics-Joint data
  90917. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90918. */
  90919. export interface PhysicsJointData {
  90920. /**
  90921. * The main pivot of the joint
  90922. */
  90923. mainPivot?: Vector3;
  90924. /**
  90925. * The connected pivot of the joint
  90926. */
  90927. connectedPivot?: Vector3;
  90928. /**
  90929. * The main axis of the joint
  90930. */
  90931. mainAxis?: Vector3;
  90932. /**
  90933. * The connected axis of the joint
  90934. */
  90935. connectedAxis?: Vector3;
  90936. /**
  90937. * The collision of the joint
  90938. */
  90939. collision?: boolean;
  90940. /**
  90941. * Native Oimo/Cannon/Energy data
  90942. */
  90943. nativeParams?: any;
  90944. }
  90945. /**
  90946. * This is a holder class for the physics joint created by the physics plugin
  90947. * It holds a set of functions to control the underlying joint
  90948. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90949. */
  90950. export class PhysicsJoint {
  90951. /**
  90952. * The type of the physics joint
  90953. */
  90954. type: number;
  90955. /**
  90956. * The data for the physics joint
  90957. */
  90958. jointData: PhysicsJointData;
  90959. private _physicsJoint;
  90960. protected _physicsPlugin: IPhysicsEnginePlugin;
  90961. /**
  90962. * Initializes the physics joint
  90963. * @param type The type of the physics joint
  90964. * @param jointData The data for the physics joint
  90965. */
  90966. constructor(
  90967. /**
  90968. * The type of the physics joint
  90969. */
  90970. type: number,
  90971. /**
  90972. * The data for the physics joint
  90973. */
  90974. jointData: PhysicsJointData);
  90975. /**
  90976. * Gets the physics joint
  90977. */
  90978. /**
  90979. * Sets the physics joint
  90980. */
  90981. physicsJoint: any;
  90982. /**
  90983. * Sets the physics plugin
  90984. */
  90985. physicsPlugin: IPhysicsEnginePlugin;
  90986. /**
  90987. * Execute a function that is physics-plugin specific.
  90988. * @param {Function} func the function that will be executed.
  90989. * It accepts two parameters: the physics world and the physics joint
  90990. */
  90991. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  90992. /**
  90993. * Distance-Joint type
  90994. */
  90995. static DistanceJoint: number;
  90996. /**
  90997. * Hinge-Joint type
  90998. */
  90999. static HingeJoint: number;
  91000. /**
  91001. * Ball-and-Socket joint type
  91002. */
  91003. static BallAndSocketJoint: number;
  91004. /**
  91005. * Wheel-Joint type
  91006. */
  91007. static WheelJoint: number;
  91008. /**
  91009. * Slider-Joint type
  91010. */
  91011. static SliderJoint: number;
  91012. /**
  91013. * Prismatic-Joint type
  91014. */
  91015. static PrismaticJoint: number;
  91016. /**
  91017. * Universal-Joint type
  91018. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  91019. */
  91020. static UniversalJoint: number;
  91021. /**
  91022. * Hinge-Joint 2 type
  91023. */
  91024. static Hinge2Joint: number;
  91025. /**
  91026. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  91027. */
  91028. static PointToPointJoint: number;
  91029. /**
  91030. * Spring-Joint type
  91031. */
  91032. static SpringJoint: number;
  91033. /**
  91034. * Lock-Joint type
  91035. */
  91036. static LockJoint: number;
  91037. }
  91038. /**
  91039. * A class representing a physics distance joint
  91040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91041. */
  91042. export class DistanceJoint extends PhysicsJoint {
  91043. /**
  91044. *
  91045. * @param jointData The data for the Distance-Joint
  91046. */
  91047. constructor(jointData: DistanceJointData);
  91048. /**
  91049. * Update the predefined distance.
  91050. * @param maxDistance The maximum preferred distance
  91051. * @param minDistance The minimum preferred distance
  91052. */
  91053. updateDistance(maxDistance: number, minDistance?: number): void;
  91054. }
  91055. /**
  91056. * Represents a Motor-Enabled Joint
  91057. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91058. */
  91059. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  91060. /**
  91061. * Initializes the Motor-Enabled Joint
  91062. * @param type The type of the joint
  91063. * @param jointData The physica joint data for the joint
  91064. */
  91065. constructor(type: number, jointData: PhysicsJointData);
  91066. /**
  91067. * Set the motor values.
  91068. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91069. * @param force the force to apply
  91070. * @param maxForce max force for this motor.
  91071. */
  91072. setMotor(force?: number, maxForce?: number): void;
  91073. /**
  91074. * Set the motor's limits.
  91075. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91076. * @param upperLimit The upper limit of the motor
  91077. * @param lowerLimit The lower limit of the motor
  91078. */
  91079. setLimit(upperLimit: number, lowerLimit?: number): void;
  91080. }
  91081. /**
  91082. * This class represents a single physics Hinge-Joint
  91083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91084. */
  91085. export class HingeJoint extends MotorEnabledJoint {
  91086. /**
  91087. * Initializes the Hinge-Joint
  91088. * @param jointData The joint data for the Hinge-Joint
  91089. */
  91090. constructor(jointData: PhysicsJointData);
  91091. /**
  91092. * Set the motor values.
  91093. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91094. * @param {number} force the force to apply
  91095. * @param {number} maxForce max force for this motor.
  91096. */
  91097. setMotor(force?: number, maxForce?: number): void;
  91098. /**
  91099. * Set the motor's limits.
  91100. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91101. * @param upperLimit The upper limit of the motor
  91102. * @param lowerLimit The lower limit of the motor
  91103. */
  91104. setLimit(upperLimit: number, lowerLimit?: number): void;
  91105. }
  91106. /**
  91107. * This class represents a dual hinge physics joint (same as wheel joint)
  91108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91109. */
  91110. export class Hinge2Joint extends MotorEnabledJoint {
  91111. /**
  91112. * Initializes the Hinge2-Joint
  91113. * @param jointData The joint data for the Hinge2-Joint
  91114. */
  91115. constructor(jointData: PhysicsJointData);
  91116. /**
  91117. * Set the motor values.
  91118. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91119. * @param {number} targetSpeed the speed the motor is to reach
  91120. * @param {number} maxForce max force for this motor.
  91121. * @param {motorIndex} the motor's index, 0 or 1.
  91122. */
  91123. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  91124. /**
  91125. * Set the motor limits.
  91126. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91127. * @param {number} upperLimit the upper limit
  91128. * @param {number} lowerLimit lower limit
  91129. * @param {motorIndex} the motor's index, 0 or 1.
  91130. */
  91131. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91132. }
  91133. /**
  91134. * Interface for a motor enabled joint
  91135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91136. */
  91137. export interface IMotorEnabledJoint {
  91138. /**
  91139. * Physics joint
  91140. */
  91141. physicsJoint: any;
  91142. /**
  91143. * Sets the motor of the motor-enabled joint
  91144. * @param force The force of the motor
  91145. * @param maxForce The maximum force of the motor
  91146. * @param motorIndex The index of the motor
  91147. */
  91148. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  91149. /**
  91150. * Sets the limit of the motor
  91151. * @param upperLimit The upper limit of the motor
  91152. * @param lowerLimit The lower limit of the motor
  91153. * @param motorIndex The index of the motor
  91154. */
  91155. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91156. }
  91157. /**
  91158. * Joint data for a Distance-Joint
  91159. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91160. */
  91161. export interface DistanceJointData extends PhysicsJointData {
  91162. /**
  91163. * Max distance the 2 joint objects can be apart
  91164. */
  91165. maxDistance: number;
  91166. }
  91167. /**
  91168. * Joint data from a spring joint
  91169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91170. */
  91171. export interface SpringJointData extends PhysicsJointData {
  91172. /**
  91173. * Length of the spring
  91174. */
  91175. length: number;
  91176. /**
  91177. * Stiffness of the spring
  91178. */
  91179. stiffness: number;
  91180. /**
  91181. * Damping of the spring
  91182. */
  91183. damping: number;
  91184. /** this callback will be called when applying the force to the impostors. */
  91185. forceApplicationCallback: () => void;
  91186. }
  91187. }
  91188. declare module BABYLON {
  91189. /**
  91190. * Holds the data for the raycast result
  91191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91192. */
  91193. export class PhysicsRaycastResult {
  91194. private _hasHit;
  91195. private _hitDistance;
  91196. private _hitNormalWorld;
  91197. private _hitPointWorld;
  91198. private _rayFromWorld;
  91199. private _rayToWorld;
  91200. /**
  91201. * Gets if there was a hit
  91202. */
  91203. readonly hasHit: boolean;
  91204. /**
  91205. * Gets the distance from the hit
  91206. */
  91207. readonly hitDistance: number;
  91208. /**
  91209. * Gets the hit normal/direction in the world
  91210. */
  91211. readonly hitNormalWorld: Vector3;
  91212. /**
  91213. * Gets the hit point in the world
  91214. */
  91215. readonly hitPointWorld: Vector3;
  91216. /**
  91217. * Gets the ray "start point" of the ray in the world
  91218. */
  91219. readonly rayFromWorld: Vector3;
  91220. /**
  91221. * Gets the ray "end point" of the ray in the world
  91222. */
  91223. readonly rayToWorld: Vector3;
  91224. /**
  91225. * Sets the hit data (normal & point in world space)
  91226. * @param hitNormalWorld defines the normal in world space
  91227. * @param hitPointWorld defines the point in world space
  91228. */
  91229. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  91230. /**
  91231. * Sets the distance from the start point to the hit point
  91232. * @param distance
  91233. */
  91234. setHitDistance(distance: number): void;
  91235. /**
  91236. * Calculates the distance manually
  91237. */
  91238. calculateHitDistance(): void;
  91239. /**
  91240. * Resets all the values to default
  91241. * @param from The from point on world space
  91242. * @param to The to point on world space
  91243. */
  91244. reset(from?: Vector3, to?: Vector3): void;
  91245. }
  91246. /**
  91247. * Interface for the size containing width and height
  91248. */
  91249. interface IXYZ {
  91250. /**
  91251. * X
  91252. */
  91253. x: number;
  91254. /**
  91255. * Y
  91256. */
  91257. y: number;
  91258. /**
  91259. * Z
  91260. */
  91261. z: number;
  91262. }
  91263. }
  91264. declare module BABYLON {
  91265. /**
  91266. * Interface used to describe a physics joint
  91267. */
  91268. export interface PhysicsImpostorJoint {
  91269. /** Defines the main impostor to which the joint is linked */
  91270. mainImpostor: PhysicsImpostor;
  91271. /** Defines the impostor that is connected to the main impostor using this joint */
  91272. connectedImpostor: PhysicsImpostor;
  91273. /** Defines the joint itself */
  91274. joint: PhysicsJoint;
  91275. }
  91276. /** @hidden */
  91277. export interface IPhysicsEnginePlugin {
  91278. world: any;
  91279. name: string;
  91280. setGravity(gravity: Vector3): void;
  91281. setTimeStep(timeStep: number): void;
  91282. getTimeStep(): number;
  91283. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  91284. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91285. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91286. generatePhysicsBody(impostor: PhysicsImpostor): void;
  91287. removePhysicsBody(impostor: PhysicsImpostor): void;
  91288. generateJoint(joint: PhysicsImpostorJoint): void;
  91289. removeJoint(joint: PhysicsImpostorJoint): void;
  91290. isSupported(): boolean;
  91291. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  91292. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  91293. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91294. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91295. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91296. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91297. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  91298. getBodyMass(impostor: PhysicsImpostor): number;
  91299. getBodyFriction(impostor: PhysicsImpostor): number;
  91300. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  91301. getBodyRestitution(impostor: PhysicsImpostor): number;
  91302. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  91303. getBodyPressure?(impostor: PhysicsImpostor): number;
  91304. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  91305. getBodyStiffness?(impostor: PhysicsImpostor): number;
  91306. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  91307. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  91308. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  91309. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  91310. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  91311. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  91312. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  91313. sleepBody(impostor: PhysicsImpostor): void;
  91314. wakeUpBody(impostor: PhysicsImpostor): void;
  91315. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91316. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  91317. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  91318. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91319. getRadius(impostor: PhysicsImpostor): number;
  91320. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  91321. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  91322. dispose(): void;
  91323. }
  91324. /**
  91325. * Interface used to define a physics engine
  91326. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  91327. */
  91328. export interface IPhysicsEngine {
  91329. /**
  91330. * Gets the gravity vector used by the simulation
  91331. */
  91332. gravity: Vector3;
  91333. /**
  91334. * Sets the gravity vector used by the simulation
  91335. * @param gravity defines the gravity vector to use
  91336. */
  91337. setGravity(gravity: Vector3): void;
  91338. /**
  91339. * Set the time step of the physics engine.
  91340. * Default is 1/60.
  91341. * To slow it down, enter 1/600 for example.
  91342. * To speed it up, 1/30
  91343. * @param newTimeStep the new timestep to apply to this world.
  91344. */
  91345. setTimeStep(newTimeStep: number): void;
  91346. /**
  91347. * Get the time step of the physics engine.
  91348. * @returns the current time step
  91349. */
  91350. getTimeStep(): number;
  91351. /**
  91352. * Release all resources
  91353. */
  91354. dispose(): void;
  91355. /**
  91356. * Gets the name of the current physics plugin
  91357. * @returns the name of the plugin
  91358. */
  91359. getPhysicsPluginName(): string;
  91360. /**
  91361. * Adding a new impostor for the impostor tracking.
  91362. * This will be done by the impostor itself.
  91363. * @param impostor the impostor to add
  91364. */
  91365. addImpostor(impostor: PhysicsImpostor): void;
  91366. /**
  91367. * Remove an impostor from the engine.
  91368. * This impostor and its mesh will not longer be updated by the physics engine.
  91369. * @param impostor the impostor to remove
  91370. */
  91371. removeImpostor(impostor: PhysicsImpostor): void;
  91372. /**
  91373. * Add a joint to the physics engine
  91374. * @param mainImpostor defines the main impostor to which the joint is added.
  91375. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  91376. * @param joint defines the joint that will connect both impostors.
  91377. */
  91378. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  91379. /**
  91380. * Removes a joint from the simulation
  91381. * @param mainImpostor defines the impostor used with the joint
  91382. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  91383. * @param joint defines the joint to remove
  91384. */
  91385. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  91386. /**
  91387. * Gets the current plugin used to run the simulation
  91388. * @returns current plugin
  91389. */
  91390. getPhysicsPlugin(): IPhysicsEnginePlugin;
  91391. /**
  91392. * Gets the list of physic impostors
  91393. * @returns an array of PhysicsImpostor
  91394. */
  91395. getImpostors(): Array<PhysicsImpostor>;
  91396. /**
  91397. * Gets the impostor for a physics enabled object
  91398. * @param object defines the object impersonated by the impostor
  91399. * @returns the PhysicsImpostor or null if not found
  91400. */
  91401. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91402. /**
  91403. * Gets the impostor for a physics body object
  91404. * @param body defines physics body used by the impostor
  91405. * @returns the PhysicsImpostor or null if not found
  91406. */
  91407. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  91408. /**
  91409. * Does a raycast in the physics world
  91410. * @param from when should the ray start?
  91411. * @param to when should the ray end?
  91412. * @returns PhysicsRaycastResult
  91413. */
  91414. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91415. /**
  91416. * Called by the scene. No need to call it.
  91417. * @param delta defines the timespam between frames
  91418. */
  91419. _step(delta: number): void;
  91420. }
  91421. }
  91422. declare module BABYLON {
  91423. /**
  91424. * The interface for the physics imposter parameters
  91425. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91426. */
  91427. export interface PhysicsImpostorParameters {
  91428. /**
  91429. * The mass of the physics imposter
  91430. */
  91431. mass: number;
  91432. /**
  91433. * The friction of the physics imposter
  91434. */
  91435. friction?: number;
  91436. /**
  91437. * The coefficient of restitution of the physics imposter
  91438. */
  91439. restitution?: number;
  91440. /**
  91441. * The native options of the physics imposter
  91442. */
  91443. nativeOptions?: any;
  91444. /**
  91445. * Specifies if the parent should be ignored
  91446. */
  91447. ignoreParent?: boolean;
  91448. /**
  91449. * Specifies if bi-directional transformations should be disabled
  91450. */
  91451. disableBidirectionalTransformation?: boolean;
  91452. /**
  91453. * The pressure inside the physics imposter, soft object only
  91454. */
  91455. pressure?: number;
  91456. /**
  91457. * The stiffness the physics imposter, soft object only
  91458. */
  91459. stiffness?: number;
  91460. /**
  91461. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  91462. */
  91463. velocityIterations?: number;
  91464. /**
  91465. * The number of iterations used in maintaining consistent vertex positions, soft object only
  91466. */
  91467. positionIterations?: number;
  91468. /**
  91469. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  91470. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  91471. * Add to fix multiple points
  91472. */
  91473. fixedPoints?: number;
  91474. /**
  91475. * The collision margin around a soft object
  91476. */
  91477. margin?: number;
  91478. /**
  91479. * The collision margin around a soft object
  91480. */
  91481. damping?: number;
  91482. /**
  91483. * The path for a rope based on an extrusion
  91484. */
  91485. path?: any;
  91486. /**
  91487. * The shape of an extrusion used for a rope based on an extrusion
  91488. */
  91489. shape?: any;
  91490. }
  91491. /**
  91492. * Interface for a physics-enabled object
  91493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91494. */
  91495. export interface IPhysicsEnabledObject {
  91496. /**
  91497. * The position of the physics-enabled object
  91498. */
  91499. position: Vector3;
  91500. /**
  91501. * The rotation of the physics-enabled object
  91502. */
  91503. rotationQuaternion: Nullable<Quaternion>;
  91504. /**
  91505. * The scale of the physics-enabled object
  91506. */
  91507. scaling: Vector3;
  91508. /**
  91509. * The rotation of the physics-enabled object
  91510. */
  91511. rotation?: Vector3;
  91512. /**
  91513. * The parent of the physics-enabled object
  91514. */
  91515. parent?: any;
  91516. /**
  91517. * The bounding info of the physics-enabled object
  91518. * @returns The bounding info of the physics-enabled object
  91519. */
  91520. getBoundingInfo(): BoundingInfo;
  91521. /**
  91522. * Computes the world matrix
  91523. * @param force Specifies if the world matrix should be computed by force
  91524. * @returns A world matrix
  91525. */
  91526. computeWorldMatrix(force: boolean): Matrix;
  91527. /**
  91528. * Gets the world matrix
  91529. * @returns A world matrix
  91530. */
  91531. getWorldMatrix?(): Matrix;
  91532. /**
  91533. * Gets the child meshes
  91534. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  91535. * @returns An array of abstract meshes
  91536. */
  91537. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  91538. /**
  91539. * Gets the vertex data
  91540. * @param kind The type of vertex data
  91541. * @returns A nullable array of numbers, or a float32 array
  91542. */
  91543. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  91544. /**
  91545. * Gets the indices from the mesh
  91546. * @returns A nullable array of index arrays
  91547. */
  91548. getIndices?(): Nullable<IndicesArray>;
  91549. /**
  91550. * Gets the scene from the mesh
  91551. * @returns the indices array or null
  91552. */
  91553. getScene?(): Scene;
  91554. /**
  91555. * Gets the absolute position from the mesh
  91556. * @returns the absolute position
  91557. */
  91558. getAbsolutePosition(): Vector3;
  91559. /**
  91560. * Gets the absolute pivot point from the mesh
  91561. * @returns the absolute pivot point
  91562. */
  91563. getAbsolutePivotPoint(): Vector3;
  91564. /**
  91565. * Rotates the mesh
  91566. * @param axis The axis of rotation
  91567. * @param amount The amount of rotation
  91568. * @param space The space of the rotation
  91569. * @returns The rotation transform node
  91570. */
  91571. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  91572. /**
  91573. * Translates the mesh
  91574. * @param axis The axis of translation
  91575. * @param distance The distance of translation
  91576. * @param space The space of the translation
  91577. * @returns The transform node
  91578. */
  91579. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  91580. /**
  91581. * Sets the absolute position of the mesh
  91582. * @param absolutePosition The absolute position of the mesh
  91583. * @returns The transform node
  91584. */
  91585. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  91586. /**
  91587. * Gets the class name of the mesh
  91588. * @returns The class name
  91589. */
  91590. getClassName(): string;
  91591. }
  91592. /**
  91593. * Represents a physics imposter
  91594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91595. */
  91596. export class PhysicsImpostor {
  91597. /**
  91598. * The physics-enabled object used as the physics imposter
  91599. */
  91600. object: IPhysicsEnabledObject;
  91601. /**
  91602. * The type of the physics imposter
  91603. */
  91604. type: number;
  91605. private _options;
  91606. private _scene?;
  91607. /**
  91608. * The default object size of the imposter
  91609. */
  91610. static DEFAULT_OBJECT_SIZE: Vector3;
  91611. /**
  91612. * The identity quaternion of the imposter
  91613. */
  91614. static IDENTITY_QUATERNION: Quaternion;
  91615. /** @hidden */
  91616. _pluginData: any;
  91617. private _physicsEngine;
  91618. private _physicsBody;
  91619. private _bodyUpdateRequired;
  91620. private _onBeforePhysicsStepCallbacks;
  91621. private _onAfterPhysicsStepCallbacks;
  91622. /** @hidden */
  91623. _onPhysicsCollideCallbacks: Array<{
  91624. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  91625. otherImpostors: Array<PhysicsImpostor>;
  91626. }>;
  91627. private _deltaPosition;
  91628. private _deltaRotation;
  91629. private _deltaRotationConjugated;
  91630. /** @hidden */
  91631. _isFromLine: boolean;
  91632. private _parent;
  91633. private _isDisposed;
  91634. private static _tmpVecs;
  91635. private static _tmpQuat;
  91636. /**
  91637. * Specifies if the physics imposter is disposed
  91638. */
  91639. readonly isDisposed: boolean;
  91640. /**
  91641. * Gets the mass of the physics imposter
  91642. */
  91643. mass: number;
  91644. /**
  91645. * Gets the coefficient of friction
  91646. */
  91647. /**
  91648. * Sets the coefficient of friction
  91649. */
  91650. friction: number;
  91651. /**
  91652. * Gets the coefficient of restitution
  91653. */
  91654. /**
  91655. * Sets the coefficient of restitution
  91656. */
  91657. restitution: number;
  91658. /**
  91659. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  91660. */
  91661. /**
  91662. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  91663. */
  91664. pressure: number;
  91665. /**
  91666. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91667. */
  91668. /**
  91669. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91670. */
  91671. stiffness: number;
  91672. /**
  91673. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91674. */
  91675. /**
  91676. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91677. */
  91678. velocityIterations: number;
  91679. /**
  91680. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91681. */
  91682. /**
  91683. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91684. */
  91685. positionIterations: number;
  91686. /**
  91687. * The unique id of the physics imposter
  91688. * set by the physics engine when adding this impostor to the array
  91689. */
  91690. uniqueId: number;
  91691. /**
  91692. * @hidden
  91693. */
  91694. soft: boolean;
  91695. /**
  91696. * @hidden
  91697. */
  91698. segments: number;
  91699. private _joints;
  91700. /**
  91701. * Initializes the physics imposter
  91702. * @param object The physics-enabled object used as the physics imposter
  91703. * @param type The type of the physics imposter
  91704. * @param _options The options for the physics imposter
  91705. * @param _scene The Babylon scene
  91706. */
  91707. constructor(
  91708. /**
  91709. * The physics-enabled object used as the physics imposter
  91710. */
  91711. object: IPhysicsEnabledObject,
  91712. /**
  91713. * The type of the physics imposter
  91714. */
  91715. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  91716. /**
  91717. * This function will completly initialize this impostor.
  91718. * It will create a new body - but only if this mesh has no parent.
  91719. * If it has, this impostor will not be used other than to define the impostor
  91720. * of the child mesh.
  91721. * @hidden
  91722. */
  91723. _init(): void;
  91724. private _getPhysicsParent;
  91725. /**
  91726. * Should a new body be generated.
  91727. * @returns boolean specifying if body initialization is required
  91728. */
  91729. isBodyInitRequired(): boolean;
  91730. /**
  91731. * Sets the updated scaling
  91732. * @param updated Specifies if the scaling is updated
  91733. */
  91734. setScalingUpdated(): void;
  91735. /**
  91736. * Force a regeneration of this or the parent's impostor's body.
  91737. * Use under cautious - This will remove all joints already implemented.
  91738. */
  91739. forceUpdate(): void;
  91740. /**
  91741. * Gets the body that holds this impostor. Either its own, or its parent.
  91742. */
  91743. /**
  91744. * Set the physics body. Used mainly by the physics engine/plugin
  91745. */
  91746. physicsBody: any;
  91747. /**
  91748. * Get the parent of the physics imposter
  91749. * @returns Physics imposter or null
  91750. */
  91751. /**
  91752. * Sets the parent of the physics imposter
  91753. */
  91754. parent: Nullable<PhysicsImpostor>;
  91755. /**
  91756. * Resets the update flags
  91757. */
  91758. resetUpdateFlags(): void;
  91759. /**
  91760. * Gets the object extend size
  91761. * @returns the object extend size
  91762. */
  91763. getObjectExtendSize(): Vector3;
  91764. /**
  91765. * Gets the object center
  91766. * @returns The object center
  91767. */
  91768. getObjectCenter(): Vector3;
  91769. /**
  91770. * Get a specific parametes from the options parameter
  91771. * @param paramName The object parameter name
  91772. * @returns The object parameter
  91773. */
  91774. getParam(paramName: string): any;
  91775. /**
  91776. * Sets a specific parameter in the options given to the physics plugin
  91777. * @param paramName The parameter name
  91778. * @param value The value of the parameter
  91779. */
  91780. setParam(paramName: string, value: number): void;
  91781. /**
  91782. * Specifically change the body's mass option. Won't recreate the physics body object
  91783. * @param mass The mass of the physics imposter
  91784. */
  91785. setMass(mass: number): void;
  91786. /**
  91787. * Gets the linear velocity
  91788. * @returns linear velocity or null
  91789. */
  91790. getLinearVelocity(): Nullable<Vector3>;
  91791. /**
  91792. * Sets the linear velocity
  91793. * @param velocity linear velocity or null
  91794. */
  91795. setLinearVelocity(velocity: Nullable<Vector3>): void;
  91796. /**
  91797. * Gets the angular velocity
  91798. * @returns angular velocity or null
  91799. */
  91800. getAngularVelocity(): Nullable<Vector3>;
  91801. /**
  91802. * Sets the angular velocity
  91803. * @param velocity The velocity or null
  91804. */
  91805. setAngularVelocity(velocity: Nullable<Vector3>): void;
  91806. /**
  91807. * Execute a function with the physics plugin native code
  91808. * Provide a function the will have two variables - the world object and the physics body object
  91809. * @param func The function to execute with the physics plugin native code
  91810. */
  91811. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  91812. /**
  91813. * Register a function that will be executed before the physics world is stepping forward
  91814. * @param func The function to execute before the physics world is stepped forward
  91815. */
  91816. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91817. /**
  91818. * Unregister a function that will be executed before the physics world is stepping forward
  91819. * @param func The function to execute before the physics world is stepped forward
  91820. */
  91821. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91822. /**
  91823. * Register a function that will be executed after the physics step
  91824. * @param func The function to execute after physics step
  91825. */
  91826. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91827. /**
  91828. * Unregisters a function that will be executed after the physics step
  91829. * @param func The function to execute after physics step
  91830. */
  91831. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91832. /**
  91833. * register a function that will be executed when this impostor collides against a different body
  91834. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  91835. * @param func Callback that is executed on collision
  91836. */
  91837. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  91838. /**
  91839. * Unregisters the physics imposter on contact
  91840. * @param collideAgainst The physics object to collide against
  91841. * @param func Callback to execute on collision
  91842. */
  91843. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  91844. private _tmpQuat;
  91845. private _tmpQuat2;
  91846. /**
  91847. * Get the parent rotation
  91848. * @returns The parent rotation
  91849. */
  91850. getParentsRotation(): Quaternion;
  91851. /**
  91852. * this function is executed by the physics engine.
  91853. */
  91854. beforeStep: () => void;
  91855. /**
  91856. * this function is executed by the physics engine
  91857. */
  91858. afterStep: () => void;
  91859. /**
  91860. * Legacy collision detection event support
  91861. */
  91862. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  91863. /**
  91864. * event and body object due to cannon's event-based architecture.
  91865. */
  91866. onCollide: (e: {
  91867. body: any;
  91868. }) => void;
  91869. /**
  91870. * Apply a force
  91871. * @param force The force to apply
  91872. * @param contactPoint The contact point for the force
  91873. * @returns The physics imposter
  91874. */
  91875. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91876. /**
  91877. * Apply an impulse
  91878. * @param force The impulse force
  91879. * @param contactPoint The contact point for the impulse force
  91880. * @returns The physics imposter
  91881. */
  91882. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91883. /**
  91884. * A help function to create a joint
  91885. * @param otherImpostor A physics imposter used to create a joint
  91886. * @param jointType The type of joint
  91887. * @param jointData The data for the joint
  91888. * @returns The physics imposter
  91889. */
  91890. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  91891. /**
  91892. * Add a joint to this impostor with a different impostor
  91893. * @param otherImpostor A physics imposter used to add a joint
  91894. * @param joint The joint to add
  91895. * @returns The physics imposter
  91896. */
  91897. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  91898. /**
  91899. * Add an anchor to a cloth impostor
  91900. * @param otherImpostor rigid impostor to anchor to
  91901. * @param width ratio across width from 0 to 1
  91902. * @param height ratio up height from 0 to 1
  91903. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  91904. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  91905. * @returns impostor the soft imposter
  91906. */
  91907. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91908. /**
  91909. * Add a hook to a rope impostor
  91910. * @param otherImpostor rigid impostor to anchor to
  91911. * @param length ratio across rope from 0 to 1
  91912. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  91913. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  91914. * @returns impostor the rope imposter
  91915. */
  91916. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91917. /**
  91918. * Will keep this body still, in a sleep mode.
  91919. * @returns the physics imposter
  91920. */
  91921. sleep(): PhysicsImpostor;
  91922. /**
  91923. * Wake the body up.
  91924. * @returns The physics imposter
  91925. */
  91926. wakeUp(): PhysicsImpostor;
  91927. /**
  91928. * Clones the physics imposter
  91929. * @param newObject The physics imposter clones to this physics-enabled object
  91930. * @returns A nullable physics imposter
  91931. */
  91932. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91933. /**
  91934. * Disposes the physics imposter
  91935. */
  91936. dispose(): void;
  91937. /**
  91938. * Sets the delta position
  91939. * @param position The delta position amount
  91940. */
  91941. setDeltaPosition(position: Vector3): void;
  91942. /**
  91943. * Sets the delta rotation
  91944. * @param rotation The delta rotation amount
  91945. */
  91946. setDeltaRotation(rotation: Quaternion): void;
  91947. /**
  91948. * Gets the box size of the physics imposter and stores the result in the input parameter
  91949. * @param result Stores the box size
  91950. * @returns The physics imposter
  91951. */
  91952. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  91953. /**
  91954. * Gets the radius of the physics imposter
  91955. * @returns Radius of the physics imposter
  91956. */
  91957. getRadius(): number;
  91958. /**
  91959. * Sync a bone with this impostor
  91960. * @param bone The bone to sync to the impostor.
  91961. * @param boneMesh The mesh that the bone is influencing.
  91962. * @param jointPivot The pivot of the joint / bone in local space.
  91963. * @param distToJoint Optional distance from the impostor to the joint.
  91964. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91965. */
  91966. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  91967. /**
  91968. * Sync impostor to a bone
  91969. * @param bone The bone that the impostor will be synced to.
  91970. * @param boneMesh The mesh that the bone is influencing.
  91971. * @param jointPivot The pivot of the joint / bone in local space.
  91972. * @param distToJoint Optional distance from the impostor to the joint.
  91973. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91974. * @param boneAxis Optional vector3 axis the bone is aligned with
  91975. */
  91976. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  91977. /**
  91978. * No-Imposter type
  91979. */
  91980. static NoImpostor: number;
  91981. /**
  91982. * Sphere-Imposter type
  91983. */
  91984. static SphereImpostor: number;
  91985. /**
  91986. * Box-Imposter type
  91987. */
  91988. static BoxImpostor: number;
  91989. /**
  91990. * Plane-Imposter type
  91991. */
  91992. static PlaneImpostor: number;
  91993. /**
  91994. * Mesh-imposter type
  91995. */
  91996. static MeshImpostor: number;
  91997. /**
  91998. * Capsule-Impostor type (Ammo.js plugin only)
  91999. */
  92000. static CapsuleImpostor: number;
  92001. /**
  92002. * Cylinder-Imposter type
  92003. */
  92004. static CylinderImpostor: number;
  92005. /**
  92006. * Particle-Imposter type
  92007. */
  92008. static ParticleImpostor: number;
  92009. /**
  92010. * Heightmap-Imposter type
  92011. */
  92012. static HeightmapImpostor: number;
  92013. /**
  92014. * ConvexHull-Impostor type (Ammo.js plugin only)
  92015. */
  92016. static ConvexHullImpostor: number;
  92017. /**
  92018. * Rope-Imposter type
  92019. */
  92020. static RopeImpostor: number;
  92021. /**
  92022. * Cloth-Imposter type
  92023. */
  92024. static ClothImpostor: number;
  92025. /**
  92026. * Softbody-Imposter type
  92027. */
  92028. static SoftbodyImpostor: number;
  92029. }
  92030. }
  92031. declare module BABYLON {
  92032. /**
  92033. * @hidden
  92034. **/
  92035. export class _CreationDataStorage {
  92036. closePath?: boolean;
  92037. closeArray?: boolean;
  92038. idx: number[];
  92039. dashSize: number;
  92040. gapSize: number;
  92041. path3D: Path3D;
  92042. pathArray: Vector3[][];
  92043. arc: number;
  92044. radius: number;
  92045. cap: number;
  92046. tessellation: number;
  92047. }
  92048. /**
  92049. * @hidden
  92050. **/
  92051. class _InstanceDataStorage {
  92052. visibleInstances: any;
  92053. batchCache: _InstancesBatch;
  92054. instancesBufferSize: number;
  92055. instancesBuffer: Nullable<Buffer>;
  92056. instancesData: Float32Array;
  92057. overridenInstanceCount: number;
  92058. isFrozen: boolean;
  92059. previousBatch: Nullable<_InstancesBatch>;
  92060. hardwareInstancedRendering: boolean;
  92061. sideOrientation: number;
  92062. manualUpdate: boolean;
  92063. }
  92064. /**
  92065. * @hidden
  92066. **/
  92067. export class _InstancesBatch {
  92068. mustReturn: boolean;
  92069. visibleInstances: Nullable<InstancedMesh[]>[];
  92070. renderSelf: boolean[];
  92071. hardwareInstancedRendering: boolean[];
  92072. }
  92073. /**
  92074. * Class used to represent renderable models
  92075. */
  92076. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  92077. /**
  92078. * Mesh side orientation : usually the external or front surface
  92079. */
  92080. static readonly FRONTSIDE: number;
  92081. /**
  92082. * Mesh side orientation : usually the internal or back surface
  92083. */
  92084. static readonly BACKSIDE: number;
  92085. /**
  92086. * Mesh side orientation : both internal and external or front and back surfaces
  92087. */
  92088. static readonly DOUBLESIDE: number;
  92089. /**
  92090. * Mesh side orientation : by default, `FRONTSIDE`
  92091. */
  92092. static readonly DEFAULTSIDE: number;
  92093. /**
  92094. * Mesh cap setting : no cap
  92095. */
  92096. static readonly NO_CAP: number;
  92097. /**
  92098. * Mesh cap setting : one cap at the beginning of the mesh
  92099. */
  92100. static readonly CAP_START: number;
  92101. /**
  92102. * Mesh cap setting : one cap at the end of the mesh
  92103. */
  92104. static readonly CAP_END: number;
  92105. /**
  92106. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  92107. */
  92108. static readonly CAP_ALL: number;
  92109. /**
  92110. * Mesh pattern setting : no flip or rotate
  92111. */
  92112. static readonly NO_FLIP: number;
  92113. /**
  92114. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  92115. */
  92116. static readonly FLIP_TILE: number;
  92117. /**
  92118. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  92119. */
  92120. static readonly ROTATE_TILE: number;
  92121. /**
  92122. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  92123. */
  92124. static readonly FLIP_ROW: number;
  92125. /**
  92126. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  92127. */
  92128. static readonly ROTATE_ROW: number;
  92129. /**
  92130. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  92131. */
  92132. static readonly FLIP_N_ROTATE_TILE: number;
  92133. /**
  92134. * Mesh pattern setting : rotate pattern and rotate
  92135. */
  92136. static readonly FLIP_N_ROTATE_ROW: number;
  92137. /**
  92138. * Mesh tile positioning : part tiles same on left/right or top/bottom
  92139. */
  92140. static readonly CENTER: number;
  92141. /**
  92142. * Mesh tile positioning : part tiles on left
  92143. */
  92144. static readonly LEFT: number;
  92145. /**
  92146. * Mesh tile positioning : part tiles on right
  92147. */
  92148. static readonly RIGHT: number;
  92149. /**
  92150. * Mesh tile positioning : part tiles on top
  92151. */
  92152. static readonly TOP: number;
  92153. /**
  92154. * Mesh tile positioning : part tiles on bottom
  92155. */
  92156. static readonly BOTTOM: number;
  92157. /**
  92158. * Gets the default side orientation.
  92159. * @param orientation the orientation to value to attempt to get
  92160. * @returns the default orientation
  92161. * @hidden
  92162. */
  92163. static _GetDefaultSideOrientation(orientation?: number): number;
  92164. private _internalMeshDataInfo;
  92165. /**
  92166. * An event triggered before rendering the mesh
  92167. */
  92168. readonly onBeforeRenderObservable: Observable<Mesh>;
  92169. /**
  92170. * An event triggered before binding the mesh
  92171. */
  92172. readonly onBeforeBindObservable: Observable<Mesh>;
  92173. /**
  92174. * An event triggered after rendering the mesh
  92175. */
  92176. readonly onAfterRenderObservable: Observable<Mesh>;
  92177. /**
  92178. * An event triggered before drawing the mesh
  92179. */
  92180. readonly onBeforeDrawObservable: Observable<Mesh>;
  92181. private _onBeforeDrawObserver;
  92182. /**
  92183. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  92184. */
  92185. onBeforeDraw: () => void;
  92186. readonly hasInstances: boolean;
  92187. /**
  92188. * Gets the delay loading state of the mesh (when delay loading is turned on)
  92189. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  92190. */
  92191. delayLoadState: number;
  92192. /**
  92193. * Gets the list of instances created from this mesh
  92194. * it is not supposed to be modified manually.
  92195. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  92196. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92197. */
  92198. instances: InstancedMesh[];
  92199. /**
  92200. * Gets the file containing delay loading data for this mesh
  92201. */
  92202. delayLoadingFile: string;
  92203. /** @hidden */
  92204. _binaryInfo: any;
  92205. /**
  92206. * User defined function used to change how LOD level selection is done
  92207. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  92208. */
  92209. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  92210. /**
  92211. * Gets or sets the morph target manager
  92212. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  92213. */
  92214. morphTargetManager: Nullable<MorphTargetManager>;
  92215. /** @hidden */
  92216. _creationDataStorage: Nullable<_CreationDataStorage>;
  92217. /** @hidden */
  92218. _geometry: Nullable<Geometry>;
  92219. /** @hidden */
  92220. _delayInfo: Array<string>;
  92221. /** @hidden */
  92222. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  92223. /** @hidden */
  92224. _instanceDataStorage: _InstanceDataStorage;
  92225. private _effectiveMaterial;
  92226. /** @hidden */
  92227. _shouldGenerateFlatShading: boolean;
  92228. /** @hidden */
  92229. _originalBuilderSideOrientation: number;
  92230. /**
  92231. * Use this property to change the original side orientation defined at construction time
  92232. */
  92233. overrideMaterialSideOrientation: Nullable<number>;
  92234. /**
  92235. * Gets the source mesh (the one used to clone this one from)
  92236. */
  92237. readonly source: Nullable<Mesh>;
  92238. /**
  92239. * Gets or sets a boolean indicating that this mesh does not use index buffer
  92240. */
  92241. isUnIndexed: boolean;
  92242. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  92243. readonly worldMatrixInstancedBuffer: Float32Array;
  92244. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  92245. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  92246. /**
  92247. * @constructor
  92248. * @param name The value used by scene.getMeshByName() to do a lookup.
  92249. * @param scene The scene to add this mesh to.
  92250. * @param parent The parent of this mesh, if it has one
  92251. * @param source An optional Mesh from which geometry is shared, cloned.
  92252. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  92253. * When false, achieved by calling a clone(), also passing False.
  92254. * This will make creation of children, recursive.
  92255. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  92256. */
  92257. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  92258. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92259. doNotInstantiate: boolean;
  92260. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92261. /**
  92262. * Gets the class name
  92263. * @returns the string "Mesh".
  92264. */
  92265. getClassName(): string;
  92266. /** @hidden */
  92267. readonly _isMesh: boolean;
  92268. /**
  92269. * Returns a description of this mesh
  92270. * @param fullDetails define if full details about this mesh must be used
  92271. * @returns a descriptive string representing this mesh
  92272. */
  92273. toString(fullDetails?: boolean): string;
  92274. /** @hidden */
  92275. _unBindEffect(): void;
  92276. /**
  92277. * Gets a boolean indicating if this mesh has LOD
  92278. */
  92279. readonly hasLODLevels: boolean;
  92280. /**
  92281. * Gets the list of MeshLODLevel associated with the current mesh
  92282. * @returns an array of MeshLODLevel
  92283. */
  92284. getLODLevels(): MeshLODLevel[];
  92285. private _sortLODLevels;
  92286. /**
  92287. * Add a mesh as LOD level triggered at the given distance.
  92288. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92289. * @param distance The distance from the center of the object to show this level
  92290. * @param mesh The mesh to be added as LOD level (can be null)
  92291. * @return This mesh (for chaining)
  92292. */
  92293. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  92294. /**
  92295. * Returns the LOD level mesh at the passed distance or null if not found.
  92296. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92297. * @param distance The distance from the center of the object to show this level
  92298. * @returns a Mesh or `null`
  92299. */
  92300. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  92301. /**
  92302. * Remove a mesh from the LOD array
  92303. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92304. * @param mesh defines the mesh to be removed
  92305. * @return This mesh (for chaining)
  92306. */
  92307. removeLODLevel(mesh: Mesh): Mesh;
  92308. /**
  92309. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  92310. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92311. * @param camera defines the camera to use to compute distance
  92312. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  92313. * @return This mesh (for chaining)
  92314. */
  92315. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  92316. /**
  92317. * Gets the mesh internal Geometry object
  92318. */
  92319. readonly geometry: Nullable<Geometry>;
  92320. /**
  92321. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  92322. * @returns the total number of vertices
  92323. */
  92324. getTotalVertices(): number;
  92325. /**
  92326. * Returns the content of an associated vertex buffer
  92327. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92328. * - VertexBuffer.PositionKind
  92329. * - VertexBuffer.UVKind
  92330. * - VertexBuffer.UV2Kind
  92331. * - VertexBuffer.UV3Kind
  92332. * - VertexBuffer.UV4Kind
  92333. * - VertexBuffer.UV5Kind
  92334. * - VertexBuffer.UV6Kind
  92335. * - VertexBuffer.ColorKind
  92336. * - VertexBuffer.MatricesIndicesKind
  92337. * - VertexBuffer.MatricesIndicesExtraKind
  92338. * - VertexBuffer.MatricesWeightsKind
  92339. * - VertexBuffer.MatricesWeightsExtraKind
  92340. * @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
  92341. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  92342. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  92343. */
  92344. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92345. /**
  92346. * Returns the mesh VertexBuffer object from the requested `kind`
  92347. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92348. * - VertexBuffer.PositionKind
  92349. * - VertexBuffer.NormalKind
  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. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  92362. */
  92363. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  92364. /**
  92365. * Tests if a specific vertex buffer is associated with this mesh
  92366. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  92367. * - VertexBuffer.PositionKind
  92368. * - VertexBuffer.NormalKind
  92369. * - VertexBuffer.UVKind
  92370. * - VertexBuffer.UV2Kind
  92371. * - VertexBuffer.UV3Kind
  92372. * - VertexBuffer.UV4Kind
  92373. * - VertexBuffer.UV5Kind
  92374. * - VertexBuffer.UV6Kind
  92375. * - VertexBuffer.ColorKind
  92376. * - VertexBuffer.MatricesIndicesKind
  92377. * - VertexBuffer.MatricesIndicesExtraKind
  92378. * - VertexBuffer.MatricesWeightsKind
  92379. * - VertexBuffer.MatricesWeightsExtraKind
  92380. * @returns a boolean
  92381. */
  92382. isVerticesDataPresent(kind: string): boolean;
  92383. /**
  92384. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  92385. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  92386. * - VertexBuffer.PositionKind
  92387. * - VertexBuffer.UVKind
  92388. * - VertexBuffer.UV2Kind
  92389. * - VertexBuffer.UV3Kind
  92390. * - VertexBuffer.UV4Kind
  92391. * - VertexBuffer.UV5Kind
  92392. * - VertexBuffer.UV6Kind
  92393. * - VertexBuffer.ColorKind
  92394. * - VertexBuffer.MatricesIndicesKind
  92395. * - VertexBuffer.MatricesIndicesExtraKind
  92396. * - VertexBuffer.MatricesWeightsKind
  92397. * - VertexBuffer.MatricesWeightsExtraKind
  92398. * @returns a boolean
  92399. */
  92400. isVertexBufferUpdatable(kind: string): boolean;
  92401. /**
  92402. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  92403. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92404. * - VertexBuffer.PositionKind
  92405. * - VertexBuffer.NormalKind
  92406. * - VertexBuffer.UVKind
  92407. * - VertexBuffer.UV2Kind
  92408. * - VertexBuffer.UV3Kind
  92409. * - VertexBuffer.UV4Kind
  92410. * - VertexBuffer.UV5Kind
  92411. * - VertexBuffer.UV6Kind
  92412. * - VertexBuffer.ColorKind
  92413. * - VertexBuffer.MatricesIndicesKind
  92414. * - VertexBuffer.MatricesIndicesExtraKind
  92415. * - VertexBuffer.MatricesWeightsKind
  92416. * - VertexBuffer.MatricesWeightsExtraKind
  92417. * @returns an array of strings
  92418. */
  92419. getVerticesDataKinds(): string[];
  92420. /**
  92421. * Returns a positive integer : the total number of indices in this mesh geometry.
  92422. * @returns the numner of indices or zero if the mesh has no geometry.
  92423. */
  92424. getTotalIndices(): number;
  92425. /**
  92426. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92427. * @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.
  92428. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92429. * @returns the indices array or an empty array if the mesh has no geometry
  92430. */
  92431. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92432. readonly isBlocked: boolean;
  92433. /**
  92434. * Determine if the current mesh is ready to be rendered
  92435. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92436. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  92437. * @returns true if all associated assets are ready (material, textures, shaders)
  92438. */
  92439. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  92440. /**
  92441. * 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.
  92442. */
  92443. readonly areNormalsFrozen: boolean;
  92444. /**
  92445. * 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.
  92446. * @returns the current mesh
  92447. */
  92448. freezeNormals(): Mesh;
  92449. /**
  92450. * 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
  92451. * @returns the current mesh
  92452. */
  92453. unfreezeNormals(): Mesh;
  92454. /**
  92455. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  92456. */
  92457. overridenInstanceCount: number;
  92458. /** @hidden */
  92459. _preActivate(): Mesh;
  92460. /** @hidden */
  92461. _preActivateForIntermediateRendering(renderId: number): Mesh;
  92462. /** @hidden */
  92463. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  92464. /**
  92465. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92466. * This means the mesh underlying bounding box and sphere are recomputed.
  92467. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92468. * @returns the current mesh
  92469. */
  92470. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  92471. /** @hidden */
  92472. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  92473. /**
  92474. * This function will subdivide the mesh into multiple submeshes
  92475. * @param count defines the expected number of submeshes
  92476. */
  92477. subdivide(count: number): void;
  92478. /**
  92479. * Copy a FloatArray into a specific associated vertex buffer
  92480. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92481. * - VertexBuffer.PositionKind
  92482. * - VertexBuffer.UVKind
  92483. * - VertexBuffer.UV2Kind
  92484. * - VertexBuffer.UV3Kind
  92485. * - VertexBuffer.UV4Kind
  92486. * - VertexBuffer.UV5Kind
  92487. * - VertexBuffer.UV6Kind
  92488. * - VertexBuffer.ColorKind
  92489. * - VertexBuffer.MatricesIndicesKind
  92490. * - VertexBuffer.MatricesIndicesExtraKind
  92491. * - VertexBuffer.MatricesWeightsKind
  92492. * - VertexBuffer.MatricesWeightsExtraKind
  92493. * @param data defines the data source
  92494. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92495. * @param stride defines the data stride size (can be null)
  92496. * @returns the current mesh
  92497. */
  92498. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92499. /**
  92500. * Delete a vertex buffer associated with this mesh
  92501. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  92502. * - VertexBuffer.PositionKind
  92503. * - VertexBuffer.UVKind
  92504. * - VertexBuffer.UV2Kind
  92505. * - VertexBuffer.UV3Kind
  92506. * - VertexBuffer.UV4Kind
  92507. * - VertexBuffer.UV5Kind
  92508. * - VertexBuffer.UV6Kind
  92509. * - VertexBuffer.ColorKind
  92510. * - VertexBuffer.MatricesIndicesKind
  92511. * - VertexBuffer.MatricesIndicesExtraKind
  92512. * - VertexBuffer.MatricesWeightsKind
  92513. * - VertexBuffer.MatricesWeightsExtraKind
  92514. */
  92515. removeVerticesData(kind: string): void;
  92516. /**
  92517. * Flags an associated vertex buffer as updatable
  92518. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  92519. * - VertexBuffer.PositionKind
  92520. * - VertexBuffer.UVKind
  92521. * - VertexBuffer.UV2Kind
  92522. * - VertexBuffer.UV3Kind
  92523. * - VertexBuffer.UV4Kind
  92524. * - VertexBuffer.UV5Kind
  92525. * - VertexBuffer.UV6Kind
  92526. * - VertexBuffer.ColorKind
  92527. * - VertexBuffer.MatricesIndicesKind
  92528. * - VertexBuffer.MatricesIndicesExtraKind
  92529. * - VertexBuffer.MatricesWeightsKind
  92530. * - VertexBuffer.MatricesWeightsExtraKind
  92531. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92532. */
  92533. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  92534. /**
  92535. * Sets the mesh global Vertex Buffer
  92536. * @param buffer defines the buffer to use
  92537. * @returns the current mesh
  92538. */
  92539. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  92540. /**
  92541. * Update a specific associated vertex buffer
  92542. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92543. * - VertexBuffer.PositionKind
  92544. * - VertexBuffer.UVKind
  92545. * - VertexBuffer.UV2Kind
  92546. * - VertexBuffer.UV3Kind
  92547. * - VertexBuffer.UV4Kind
  92548. * - VertexBuffer.UV5Kind
  92549. * - VertexBuffer.UV6Kind
  92550. * - VertexBuffer.ColorKind
  92551. * - VertexBuffer.MatricesIndicesKind
  92552. * - VertexBuffer.MatricesIndicesExtraKind
  92553. * - VertexBuffer.MatricesWeightsKind
  92554. * - VertexBuffer.MatricesWeightsExtraKind
  92555. * @param data defines the data source
  92556. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  92557. * @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)
  92558. * @returns the current mesh
  92559. */
  92560. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92561. /**
  92562. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  92563. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  92564. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  92565. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  92566. * @returns the current mesh
  92567. */
  92568. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  92569. /**
  92570. * Creates a un-shared specific occurence of the geometry for the mesh.
  92571. * @returns the current mesh
  92572. */
  92573. makeGeometryUnique(): Mesh;
  92574. /**
  92575. * Set the index buffer of this mesh
  92576. * @param indices defines the source data
  92577. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  92578. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  92579. * @returns the current mesh
  92580. */
  92581. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  92582. /**
  92583. * Update the current index buffer
  92584. * @param indices defines the source data
  92585. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92586. * @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)
  92587. * @returns the current mesh
  92588. */
  92589. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92590. /**
  92591. * Invert the geometry to move from a right handed system to a left handed one.
  92592. * @returns the current mesh
  92593. */
  92594. toLeftHanded(): Mesh;
  92595. /** @hidden */
  92596. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  92597. /** @hidden */
  92598. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  92599. /**
  92600. * Registers for this mesh a javascript function called just before the rendering process
  92601. * @param func defines the function to call before rendering this mesh
  92602. * @returns the current mesh
  92603. */
  92604. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92605. /**
  92606. * Disposes a previously registered javascript function called before the rendering
  92607. * @param func defines the function to remove
  92608. * @returns the current mesh
  92609. */
  92610. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92611. /**
  92612. * Registers for this mesh a javascript function called just after the rendering is complete
  92613. * @param func defines the function to call after rendering this mesh
  92614. * @returns the current mesh
  92615. */
  92616. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92617. /**
  92618. * Disposes a previously registered javascript function called after the rendering.
  92619. * @param func defines the function to remove
  92620. * @returns the current mesh
  92621. */
  92622. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92623. /** @hidden */
  92624. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  92625. /** @hidden */
  92626. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  92627. /** @hidden */
  92628. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  92629. /** @hidden */
  92630. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  92631. /** @hidden */
  92632. _rebuild(): void;
  92633. /** @hidden */
  92634. _freeze(): void;
  92635. /** @hidden */
  92636. _unFreeze(): void;
  92637. /**
  92638. * 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
  92639. * @param subMesh defines the subMesh to render
  92640. * @param enableAlphaMode defines if alpha mode can be changed
  92641. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  92642. * @returns the current mesh
  92643. */
  92644. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  92645. private _onBeforeDraw;
  92646. /**
  92647. * Renormalize the mesh and patch it up if there are no weights
  92648. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  92649. * However in the case of zero weights then we set just a single influence to 1.
  92650. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  92651. */
  92652. cleanMatrixWeights(): void;
  92653. private normalizeSkinFourWeights;
  92654. private normalizeSkinWeightsAndExtra;
  92655. /**
  92656. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  92657. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  92658. * the user know there was an issue with importing the mesh
  92659. * @returns a validation object with skinned, valid and report string
  92660. */
  92661. validateSkinning(): {
  92662. skinned: boolean;
  92663. valid: boolean;
  92664. report: string;
  92665. };
  92666. /** @hidden */
  92667. _checkDelayState(): Mesh;
  92668. private _queueLoad;
  92669. /**
  92670. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92671. * A mesh is in the frustum if its bounding box intersects the frustum
  92672. * @param frustumPlanes defines the frustum to test
  92673. * @returns true if the mesh is in the frustum planes
  92674. */
  92675. isInFrustum(frustumPlanes: Plane[]): boolean;
  92676. /**
  92677. * Sets the mesh material by the material or multiMaterial `id` property
  92678. * @param id is a string identifying the material or the multiMaterial
  92679. * @returns the current mesh
  92680. */
  92681. setMaterialByID(id: string): Mesh;
  92682. /**
  92683. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  92684. * @returns an array of IAnimatable
  92685. */
  92686. getAnimatables(): IAnimatable[];
  92687. /**
  92688. * Modifies the mesh geometry according to the passed transformation matrix.
  92689. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  92690. * The mesh normals are modified using the same transformation.
  92691. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92692. * @param transform defines the transform matrix to use
  92693. * @see http://doc.babylonjs.com/resources/baking_transformations
  92694. * @returns the current mesh
  92695. */
  92696. bakeTransformIntoVertices(transform: Matrix): Mesh;
  92697. /**
  92698. * Modifies the mesh geometry according to its own current World Matrix.
  92699. * The mesh World Matrix is then reset.
  92700. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  92701. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92702. * @see http://doc.babylonjs.com/resources/baking_transformations
  92703. * @returns the current mesh
  92704. */
  92705. bakeCurrentTransformIntoVertices(): Mesh;
  92706. /** @hidden */
  92707. readonly _positions: Nullable<Vector3[]>;
  92708. /** @hidden */
  92709. _resetPointsArrayCache(): Mesh;
  92710. /** @hidden */
  92711. _generatePointsArray(): boolean;
  92712. /**
  92713. * Returns a new Mesh object generated from the current mesh properties.
  92714. * This method must not get confused with createInstance()
  92715. * @param name is a string, the name given to the new mesh
  92716. * @param newParent can be any Node object (default `null`)
  92717. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  92718. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  92719. * @returns a new mesh
  92720. */
  92721. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  92722. /**
  92723. * Releases resources associated with this mesh.
  92724. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92725. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92726. */
  92727. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92728. /** @hidden */
  92729. _disposeInstanceSpecificData(): void;
  92730. /**
  92731. * Modifies the mesh geometry according to a displacement map.
  92732. * 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.
  92733. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92734. * @param url is a string, the URL from the image file is to be downloaded.
  92735. * @param minHeight is the lower limit of the displacement.
  92736. * @param maxHeight is the upper limit of the displacement.
  92737. * @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.
  92738. * @param uvOffset is an optional vector2 used to offset UV.
  92739. * @param uvScale is an optional vector2 used to scale UV.
  92740. * @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.
  92741. * @returns the Mesh.
  92742. */
  92743. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92744. /**
  92745. * Modifies the mesh geometry according to a displacementMap buffer.
  92746. * 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.
  92747. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92748. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  92749. * @param heightMapWidth is the width of the buffer image.
  92750. * @param heightMapHeight is the height of the buffer image.
  92751. * @param minHeight is the lower limit of the displacement.
  92752. * @param maxHeight is the upper limit of the displacement.
  92753. * @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.
  92754. * @param uvOffset is an optional vector2 used to offset UV.
  92755. * @param uvScale is an optional vector2 used to scale UV.
  92756. * @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.
  92757. * @returns the Mesh.
  92758. */
  92759. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92760. /**
  92761. * Modify the mesh to get a flat shading rendering.
  92762. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  92763. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  92764. * @returns current mesh
  92765. */
  92766. convertToFlatShadedMesh(): Mesh;
  92767. /**
  92768. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  92769. * In other words, more vertices, no more indices and a single bigger VBO.
  92770. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  92771. * @returns current mesh
  92772. */
  92773. convertToUnIndexedMesh(): Mesh;
  92774. /**
  92775. * Inverses facet orientations.
  92776. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92777. * @param flipNormals will also inverts the normals
  92778. * @returns current mesh
  92779. */
  92780. flipFaces(flipNormals?: boolean): Mesh;
  92781. /**
  92782. * Increase the number of facets and hence vertices in a mesh
  92783. * Vertex normals are interpolated from existing vertex normals
  92784. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92785. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  92786. */
  92787. increaseVertices(numberPerEdge: number): void;
  92788. /**
  92789. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  92790. * This will undo any application of covertToFlatShadedMesh
  92791. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92792. */
  92793. forceSharedVertices(): void;
  92794. /** @hidden */
  92795. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  92796. /** @hidden */
  92797. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  92798. /**
  92799. * Creates a new InstancedMesh object from the mesh model.
  92800. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92801. * @param name defines the name of the new instance
  92802. * @returns a new InstancedMesh
  92803. */
  92804. createInstance(name: string): InstancedMesh;
  92805. /**
  92806. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  92807. * After this call, all the mesh instances have the same submeshes than the current mesh.
  92808. * @returns the current mesh
  92809. */
  92810. synchronizeInstances(): Mesh;
  92811. /**
  92812. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  92813. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  92814. * This should be used together with the simplification to avoid disappearing triangles.
  92815. * @param successCallback an optional success callback to be called after the optimization finished.
  92816. * @returns the current mesh
  92817. */
  92818. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  92819. /**
  92820. * Serialize current mesh
  92821. * @param serializationObject defines the object which will receive the serialization data
  92822. */
  92823. serialize(serializationObject: any): void;
  92824. /** @hidden */
  92825. _syncGeometryWithMorphTargetManager(): void;
  92826. /** @hidden */
  92827. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  92828. /**
  92829. * Returns a new Mesh object parsed from the source provided.
  92830. * @param parsedMesh is the source
  92831. * @param scene defines the hosting scene
  92832. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  92833. * @returns a new Mesh
  92834. */
  92835. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  92836. /**
  92837. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  92838. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92839. * @param name defines the name of the mesh to create
  92840. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  92841. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  92842. * @param closePath creates a seam between the first and the last points of each path of the path array
  92843. * @param offset is taken in account only if the `pathArray` is containing a single path
  92844. * @param scene defines the hosting scene
  92845. * @param updatable defines if the mesh must be flagged as updatable
  92846. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92847. * @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)
  92848. * @returns a new Mesh
  92849. */
  92850. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92851. /**
  92852. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  92853. * @param name defines the name of the mesh to create
  92854. * @param radius sets the radius size (float) of the polygon (default 0.5)
  92855. * @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
  92856. * @param scene defines the hosting scene
  92857. * @param updatable defines if the mesh must be flagged as updatable
  92858. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92859. * @returns a new Mesh
  92860. */
  92861. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92862. /**
  92863. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  92864. * @param name defines the name of the mesh to create
  92865. * @param size sets the size (float) of each box side (default 1)
  92866. * @param scene defines the hosting scene
  92867. * @param updatable defines if the mesh must be flagged as updatable
  92868. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92869. * @returns a new Mesh
  92870. */
  92871. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92872. /**
  92873. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  92874. * @param name defines the name of the mesh to create
  92875. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92876. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92877. * @param scene defines the hosting scene
  92878. * @param updatable defines if the mesh must be flagged as updatable
  92879. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92880. * @returns a new Mesh
  92881. */
  92882. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92883. /**
  92884. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  92885. * @param name defines the name of the mesh to create
  92886. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92887. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92888. * @param scene defines the hosting scene
  92889. * @returns a new Mesh
  92890. */
  92891. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  92892. /**
  92893. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  92894. * @param name defines the name of the mesh to create
  92895. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  92896. * @param diameterTop set the top cap diameter (floats, default 1)
  92897. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  92898. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  92899. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  92900. * @param scene defines the hosting scene
  92901. * @param updatable defines if the mesh must be flagged as updatable
  92902. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92903. * @returns a new Mesh
  92904. */
  92905. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  92906. /**
  92907. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  92908. * @param name defines the name of the mesh to create
  92909. * @param diameter sets the diameter size (float) of the torus (default 1)
  92910. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  92911. * @param tessellation sets the number of torus sides (postive integer, default 16)
  92912. * @param scene defines the hosting scene
  92913. * @param updatable defines if the mesh must be flagged as updatable
  92914. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92915. * @returns a new Mesh
  92916. */
  92917. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92918. /**
  92919. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  92920. * @param name defines the name of the mesh to create
  92921. * @param radius sets the global radius size (float) of the torus knot (default 2)
  92922. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  92923. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  92924. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  92925. * @param p the number of windings on X axis (positive integers, default 2)
  92926. * @param q the number of windings on Y axis (positive integers, default 3)
  92927. * @param scene defines the hosting scene
  92928. * @param updatable defines if the mesh must be flagged as updatable
  92929. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92930. * @returns a new Mesh
  92931. */
  92932. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92933. /**
  92934. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  92935. * @param name defines the name of the mesh to create
  92936. * @param points is an array successive Vector3
  92937. * @param scene defines the hosting scene
  92938. * @param updatable defines if the mesh must be flagged as updatable
  92939. * @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).
  92940. * @returns a new Mesh
  92941. */
  92942. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  92943. /**
  92944. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  92945. * @param name defines the name of the mesh to create
  92946. * @param points is an array successive Vector3
  92947. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  92948. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  92949. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  92950. * @param scene defines the hosting scene
  92951. * @param updatable defines if the mesh must be flagged as updatable
  92952. * @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)
  92953. * @returns a new Mesh
  92954. */
  92955. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  92956. /**
  92957. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  92958. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  92959. * 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.
  92960. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92961. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92962. * Remember you can only change the shape positions, not their number when updating a polygon.
  92963. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  92964. * @param name defines the name of the mesh to create
  92965. * @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
  92966. * @param scene defines the hosting scene
  92967. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92968. * @param updatable defines if the mesh must be flagged as updatable
  92969. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92970. * @param earcutInjection can be used to inject your own earcut reference
  92971. * @returns a new Mesh
  92972. */
  92973. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92974. /**
  92975. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  92976. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  92977. * @param name defines the name of the mesh to create
  92978. * @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
  92979. * @param depth defines the height of extrusion
  92980. * @param scene defines the hosting scene
  92981. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92982. * @param updatable defines if the mesh must be flagged as updatable
  92983. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92984. * @param earcutInjection can be used to inject your own earcut reference
  92985. * @returns a new Mesh
  92986. */
  92987. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92988. /**
  92989. * Creates an extruded shape mesh.
  92990. * 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
  92991. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92992. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92993. * @param name defines the name of the mesh to create
  92994. * @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
  92995. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92996. * @param scale is the value to scale the shape
  92997. * @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
  92998. * @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
  92999. * @param scene defines the hosting scene
  93000. * @param updatable defines if the mesh must be flagged as updatable
  93001. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93002. * @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)
  93003. * @returns a new Mesh
  93004. */
  93005. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93006. /**
  93007. * Creates an custom extruded shape mesh.
  93008. * The custom extrusion is a parametric shape.
  93009. * It has no predefined shape. Its final shape will depend on the input parameters.
  93010. * Please consider using the same method from the MeshBuilder class instead
  93011. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  93012. * @param name defines the name of the mesh to create
  93013. * @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
  93014. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  93015. * @param scaleFunction is a custom Javascript function called on each path point
  93016. * @param rotationFunction is a custom Javascript function called on each path point
  93017. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  93018. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  93019. * @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
  93020. * @param scene defines the hosting scene
  93021. * @param updatable defines if the mesh must be flagged as updatable
  93022. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93023. * @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)
  93024. * @returns a new Mesh
  93025. */
  93026. 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;
  93027. /**
  93028. * Creates lathe mesh.
  93029. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  93030. * Please consider using the same method from the MeshBuilder class instead
  93031. * @param name defines the name of the mesh to create
  93032. * @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
  93033. * @param radius is the radius value of the lathe
  93034. * @param tessellation is the side number of the lathe.
  93035. * @param scene defines the hosting scene
  93036. * @param updatable defines if the mesh must be flagged as updatable
  93037. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93038. * @returns a new Mesh
  93039. */
  93040. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93041. /**
  93042. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  93043. * @param name defines the name of the mesh to create
  93044. * @param size sets the size (float) of both sides of the plane at once (default 1)
  93045. * @param scene defines the hosting scene
  93046. * @param updatable defines if the mesh must be flagged as updatable
  93047. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93048. * @returns a new Mesh
  93049. */
  93050. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93051. /**
  93052. * Creates a ground mesh.
  93053. * Please consider using the same method from the MeshBuilder class instead
  93054. * @param name defines the name of the mesh to create
  93055. * @param width set the width of the ground
  93056. * @param height set the height of the ground
  93057. * @param subdivisions sets the number of subdivisions per side
  93058. * @param scene defines the hosting scene
  93059. * @param updatable defines if the mesh must be flagged as updatable
  93060. * @returns a new Mesh
  93061. */
  93062. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  93063. /**
  93064. * Creates a tiled ground mesh.
  93065. * Please consider using the same method from the MeshBuilder class instead
  93066. * @param name defines the name of the mesh to create
  93067. * @param xmin set the ground minimum X coordinate
  93068. * @param zmin set the ground minimum Y coordinate
  93069. * @param xmax set the ground maximum X coordinate
  93070. * @param zmax set the ground maximum Z coordinate
  93071. * @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
  93072. * @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
  93073. * @param scene defines the hosting scene
  93074. * @param updatable defines if the mesh must be flagged as updatable
  93075. * @returns a new Mesh
  93076. */
  93077. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  93078. w: number;
  93079. h: number;
  93080. }, precision: {
  93081. w: number;
  93082. h: number;
  93083. }, scene: Scene, updatable?: boolean): Mesh;
  93084. /**
  93085. * Creates a ground mesh from a height map.
  93086. * Please consider using the same method from the MeshBuilder class instead
  93087. * @see http://doc.babylonjs.com/babylon101/height_map
  93088. * @param name defines the name of the mesh to create
  93089. * @param url sets the URL of the height map image resource
  93090. * @param width set the ground width size
  93091. * @param height set the ground height size
  93092. * @param subdivisions sets the number of subdivision per side
  93093. * @param minHeight is the minimum altitude on the ground
  93094. * @param maxHeight is the maximum altitude on the ground
  93095. * @param scene defines the hosting scene
  93096. * @param updatable defines if the mesh must be flagged as updatable
  93097. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  93098. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  93099. * @returns a new Mesh
  93100. */
  93101. 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;
  93102. /**
  93103. * Creates a tube mesh.
  93104. * The tube is a parametric shape.
  93105. * It has no predefined shape. Its final shape will depend on the input parameters.
  93106. * Please consider using the same method from the MeshBuilder class instead
  93107. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93108. * @param name defines the name of the mesh to create
  93109. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  93110. * @param radius sets the tube radius size
  93111. * @param tessellation is the number of sides on the tubular surface
  93112. * @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
  93113. * @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
  93114. * @param scene defines the hosting scene
  93115. * @param updatable defines if the mesh must be flagged as updatable
  93116. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93117. * @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)
  93118. * @returns a new Mesh
  93119. */
  93120. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  93121. (i: number, distance: number): number;
  93122. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93123. /**
  93124. * Creates a polyhedron mesh.
  93125. * Please consider using the same method from the MeshBuilder class instead.
  93126. * * 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
  93127. * * The parameter `size` (positive float, default 1) sets the polygon size
  93128. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  93129. * * 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`
  93130. * * 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
  93131. * * 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)`)
  93132. * * 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
  93133. * * 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
  93134. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93135. * * If you create a double-sided mesh, you can choose what parts of 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
  93136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93137. * @param name defines the name of the mesh to create
  93138. * @param options defines the options used to create the mesh
  93139. * @param scene defines the hosting scene
  93140. * @returns a new Mesh
  93141. */
  93142. static CreatePolyhedron(name: string, options: {
  93143. type?: number;
  93144. size?: number;
  93145. sizeX?: number;
  93146. sizeY?: number;
  93147. sizeZ?: number;
  93148. custom?: any;
  93149. faceUV?: Vector4[];
  93150. faceColors?: Color4[];
  93151. updatable?: boolean;
  93152. sideOrientation?: number;
  93153. }, scene: Scene): Mesh;
  93154. /**
  93155. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  93156. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  93157. * * 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`)
  93158. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  93159. * * 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
  93160. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93161. * * If you create a double-sided mesh, you can choose what parts of 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
  93162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93163. * @param name defines the name of the mesh
  93164. * @param options defines the options used to create the mesh
  93165. * @param scene defines the hosting scene
  93166. * @returns a new Mesh
  93167. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  93168. */
  93169. static CreateIcoSphere(name: string, options: {
  93170. radius?: number;
  93171. flat?: boolean;
  93172. subdivisions?: number;
  93173. sideOrientation?: number;
  93174. updatable?: boolean;
  93175. }, scene: Scene): Mesh;
  93176. /**
  93177. * Creates a decal mesh.
  93178. * Please consider using the same method from the MeshBuilder class instead.
  93179. * A decal is a mesh usually applied as a model onto the surface of another mesh
  93180. * @param name defines the name of the mesh
  93181. * @param sourceMesh defines the mesh receiving the decal
  93182. * @param position sets the position of the decal in world coordinates
  93183. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  93184. * @param size sets the decal scaling
  93185. * @param angle sets the angle to rotate the decal
  93186. * @returns a new Mesh
  93187. */
  93188. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  93189. /**
  93190. * Prepare internal position array for software CPU skinning
  93191. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  93192. */
  93193. setPositionsForCPUSkinning(): Float32Array;
  93194. /**
  93195. * Prepare internal normal array for software CPU skinning
  93196. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  93197. */
  93198. setNormalsForCPUSkinning(): Float32Array;
  93199. /**
  93200. * Updates the vertex buffer by applying transformation from the bones
  93201. * @param skeleton defines the skeleton to apply to current mesh
  93202. * @returns the current mesh
  93203. */
  93204. applySkeleton(skeleton: Skeleton): Mesh;
  93205. /**
  93206. * 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
  93207. * @param meshes defines the list of meshes to scan
  93208. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  93209. */
  93210. static MinMax(meshes: AbstractMesh[]): {
  93211. min: Vector3;
  93212. max: Vector3;
  93213. };
  93214. /**
  93215. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  93216. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  93217. * @returns a vector3
  93218. */
  93219. static Center(meshesOrMinMaxVector: {
  93220. min: Vector3;
  93221. max: Vector3;
  93222. } | AbstractMesh[]): Vector3;
  93223. /**
  93224. * Merge the array of meshes into a single mesh for performance reasons.
  93225. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  93226. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  93227. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  93228. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  93229. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  93230. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  93231. * @returns a new mesh
  93232. */
  93233. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  93234. /** @hidden */
  93235. addInstance(instance: InstancedMesh): void;
  93236. /** @hidden */
  93237. removeInstance(instance: InstancedMesh): void;
  93238. }
  93239. }
  93240. declare module BABYLON {
  93241. /**
  93242. * This is the base class of all the camera used in the application.
  93243. * @see http://doc.babylonjs.com/features/cameras
  93244. */
  93245. export class Camera extends Node {
  93246. /** @hidden */
  93247. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93248. /**
  93249. * This is the default projection mode used by the cameras.
  93250. * It helps recreating a feeling of perspective and better appreciate depth.
  93251. * This is the best way to simulate real life cameras.
  93252. */
  93253. static readonly PERSPECTIVE_CAMERA: number;
  93254. /**
  93255. * This helps creating camera with an orthographic mode.
  93256. * 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.
  93257. */
  93258. static readonly ORTHOGRAPHIC_CAMERA: number;
  93259. /**
  93260. * This is the default FOV mode for perspective cameras.
  93261. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93262. */
  93263. static readonly FOVMODE_VERTICAL_FIXED: number;
  93264. /**
  93265. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93266. */
  93267. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93268. /**
  93269. * This specifies ther is no need for a camera rig.
  93270. * Basically only one eye is rendered corresponding to the camera.
  93271. */
  93272. static readonly RIG_MODE_NONE: number;
  93273. /**
  93274. * Simulates a camera Rig with one blue eye and one red eye.
  93275. * This can be use with 3d blue and red glasses.
  93276. */
  93277. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93278. /**
  93279. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93280. */
  93281. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93282. /**
  93283. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93284. */
  93285. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93286. /**
  93287. * Defines that both eyes of the camera will be rendered over under each other.
  93288. */
  93289. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93290. /**
  93291. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93292. */
  93293. static readonly RIG_MODE_VR: number;
  93294. /**
  93295. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93296. */
  93297. static readonly RIG_MODE_WEBVR: number;
  93298. /**
  93299. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93300. */
  93301. static readonly RIG_MODE_CUSTOM: number;
  93302. /**
  93303. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93304. */
  93305. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93306. /**
  93307. * Define the input manager associated with the camera.
  93308. */
  93309. inputs: CameraInputsManager<Camera>;
  93310. /** @hidden */
  93311. _position: Vector3;
  93312. /**
  93313. * Define the current local position of the camera in the scene
  93314. */
  93315. position: Vector3;
  93316. /**
  93317. * The vector the camera should consider as up.
  93318. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93319. */
  93320. upVector: Vector3;
  93321. /**
  93322. * Define the current limit on the left side for an orthographic camera
  93323. * In scene unit
  93324. */
  93325. orthoLeft: Nullable<number>;
  93326. /**
  93327. * Define the current limit on the right side for an orthographic camera
  93328. * In scene unit
  93329. */
  93330. orthoRight: Nullable<number>;
  93331. /**
  93332. * Define the current limit on the bottom side for an orthographic camera
  93333. * In scene unit
  93334. */
  93335. orthoBottom: Nullable<number>;
  93336. /**
  93337. * Define the current limit on the top side for an orthographic camera
  93338. * In scene unit
  93339. */
  93340. orthoTop: Nullable<number>;
  93341. /**
  93342. * Field Of View is set in Radians. (default is 0.8)
  93343. */
  93344. fov: number;
  93345. /**
  93346. * Define the minimum distance the camera can see from.
  93347. * This is important to note that the depth buffer are not infinite and the closer it starts
  93348. * the more your scene might encounter depth fighting issue.
  93349. */
  93350. minZ: number;
  93351. /**
  93352. * Define the maximum distance the camera can see to.
  93353. * This is important to note that the depth buffer are not infinite and the further it end
  93354. * the more your scene might encounter depth fighting issue.
  93355. */
  93356. maxZ: number;
  93357. /**
  93358. * Define the default inertia of the camera.
  93359. * This helps giving a smooth feeling to the camera movement.
  93360. */
  93361. inertia: number;
  93362. /**
  93363. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  93364. */
  93365. mode: number;
  93366. /**
  93367. * Define wether the camera is intermediate.
  93368. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93369. */
  93370. isIntermediate: boolean;
  93371. /**
  93372. * Define the viewport of the camera.
  93373. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93374. */
  93375. viewport: Viewport;
  93376. /**
  93377. * Restricts the camera to viewing objects with the same layerMask.
  93378. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93379. */
  93380. layerMask: number;
  93381. /**
  93382. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93383. */
  93384. fovMode: number;
  93385. /**
  93386. * Rig mode of the camera.
  93387. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93388. * This is normally controlled byt the camera themselves as internal use.
  93389. */
  93390. cameraRigMode: number;
  93391. /**
  93392. * Defines the distance between both "eyes" in case of a RIG
  93393. */
  93394. interaxialDistance: number;
  93395. /**
  93396. * Defines if stereoscopic rendering is done side by side or over under.
  93397. */
  93398. isStereoscopicSideBySide: boolean;
  93399. /**
  93400. * 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
  93401. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93402. * else in the scene. (Eg. security camera)
  93403. *
  93404. * 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)
  93405. */
  93406. customRenderTargets: RenderTargetTexture[];
  93407. /**
  93408. * When set, the camera will render to this render target instead of the default canvas
  93409. *
  93410. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  93411. */
  93412. outputRenderTarget: Nullable<RenderTargetTexture>;
  93413. /**
  93414. * Observable triggered when the camera view matrix has changed.
  93415. */
  93416. onViewMatrixChangedObservable: Observable<Camera>;
  93417. /**
  93418. * Observable triggered when the camera Projection matrix has changed.
  93419. */
  93420. onProjectionMatrixChangedObservable: Observable<Camera>;
  93421. /**
  93422. * Observable triggered when the inputs have been processed.
  93423. */
  93424. onAfterCheckInputsObservable: Observable<Camera>;
  93425. /**
  93426. * Observable triggered when reset has been called and applied to the camera.
  93427. */
  93428. onRestoreStateObservable: Observable<Camera>;
  93429. /** @hidden */
  93430. _cameraRigParams: any;
  93431. /** @hidden */
  93432. _rigCameras: Camera[];
  93433. /** @hidden */
  93434. _rigPostProcess: Nullable<PostProcess>;
  93435. protected _webvrViewMatrix: Matrix;
  93436. /** @hidden */
  93437. _skipRendering: boolean;
  93438. /** @hidden */
  93439. _projectionMatrix: Matrix;
  93440. /** @hidden */
  93441. _postProcesses: Nullable<PostProcess>[];
  93442. /** @hidden */
  93443. _activeMeshes: SmartArray<AbstractMesh>;
  93444. protected _globalPosition: Vector3;
  93445. /** @hidden */
  93446. _computedViewMatrix: Matrix;
  93447. private _doNotComputeProjectionMatrix;
  93448. private _transformMatrix;
  93449. private _frustumPlanes;
  93450. private _refreshFrustumPlanes;
  93451. private _storedFov;
  93452. private _stateStored;
  93453. /**
  93454. * Instantiates a new camera object.
  93455. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93456. * @see http://doc.babylonjs.com/features/cameras
  93457. * @param name Defines the name of the camera in the scene
  93458. * @param position Defines the position of the camera
  93459. * @param scene Defines the scene the camera belongs too
  93460. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93461. */
  93462. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93463. /**
  93464. * Store current camera state (fov, position, etc..)
  93465. * @returns the camera
  93466. */
  93467. storeState(): Camera;
  93468. /**
  93469. * Restores the camera state values if it has been stored. You must call storeState() first
  93470. */
  93471. protected _restoreStateValues(): boolean;
  93472. /**
  93473. * Restored camera state. You must call storeState() first.
  93474. * @returns true if restored and false otherwise
  93475. */
  93476. restoreState(): boolean;
  93477. /**
  93478. * Gets the class name of the camera.
  93479. * @returns the class name
  93480. */
  93481. getClassName(): string;
  93482. /** @hidden */
  93483. readonly _isCamera: boolean;
  93484. /**
  93485. * Gets a string representation of the camera useful for debug purpose.
  93486. * @param fullDetails Defines that a more verboe level of logging is required
  93487. * @returns the string representation
  93488. */
  93489. toString(fullDetails?: boolean): string;
  93490. /**
  93491. * Gets the current world space position of the camera.
  93492. */
  93493. readonly globalPosition: Vector3;
  93494. /**
  93495. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93496. * @returns the active meshe list
  93497. */
  93498. getActiveMeshes(): SmartArray<AbstractMesh>;
  93499. /**
  93500. * Check wether a mesh is part of the current active mesh list of the camera
  93501. * @param mesh Defines the mesh to check
  93502. * @returns true if active, false otherwise
  93503. */
  93504. isActiveMesh(mesh: Mesh): boolean;
  93505. /**
  93506. * Is this camera ready to be used/rendered
  93507. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93508. * @return true if the camera is ready
  93509. */
  93510. isReady(completeCheck?: boolean): boolean;
  93511. /** @hidden */
  93512. _initCache(): void;
  93513. /** @hidden */
  93514. _updateCache(ignoreParentClass?: boolean): void;
  93515. /** @hidden */
  93516. _isSynchronized(): boolean;
  93517. /** @hidden */
  93518. _isSynchronizedViewMatrix(): boolean;
  93519. /** @hidden */
  93520. _isSynchronizedProjectionMatrix(): boolean;
  93521. /**
  93522. * Attach the input controls to a specific dom element to get the input from.
  93523. * @param element Defines the element the controls should be listened from
  93524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93525. */
  93526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93527. /**
  93528. * Detach the current controls from the specified dom element.
  93529. * @param element Defines the element to stop listening the inputs from
  93530. */
  93531. detachControl(element: HTMLElement): void;
  93532. /**
  93533. * Update the camera state according to the different inputs gathered during the frame.
  93534. */
  93535. update(): void;
  93536. /** @hidden */
  93537. _checkInputs(): void;
  93538. /** @hidden */
  93539. readonly rigCameras: Camera[];
  93540. /**
  93541. * Gets the post process used by the rig cameras
  93542. */
  93543. readonly rigPostProcess: Nullable<PostProcess>;
  93544. /**
  93545. * Internal, gets the first post proces.
  93546. * @returns the first post process to be run on this camera.
  93547. */
  93548. _getFirstPostProcess(): Nullable<PostProcess>;
  93549. private _cascadePostProcessesToRigCams;
  93550. /**
  93551. * Attach a post process to the camera.
  93552. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93553. * @param postProcess The post process to attach to the camera
  93554. * @param insertAt The position of the post process in case several of them are in use in the scene
  93555. * @returns the position the post process has been inserted at
  93556. */
  93557. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93558. /**
  93559. * Detach a post process to the camera.
  93560. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93561. * @param postProcess The post process to detach from the camera
  93562. */
  93563. detachPostProcess(postProcess: PostProcess): void;
  93564. /**
  93565. * Gets the current world matrix of the camera
  93566. */
  93567. getWorldMatrix(): Matrix;
  93568. /** @hidden */
  93569. _getViewMatrix(): Matrix;
  93570. /**
  93571. * Gets the current view matrix of the camera.
  93572. * @param force forces the camera to recompute the matrix without looking at the cached state
  93573. * @returns the view matrix
  93574. */
  93575. getViewMatrix(force?: boolean): Matrix;
  93576. /**
  93577. * Freeze the projection matrix.
  93578. * It will prevent the cache check of the camera projection compute and can speed up perf
  93579. * if no parameter of the camera are meant to change
  93580. * @param projection Defines manually a projection if necessary
  93581. */
  93582. freezeProjectionMatrix(projection?: Matrix): void;
  93583. /**
  93584. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93585. */
  93586. unfreezeProjectionMatrix(): void;
  93587. /**
  93588. * Gets the current projection matrix of the camera.
  93589. * @param force forces the camera to recompute the matrix without looking at the cached state
  93590. * @returns the projection matrix
  93591. */
  93592. getProjectionMatrix(force?: boolean): Matrix;
  93593. /**
  93594. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93595. * @returns a Matrix
  93596. */
  93597. getTransformationMatrix(): Matrix;
  93598. private _updateFrustumPlanes;
  93599. /**
  93600. * Checks if a cullable object (mesh...) is in the camera frustum
  93601. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93602. * @param target The object to check
  93603. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93604. * @returns true if the object is in frustum otherwise false
  93605. */
  93606. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93607. /**
  93608. * Checks if a cullable object (mesh...) is in the camera frustum
  93609. * Unlike isInFrustum this cheks the full bounding box
  93610. * @param target The object to check
  93611. * @returns true if the object is in frustum otherwise false
  93612. */
  93613. isCompletelyInFrustum(target: ICullable): boolean;
  93614. /**
  93615. * Gets a ray in the forward direction from the camera.
  93616. * @param length Defines the length of the ray to create
  93617. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93618. * @param origin Defines the start point of the ray which defaults to the camera position
  93619. * @returns the forward ray
  93620. */
  93621. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93622. /**
  93623. * Releases resources associated with this node.
  93624. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93625. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93626. */
  93627. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93628. /** @hidden */
  93629. _isLeftCamera: boolean;
  93630. /**
  93631. * Gets the left camera of a rig setup in case of Rigged Camera
  93632. */
  93633. readonly isLeftCamera: boolean;
  93634. /** @hidden */
  93635. _isRightCamera: boolean;
  93636. /**
  93637. * Gets the right camera of a rig setup in case of Rigged Camera
  93638. */
  93639. readonly isRightCamera: boolean;
  93640. /**
  93641. * Gets the left camera of a rig setup in case of Rigged Camera
  93642. */
  93643. readonly leftCamera: Nullable<FreeCamera>;
  93644. /**
  93645. * Gets the right camera of a rig setup in case of Rigged Camera
  93646. */
  93647. readonly rightCamera: Nullable<FreeCamera>;
  93648. /**
  93649. * Gets the left camera target of a rig setup in case of Rigged Camera
  93650. * @returns the target position
  93651. */
  93652. getLeftTarget(): Nullable<Vector3>;
  93653. /**
  93654. * Gets the right camera target of a rig setup in case of Rigged Camera
  93655. * @returns the target position
  93656. */
  93657. getRightTarget(): Nullable<Vector3>;
  93658. /**
  93659. * @hidden
  93660. */
  93661. setCameraRigMode(mode: number, rigParams: any): void;
  93662. /** @hidden */
  93663. static _setStereoscopicRigMode(camera: Camera): void;
  93664. /** @hidden */
  93665. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93666. /** @hidden */
  93667. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93668. /** @hidden */
  93669. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93670. /** @hidden */
  93671. _getVRProjectionMatrix(): Matrix;
  93672. protected _updateCameraRotationMatrix(): void;
  93673. protected _updateWebVRCameraRotationMatrix(): void;
  93674. /**
  93675. * This function MUST be overwritten by the different WebVR cameras available.
  93676. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93677. * @hidden
  93678. */
  93679. _getWebVRProjectionMatrix(): Matrix;
  93680. /**
  93681. * This function MUST be overwritten by the different WebVR cameras available.
  93682. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93683. * @hidden
  93684. */
  93685. _getWebVRViewMatrix(): Matrix;
  93686. /** @hidden */
  93687. setCameraRigParameter(name: string, value: any): void;
  93688. /**
  93689. * needs to be overridden by children so sub has required properties to be copied
  93690. * @hidden
  93691. */
  93692. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93693. /**
  93694. * May need to be overridden by children
  93695. * @hidden
  93696. */
  93697. _updateRigCameras(): void;
  93698. /** @hidden */
  93699. _setupInputs(): void;
  93700. /**
  93701. * Serialiaze the camera setup to a json represention
  93702. * @returns the JSON representation
  93703. */
  93704. serialize(): any;
  93705. /**
  93706. * Clones the current camera.
  93707. * @param name The cloned camera name
  93708. * @returns the cloned camera
  93709. */
  93710. clone(name: string): Camera;
  93711. /**
  93712. * Gets the direction of the camera relative to a given local axis.
  93713. * @param localAxis Defines the reference axis to provide a relative direction.
  93714. * @return the direction
  93715. */
  93716. getDirection(localAxis: Vector3): Vector3;
  93717. /**
  93718. * Returns the current camera absolute rotation
  93719. */
  93720. readonly absoluteRotation: Quaternion;
  93721. /**
  93722. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93723. * @param localAxis Defines the reference axis to provide a relative direction.
  93724. * @param result Defines the vector to store the result in
  93725. */
  93726. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93727. /**
  93728. * Gets a camera constructor for a given camera type
  93729. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93730. * @param name The name of the camera the result will be able to instantiate
  93731. * @param scene The scene the result will construct the camera in
  93732. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93733. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93734. * @returns a factory method to construc the camera
  93735. */
  93736. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93737. /**
  93738. * Compute the world matrix of the camera.
  93739. * @returns the camera world matrix
  93740. */
  93741. computeWorldMatrix(): Matrix;
  93742. /**
  93743. * Parse a JSON and creates the camera from the parsed information
  93744. * @param parsedCamera The JSON to parse
  93745. * @param scene The scene to instantiate the camera in
  93746. * @returns the newly constructed camera
  93747. */
  93748. static Parse(parsedCamera: any, scene: Scene): Camera;
  93749. }
  93750. }
  93751. declare module BABYLON {
  93752. /**
  93753. * Class containing static functions to help procedurally build meshes
  93754. */
  93755. export class DiscBuilder {
  93756. /**
  93757. * Creates a plane polygonal mesh. By default, this is a disc
  93758. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  93759. * * 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
  93760. * * 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
  93761. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  93762. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  93763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93764. * @param name defines the name of the mesh
  93765. * @param options defines the options used to create the mesh
  93766. * @param scene defines the hosting scene
  93767. * @returns the plane polygonal mesh
  93768. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  93769. */
  93770. static CreateDisc(name: string, options: {
  93771. radius?: number;
  93772. tessellation?: number;
  93773. arc?: number;
  93774. updatable?: boolean;
  93775. sideOrientation?: number;
  93776. frontUVs?: Vector4;
  93777. backUVs?: Vector4;
  93778. }, scene?: Nullable<Scene>): Mesh;
  93779. }
  93780. }
  93781. declare module BABYLON {
  93782. /**
  93783. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  93784. *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.
  93785. * The SPS is also a particle system. It provides some methods to manage the particles.
  93786. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  93787. *
  93788. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  93789. */
  93790. export class SolidParticleSystem implements IDisposable {
  93791. /**
  93792. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  93793. * Example : var p = SPS.particles[i];
  93794. */
  93795. particles: SolidParticle[];
  93796. /**
  93797. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  93798. */
  93799. nbParticles: number;
  93800. /**
  93801. * If the particles must ever face the camera (default false). Useful for planar particles.
  93802. */
  93803. billboard: boolean;
  93804. /**
  93805. * Recompute normals when adding a shape
  93806. */
  93807. recomputeNormals: boolean;
  93808. /**
  93809. * This a counter ofr your own usage. It's not set by any SPS functions.
  93810. */
  93811. counter: number;
  93812. /**
  93813. * The SPS name. This name is also given to the underlying mesh.
  93814. */
  93815. name: string;
  93816. /**
  93817. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  93818. */
  93819. mesh: Mesh;
  93820. /**
  93821. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  93822. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  93823. */
  93824. vars: any;
  93825. /**
  93826. * This array is populated when the SPS is set as 'pickable'.
  93827. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  93828. * Each element of this array is an object `{idx: int, faceId: int}`.
  93829. * `idx` is the picked particle index in the `SPS.particles` array
  93830. * `faceId` is the picked face index counted within this particle.
  93831. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  93832. */
  93833. pickedParticles: {
  93834. idx: number;
  93835. faceId: number;
  93836. }[];
  93837. /**
  93838. * This array is populated when `enableDepthSort` is set to true.
  93839. * Each element of this array is an instance of the class DepthSortedParticle.
  93840. */
  93841. depthSortedParticles: DepthSortedParticle[];
  93842. /**
  93843. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  93844. * @hidden
  93845. */
  93846. _bSphereOnly: boolean;
  93847. /**
  93848. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  93849. * @hidden
  93850. */
  93851. _bSphereRadiusFactor: number;
  93852. private _scene;
  93853. private _positions;
  93854. private _indices;
  93855. private _normals;
  93856. private _colors;
  93857. private _uvs;
  93858. private _indices32;
  93859. private _positions32;
  93860. private _normals32;
  93861. private _fixedNormal32;
  93862. private _colors32;
  93863. private _uvs32;
  93864. private _index;
  93865. private _updatable;
  93866. private _pickable;
  93867. private _isVisibilityBoxLocked;
  93868. private _alwaysVisible;
  93869. private _depthSort;
  93870. private _expandable;
  93871. private _shapeCounter;
  93872. private _copy;
  93873. private _color;
  93874. private _computeParticleColor;
  93875. private _computeParticleTexture;
  93876. private _computeParticleRotation;
  93877. private _computeParticleVertex;
  93878. private _computeBoundingBox;
  93879. private _depthSortParticles;
  93880. private _camera;
  93881. private _mustUnrotateFixedNormals;
  93882. private _particlesIntersect;
  93883. private _needs32Bits;
  93884. private _isNotBuilt;
  93885. private _lastParticleId;
  93886. private _idxOfId;
  93887. /**
  93888. * Creates a SPS (Solid Particle System) object.
  93889. * @param name (String) is the SPS name, this will be the underlying mesh name.
  93890. * @param scene (Scene) is the scene in which the SPS is added.
  93891. * @param options defines the options of the sps e.g.
  93892. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  93893. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  93894. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  93895. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  93896. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  93897. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  93898. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  93899. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  93900. */
  93901. constructor(name: string, scene: Scene, options?: {
  93902. updatable?: boolean;
  93903. isPickable?: boolean;
  93904. enableDepthSort?: boolean;
  93905. particleIntersection?: boolean;
  93906. boundingSphereOnly?: boolean;
  93907. bSphereRadiusFactor?: number;
  93908. expandable?: boolean;
  93909. });
  93910. /**
  93911. * Builds the SPS underlying mesh. Returns a standard Mesh.
  93912. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  93913. * @returns the created mesh
  93914. */
  93915. buildMesh(): Mesh;
  93916. /**
  93917. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  93918. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  93919. * Thus the particles generated from `digest()` have their property `position` set yet.
  93920. * @param mesh ( Mesh ) is the mesh to be digested
  93921. * @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
  93922. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  93923. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  93924. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  93925. * @returns the current SPS
  93926. */
  93927. digest(mesh: Mesh, options?: {
  93928. facetNb?: number;
  93929. number?: number;
  93930. delta?: number;
  93931. storage?: [];
  93932. }): SolidParticleSystem;
  93933. /**
  93934. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  93935. * @hidden
  93936. */
  93937. private _unrotateFixedNormals;
  93938. /**
  93939. * Resets the temporary working copy particle
  93940. * @hidden
  93941. */
  93942. private _resetCopy;
  93943. /**
  93944. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  93945. * @param p the current index in the positions array to be updated
  93946. * @param shape a Vector3 array, the shape geometry
  93947. * @param positions the positions array to be updated
  93948. * @param meshInd the shape indices array
  93949. * @param indices the indices array to be updated
  93950. * @param meshUV the shape uv array
  93951. * @param uvs the uv array to be updated
  93952. * @param meshCol the shape color array
  93953. * @param colors the color array to be updated
  93954. * @param meshNor the shape normals array
  93955. * @param normals the normals array to be updated
  93956. * @param idx the particle index
  93957. * @param idxInShape the particle index in its shape
  93958. * @param options the addShape() method passed options
  93959. * @hidden
  93960. */
  93961. private _meshBuilder;
  93962. /**
  93963. * Returns a shape Vector3 array from positions float array
  93964. * @param positions float array
  93965. * @returns a vector3 array
  93966. * @hidden
  93967. */
  93968. private _posToShape;
  93969. /**
  93970. * Returns a shapeUV array from a float uvs (array deep copy)
  93971. * @param uvs as a float array
  93972. * @returns a shapeUV array
  93973. * @hidden
  93974. */
  93975. private _uvsToShapeUV;
  93976. /**
  93977. * Adds a new particle object in the particles array
  93978. * @param idx particle index in particles array
  93979. * @param id particle id
  93980. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  93981. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  93982. * @param model particle ModelShape object
  93983. * @param shapeId model shape identifier
  93984. * @param idxInShape index of the particle in the current model
  93985. * @param bInfo model bounding info object
  93986. * @param storage target storage array, if any
  93987. * @hidden
  93988. */
  93989. private _addParticle;
  93990. /**
  93991. * Adds some particles to the SPS from the model shape. Returns the shape id.
  93992. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  93993. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  93994. * @param nb (positive integer) the number of particles to be created from this model
  93995. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  93996. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  93997. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  93998. * @returns the number of shapes in the system
  93999. */
  94000. addShape(mesh: Mesh, nb: number, options?: {
  94001. positionFunction?: any;
  94002. vertexFunction?: any;
  94003. storage?: [];
  94004. }): number;
  94005. /**
  94006. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  94007. * @hidden
  94008. */
  94009. private _rebuildParticle;
  94010. /**
  94011. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  94012. * @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.
  94013. * @returns the SPS.
  94014. */
  94015. rebuildMesh(reset?: boolean): SolidParticleSystem;
  94016. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  94017. * Returns an array with the removed particles.
  94018. * 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.
  94019. * The SPS can't be empty so at least one particle needs to remain in place.
  94020. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  94021. * @param start index of the first particle to remove
  94022. * @param end index of the last particle to remove (included)
  94023. * @returns an array populated with the removed particles
  94024. */
  94025. removeParticles(start: number, end: number): SolidParticle[];
  94026. /**
  94027. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  94028. * @param solidParticleArray an array populated with Solid Particles objects
  94029. * @returns the SPS
  94030. */
  94031. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  94032. /**
  94033. * Creates a new particle and modifies the SPS mesh geometry :
  94034. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  94035. * - calls _addParticle() to populate the particle array
  94036. * factorized code from addShape() and insertParticlesFromArray()
  94037. * @param idx particle index in the particles array
  94038. * @param i particle index in its shape
  94039. * @param modelShape particle ModelShape object
  94040. * @param shape shape vertex array
  94041. * @param meshInd shape indices array
  94042. * @param meshUV shape uv array
  94043. * @param meshCol shape color array
  94044. * @param meshNor shape normals array
  94045. * @param bbInfo shape bounding info
  94046. * @param storage target particle storage
  94047. * @options addShape() passed options
  94048. * @hidden
  94049. */
  94050. private _insertNewParticle;
  94051. /**
  94052. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  94053. * This method calls `updateParticle()` for each particle of the SPS.
  94054. * For an animated SPS, it is usually called within the render loop.
  94055. * 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.
  94056. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  94057. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  94058. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  94059. * @returns the SPS.
  94060. */
  94061. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  94062. /**
  94063. * Disposes the SPS.
  94064. */
  94065. dispose(): void;
  94066. /**
  94067. * Returns a SolidParticle object from its identifier : particle.id
  94068. * @param id (integer) the particle Id
  94069. * @returns the searched particle or null if not found in the SPS.
  94070. */
  94071. getParticleById(id: number): Nullable<SolidParticle>;
  94072. /**
  94073. * Returns a new array populated with the particles having the passed shapeId.
  94074. * @param shapeId (integer) the shape identifier
  94075. * @returns a new solid particle array
  94076. */
  94077. getParticlesByShapeId(shapeId: number): SolidParticle[];
  94078. /**
  94079. * Populates the passed array "ref" with the particles having the passed shapeId.
  94080. * @param shapeId the shape identifier
  94081. * @returns the SPS
  94082. * @param ref
  94083. */
  94084. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  94085. /**
  94086. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  94087. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94088. * @returns the SPS.
  94089. */
  94090. refreshVisibleSize(): SolidParticleSystem;
  94091. /**
  94092. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  94093. * @param size the size (float) of the visibility box
  94094. * note : this doesn't lock the SPS mesh bounding box.
  94095. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94096. */
  94097. setVisibilityBox(size: number): void;
  94098. /**
  94099. * Gets whether the SPS as always visible or not
  94100. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94101. */
  94102. /**
  94103. * Sets the SPS as always visible or not
  94104. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94105. */
  94106. isAlwaysVisible: boolean;
  94107. /**
  94108. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  94109. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94110. */
  94111. /**
  94112. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  94113. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94114. */
  94115. isVisibilityBoxLocked: boolean;
  94116. /**
  94117. * Tells to `setParticles()` to compute the particle rotations or not.
  94118. * Default value : true. The SPS is faster when it's set to false.
  94119. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  94120. */
  94121. /**
  94122. * Gets if `setParticles()` computes the particle rotations or not.
  94123. * Default value : true. The SPS is faster when it's set to false.
  94124. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  94125. */
  94126. computeParticleRotation: boolean;
  94127. /**
  94128. * Tells to `setParticles()` to compute the particle colors or not.
  94129. * Default value : true. The SPS is faster when it's set to false.
  94130. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  94131. */
  94132. /**
  94133. * Gets if `setParticles()` computes the particle colors or not.
  94134. * Default value : true. The SPS is faster when it's set to false.
  94135. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  94136. */
  94137. computeParticleColor: boolean;
  94138. /**
  94139. * Gets if `setParticles()` computes the particle textures or not.
  94140. * Default value : true. The SPS is faster when it's set to false.
  94141. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  94142. */
  94143. computeParticleTexture: boolean;
  94144. /**
  94145. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  94146. * Default value : false. The SPS is faster when it's set to false.
  94147. * Note : the particle custom vertex positions aren't stored values.
  94148. */
  94149. /**
  94150. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  94151. * Default value : false. The SPS is faster when it's set to false.
  94152. * Note : the particle custom vertex positions aren't stored values.
  94153. */
  94154. computeParticleVertex: boolean;
  94155. /**
  94156. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  94157. */
  94158. /**
  94159. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  94160. */
  94161. computeBoundingBox: boolean;
  94162. /**
  94163. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  94164. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  94165. * Default : `true`
  94166. */
  94167. /**
  94168. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  94169. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  94170. * Default : `true`
  94171. */
  94172. depthSortParticles: boolean;
  94173. /**
  94174. * Gets if the SPS is created as expandable at construction time.
  94175. * Default : `false`
  94176. */
  94177. readonly expandable: boolean;
  94178. /**
  94179. * This function does nothing. It may be overwritten to set all the particle first values.
  94180. * The SPS doesn't call this function, you may have to call it by your own.
  94181. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94182. */
  94183. initParticles(): void;
  94184. /**
  94185. * This function does nothing. It may be overwritten to recycle a particle.
  94186. * The SPS doesn't call this function, you may have to call it by your own.
  94187. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94188. * @param particle The particle to recycle
  94189. * @returns the recycled particle
  94190. */
  94191. recycleParticle(particle: SolidParticle): SolidParticle;
  94192. /**
  94193. * Updates a particle : this function should be overwritten by the user.
  94194. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  94195. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94196. * @example : just set a particle position or velocity and recycle conditions
  94197. * @param particle The particle to update
  94198. * @returns the updated particle
  94199. */
  94200. updateParticle(particle: SolidParticle): SolidParticle;
  94201. /**
  94202. * Updates a vertex of a particle : it can be overwritten by the user.
  94203. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  94204. * @param particle the current particle
  94205. * @param vertex the current index of the current particle
  94206. * @param pt the index of the current vertex in the particle shape
  94207. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  94208. * @example : just set a vertex particle position
  94209. * @returns the updated vertex
  94210. */
  94211. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  94212. /**
  94213. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  94214. * This does nothing and may be overwritten by the user.
  94215. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94216. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94217. * @param update the boolean update value actually passed to setParticles()
  94218. */
  94219. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  94220. /**
  94221. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  94222. * This will be passed three parameters.
  94223. * This does nothing and may be overwritten by the user.
  94224. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94225. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94226. * @param update the boolean update value actually passed to setParticles()
  94227. */
  94228. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  94229. }
  94230. }
  94231. declare module BABYLON {
  94232. /**
  94233. * Represents one particle of a solid particle system.
  94234. */
  94235. export class SolidParticle {
  94236. /**
  94237. * particle global index
  94238. */
  94239. idx: number;
  94240. /**
  94241. * particle identifier
  94242. */
  94243. id: number;
  94244. /**
  94245. * The color of the particle
  94246. */
  94247. color: Nullable<Color4>;
  94248. /**
  94249. * The world space position of the particle.
  94250. */
  94251. position: Vector3;
  94252. /**
  94253. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  94254. */
  94255. rotation: Vector3;
  94256. /**
  94257. * The world space rotation quaternion of the particle.
  94258. */
  94259. rotationQuaternion: Nullable<Quaternion>;
  94260. /**
  94261. * The scaling of the particle.
  94262. */
  94263. scaling: Vector3;
  94264. /**
  94265. * The uvs of the particle.
  94266. */
  94267. uvs: Vector4;
  94268. /**
  94269. * The current speed of the particle.
  94270. */
  94271. velocity: Vector3;
  94272. /**
  94273. * The pivot point in the particle local space.
  94274. */
  94275. pivot: Vector3;
  94276. /**
  94277. * Must the particle be translated from its pivot point in its local space ?
  94278. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  94279. * Default : false
  94280. */
  94281. translateFromPivot: boolean;
  94282. /**
  94283. * Is the particle active or not ?
  94284. */
  94285. alive: boolean;
  94286. /**
  94287. * Is the particle visible or not ?
  94288. */
  94289. isVisible: boolean;
  94290. /**
  94291. * Index of this particle in the global "positions" array (Internal use)
  94292. * @hidden
  94293. */
  94294. _pos: number;
  94295. /**
  94296. * @hidden Index of this particle in the global "indices" array (Internal use)
  94297. */
  94298. _ind: number;
  94299. /**
  94300. * @hidden ModelShape of this particle (Internal use)
  94301. */
  94302. _model: ModelShape;
  94303. /**
  94304. * ModelShape id of this particle
  94305. */
  94306. shapeId: number;
  94307. /**
  94308. * Index of the particle in its shape id
  94309. */
  94310. idxInShape: number;
  94311. /**
  94312. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  94313. */
  94314. _modelBoundingInfo: BoundingInfo;
  94315. /**
  94316. * @hidden Particle BoundingInfo object (Internal use)
  94317. */
  94318. _boundingInfo: BoundingInfo;
  94319. /**
  94320. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  94321. */
  94322. _sps: SolidParticleSystem;
  94323. /**
  94324. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  94325. */
  94326. _stillInvisible: boolean;
  94327. /**
  94328. * @hidden Last computed particle rotation matrix
  94329. */
  94330. _rotationMatrix: number[];
  94331. /**
  94332. * Parent particle Id, if any.
  94333. * Default null.
  94334. */
  94335. parentId: Nullable<number>;
  94336. /**
  94337. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  94338. * The possible values are :
  94339. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  94340. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94341. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  94342. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  94343. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94344. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  94345. * */
  94346. cullingStrategy: number;
  94347. /**
  94348. * @hidden Internal global position in the SPS.
  94349. */
  94350. _globalPosition: Vector3;
  94351. /**
  94352. * Creates a Solid Particle object.
  94353. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  94354. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  94355. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  94356. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  94357. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  94358. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  94359. * @param shapeId (integer) is the model shape identifier in the SPS.
  94360. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  94361. * @param sps defines the sps it is associated to
  94362. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  94363. */
  94364. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  94365. /**
  94366. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  94367. * @param target the particle target
  94368. * @returns the current particle
  94369. */
  94370. copyToRef(target: SolidParticle): SolidParticle;
  94371. /**
  94372. * Legacy support, changed scale to scaling
  94373. */
  94374. /**
  94375. * Legacy support, changed scale to scaling
  94376. */
  94377. scale: Vector3;
  94378. /**
  94379. * Legacy support, changed quaternion to rotationQuaternion
  94380. */
  94381. /**
  94382. * Legacy support, changed quaternion to rotationQuaternion
  94383. */
  94384. quaternion: Nullable<Quaternion>;
  94385. /**
  94386. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  94387. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  94388. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  94389. * @returns true if it intersects
  94390. */
  94391. intersectsMesh(target: Mesh | SolidParticle): boolean;
  94392. /**
  94393. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  94394. * A particle is in the frustum if its bounding box intersects the frustum
  94395. * @param frustumPlanes defines the frustum to test
  94396. * @returns true if the particle is in the frustum planes
  94397. */
  94398. isInFrustum(frustumPlanes: Plane[]): boolean;
  94399. /**
  94400. * get the rotation matrix of the particle
  94401. * @hidden
  94402. */
  94403. getRotationMatrix(m: Matrix): void;
  94404. }
  94405. /**
  94406. * Represents the shape of the model used by one particle of a solid particle system.
  94407. * SPS internal tool, don't use it manually.
  94408. */
  94409. export class ModelShape {
  94410. /**
  94411. * The shape id
  94412. * @hidden
  94413. */
  94414. shapeID: number;
  94415. /**
  94416. * flat array of model positions (internal use)
  94417. * @hidden
  94418. */
  94419. _shape: Vector3[];
  94420. /**
  94421. * flat array of model UVs (internal use)
  94422. * @hidden
  94423. */
  94424. _shapeUV: number[];
  94425. /**
  94426. * color array of the model
  94427. * @hidden
  94428. */
  94429. _shapeColors: number[];
  94430. /**
  94431. * indices array of the model
  94432. * @hidden
  94433. */
  94434. _indices: number[];
  94435. /**
  94436. * normals array of the model
  94437. * @hidden
  94438. */
  94439. _normals: number[];
  94440. /**
  94441. * length of the shape in the model indices array (internal use)
  94442. * @hidden
  94443. */
  94444. _indicesLength: number;
  94445. /**
  94446. * Custom position function (internal use)
  94447. * @hidden
  94448. */
  94449. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  94450. /**
  94451. * Custom vertex function (internal use)
  94452. * @hidden
  94453. */
  94454. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  94455. /**
  94456. * 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.
  94457. * SPS internal tool, don't use it manually.
  94458. * @hidden
  94459. */
  94460. 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>);
  94461. }
  94462. /**
  94463. * Represents a Depth Sorted Particle in the solid particle system.
  94464. */
  94465. export class DepthSortedParticle {
  94466. /**
  94467. * Index of the particle in the "indices" array
  94468. */
  94469. ind: number;
  94470. /**
  94471. * Length of the particle shape in the "indices" array
  94472. */
  94473. indicesLength: number;
  94474. /**
  94475. * Squared distance from the particle to the camera
  94476. */
  94477. sqDistance: number;
  94478. }
  94479. }
  94480. declare module BABYLON {
  94481. /**
  94482. * @hidden
  94483. */
  94484. export class _MeshCollisionData {
  94485. _checkCollisions: boolean;
  94486. _collisionMask: number;
  94487. _collisionGroup: number;
  94488. _collider: Nullable<Collider>;
  94489. _oldPositionForCollisions: Vector3;
  94490. _diffPositionForCollisions: Vector3;
  94491. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  94492. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  94493. }
  94494. }
  94495. declare module BABYLON {
  94496. /** @hidden */
  94497. class _FacetDataStorage {
  94498. facetPositions: Vector3[];
  94499. facetNormals: Vector3[];
  94500. facetPartitioning: number[][];
  94501. facetNb: number;
  94502. partitioningSubdivisions: number;
  94503. partitioningBBoxRatio: number;
  94504. facetDataEnabled: boolean;
  94505. facetParameters: any;
  94506. bbSize: Vector3;
  94507. subDiv: {
  94508. max: number;
  94509. X: number;
  94510. Y: number;
  94511. Z: number;
  94512. };
  94513. facetDepthSort: boolean;
  94514. facetDepthSortEnabled: boolean;
  94515. depthSortedIndices: IndicesArray;
  94516. depthSortedFacets: {
  94517. ind: number;
  94518. sqDistance: number;
  94519. }[];
  94520. facetDepthSortFunction: (f1: {
  94521. ind: number;
  94522. sqDistance: number;
  94523. }, f2: {
  94524. ind: number;
  94525. sqDistance: number;
  94526. }) => number;
  94527. facetDepthSortFrom: Vector3;
  94528. facetDepthSortOrigin: Vector3;
  94529. invertedMatrix: Matrix;
  94530. }
  94531. /**
  94532. * @hidden
  94533. **/
  94534. class _InternalAbstractMeshDataInfo {
  94535. _hasVertexAlpha: boolean;
  94536. _useVertexColors: boolean;
  94537. _numBoneInfluencers: number;
  94538. _applyFog: boolean;
  94539. _receiveShadows: boolean;
  94540. _facetData: _FacetDataStorage;
  94541. _visibility: number;
  94542. _skeleton: Nullable<Skeleton>;
  94543. _layerMask: number;
  94544. _computeBonesUsingShaders: boolean;
  94545. _isActive: boolean;
  94546. _onlyForInstances: boolean;
  94547. _isActiveIntermediate: boolean;
  94548. _onlyForInstancesIntermediate: boolean;
  94549. _actAsRegularMesh: boolean;
  94550. }
  94551. /**
  94552. * Class used to store all common mesh properties
  94553. */
  94554. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  94555. /** No occlusion */
  94556. static OCCLUSION_TYPE_NONE: number;
  94557. /** Occlusion set to optimisitic */
  94558. static OCCLUSION_TYPE_OPTIMISTIC: number;
  94559. /** Occlusion set to strict */
  94560. static OCCLUSION_TYPE_STRICT: number;
  94561. /** Use an accurante occlusion algorithm */
  94562. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  94563. /** Use a conservative occlusion algorithm */
  94564. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  94565. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  94566. * Test order :
  94567. * Is the bounding sphere outside the frustum ?
  94568. * If not, are the bounding box vertices outside the frustum ?
  94569. * It not, then the cullable object is in the frustum.
  94570. */
  94571. static readonly CULLINGSTRATEGY_STANDARD: number;
  94572. /** Culling strategy : Bounding Sphere Only.
  94573. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  94574. * It's also less accurate than the standard because some not visible objects can still be selected.
  94575. * Test : is the bounding sphere outside the frustum ?
  94576. * If not, then the cullable object is in the frustum.
  94577. */
  94578. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  94579. /** Culling strategy : Optimistic Inclusion.
  94580. * This in an inclusion test first, then the standard exclusion test.
  94581. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  94582. * 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.
  94583. * Anyway, it's as accurate as the standard strategy.
  94584. * Test :
  94585. * Is the cullable object bounding sphere center in the frustum ?
  94586. * If not, apply the default culling strategy.
  94587. */
  94588. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  94589. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  94590. * This in an inclusion test first, then the bounding sphere only exclusion test.
  94591. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  94592. * 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.
  94593. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  94594. * Test :
  94595. * Is the cullable object bounding sphere center in the frustum ?
  94596. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  94597. */
  94598. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  94599. /**
  94600. * No billboard
  94601. */
  94602. static readonly BILLBOARDMODE_NONE: number;
  94603. /** Billboard on X axis */
  94604. static readonly BILLBOARDMODE_X: number;
  94605. /** Billboard on Y axis */
  94606. static readonly BILLBOARDMODE_Y: number;
  94607. /** Billboard on Z axis */
  94608. static readonly BILLBOARDMODE_Z: number;
  94609. /** Billboard on all axes */
  94610. static readonly BILLBOARDMODE_ALL: number;
  94611. /** Billboard on using position instead of orientation */
  94612. static readonly BILLBOARDMODE_USE_POSITION: number;
  94613. /** @hidden */
  94614. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  94615. /**
  94616. * The culling strategy to use to check whether the mesh must be rendered or not.
  94617. * This value can be changed at any time and will be used on the next render mesh selection.
  94618. * The possible values are :
  94619. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  94620. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94621. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  94622. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  94623. * Please read each static variable documentation to get details about the culling process.
  94624. * */
  94625. cullingStrategy: number;
  94626. /**
  94627. * Gets the number of facets in the mesh
  94628. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94629. */
  94630. readonly facetNb: number;
  94631. /**
  94632. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  94633. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  94634. */
  94635. partitioningSubdivisions: number;
  94636. /**
  94637. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  94638. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  94639. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  94640. */
  94641. partitioningBBoxRatio: number;
  94642. /**
  94643. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  94644. * Works only for updatable meshes.
  94645. * Doesn't work with multi-materials
  94646. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94647. */
  94648. mustDepthSortFacets: boolean;
  94649. /**
  94650. * The location (Vector3) where the facet depth sort must be computed from.
  94651. * By default, the active camera position.
  94652. * Used only when facet depth sort is enabled
  94653. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94654. */
  94655. facetDepthSortFrom: Vector3;
  94656. /**
  94657. * gets a boolean indicating if facetData is enabled
  94658. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94659. */
  94660. readonly isFacetDataEnabled: boolean;
  94661. /** @hidden */
  94662. _updateNonUniformScalingState(value: boolean): boolean;
  94663. /**
  94664. * An event triggered when this mesh collides with another one
  94665. */
  94666. onCollideObservable: Observable<AbstractMesh>;
  94667. /** Set a function to call when this mesh collides with another one */
  94668. onCollide: () => void;
  94669. /**
  94670. * An event triggered when the collision's position changes
  94671. */
  94672. onCollisionPositionChangeObservable: Observable<Vector3>;
  94673. /** Set a function to call when the collision's position changes */
  94674. onCollisionPositionChange: () => void;
  94675. /**
  94676. * An event triggered when material is changed
  94677. */
  94678. onMaterialChangedObservable: Observable<AbstractMesh>;
  94679. /**
  94680. * Gets or sets the orientation for POV movement & rotation
  94681. */
  94682. definedFacingForward: boolean;
  94683. /** @hidden */
  94684. _occlusionQuery: Nullable<WebGLQuery>;
  94685. /** @hidden */
  94686. _renderingGroup: Nullable<RenderingGroup>;
  94687. /**
  94688. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94689. */
  94690. /**
  94691. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94692. */
  94693. visibility: number;
  94694. /** Gets or sets the alpha index used to sort transparent meshes
  94695. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  94696. */
  94697. alphaIndex: number;
  94698. /**
  94699. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  94700. */
  94701. isVisible: boolean;
  94702. /**
  94703. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  94704. */
  94705. isPickable: boolean;
  94706. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  94707. showSubMeshesBoundingBox: boolean;
  94708. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  94709. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  94710. */
  94711. isBlocker: boolean;
  94712. /**
  94713. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  94714. */
  94715. enablePointerMoveEvents: boolean;
  94716. /**
  94717. * Specifies the rendering group id for this mesh (0 by default)
  94718. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  94719. */
  94720. renderingGroupId: number;
  94721. private _material;
  94722. /** Gets or sets current material */
  94723. material: Nullable<Material>;
  94724. /**
  94725. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  94726. * @see http://doc.babylonjs.com/babylon101/shadows
  94727. */
  94728. receiveShadows: boolean;
  94729. /** Defines color to use when rendering outline */
  94730. outlineColor: Color3;
  94731. /** Define width to use when rendering outline */
  94732. outlineWidth: number;
  94733. /** Defines color to use when rendering overlay */
  94734. overlayColor: Color3;
  94735. /** Defines alpha to use when rendering overlay */
  94736. overlayAlpha: number;
  94737. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  94738. hasVertexAlpha: boolean;
  94739. /** 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) */
  94740. useVertexColors: boolean;
  94741. /**
  94742. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  94743. */
  94744. computeBonesUsingShaders: boolean;
  94745. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  94746. numBoneInfluencers: number;
  94747. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  94748. applyFog: boolean;
  94749. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  94750. useOctreeForRenderingSelection: boolean;
  94751. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  94752. useOctreeForPicking: boolean;
  94753. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  94754. useOctreeForCollisions: boolean;
  94755. /**
  94756. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  94757. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  94758. */
  94759. layerMask: number;
  94760. /**
  94761. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  94762. */
  94763. alwaysSelectAsActiveMesh: boolean;
  94764. /**
  94765. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  94766. */
  94767. doNotSyncBoundingInfo: boolean;
  94768. /**
  94769. * Gets or sets the current action manager
  94770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94771. */
  94772. actionManager: Nullable<AbstractActionManager>;
  94773. private _meshCollisionData;
  94774. /**
  94775. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  94776. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94777. */
  94778. ellipsoid: Vector3;
  94779. /**
  94780. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  94781. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94782. */
  94783. ellipsoidOffset: Vector3;
  94784. /**
  94785. * Gets or sets a collision mask used to mask collisions (default is -1).
  94786. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94787. */
  94788. collisionMask: number;
  94789. /**
  94790. * Gets or sets the current collision group mask (-1 by default).
  94791. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94792. */
  94793. collisionGroup: number;
  94794. /**
  94795. * Defines edge width used when edgesRenderer is enabled
  94796. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94797. */
  94798. edgesWidth: number;
  94799. /**
  94800. * Defines edge color used when edgesRenderer is enabled
  94801. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94802. */
  94803. edgesColor: Color4;
  94804. /** @hidden */
  94805. _edgesRenderer: Nullable<IEdgesRenderer>;
  94806. /** @hidden */
  94807. _masterMesh: Nullable<AbstractMesh>;
  94808. /** @hidden */
  94809. _boundingInfo: Nullable<BoundingInfo>;
  94810. /** @hidden */
  94811. _renderId: number;
  94812. /**
  94813. * Gets or sets the list of subMeshes
  94814. * @see http://doc.babylonjs.com/how_to/multi_materials
  94815. */
  94816. subMeshes: SubMesh[];
  94817. /** @hidden */
  94818. _intersectionsInProgress: AbstractMesh[];
  94819. /** @hidden */
  94820. _unIndexed: boolean;
  94821. /** @hidden */
  94822. _lightSources: Light[];
  94823. /** Gets the list of lights affecting that mesh */
  94824. readonly lightSources: Light[];
  94825. /** @hidden */
  94826. readonly _positions: Nullable<Vector3[]>;
  94827. /** @hidden */
  94828. _waitingData: {
  94829. lods: Nullable<any>;
  94830. actions: Nullable<any>;
  94831. freezeWorldMatrix: Nullable<boolean>;
  94832. };
  94833. /** @hidden */
  94834. _bonesTransformMatrices: Nullable<Float32Array>;
  94835. /** @hidden */
  94836. _transformMatrixTexture: Nullable<RawTexture>;
  94837. /**
  94838. * Gets or sets a skeleton to apply skining transformations
  94839. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94840. */
  94841. skeleton: Nullable<Skeleton>;
  94842. /**
  94843. * An event triggered when the mesh is rebuilt.
  94844. */
  94845. onRebuildObservable: Observable<AbstractMesh>;
  94846. /**
  94847. * Creates a new AbstractMesh
  94848. * @param name defines the name of the mesh
  94849. * @param scene defines the hosting scene
  94850. */
  94851. constructor(name: string, scene?: Nullable<Scene>);
  94852. /**
  94853. * Returns the string "AbstractMesh"
  94854. * @returns "AbstractMesh"
  94855. */
  94856. getClassName(): string;
  94857. /**
  94858. * Gets a string representation of the current mesh
  94859. * @param fullDetails defines a boolean indicating if full details must be included
  94860. * @returns a string representation of the current mesh
  94861. */
  94862. toString(fullDetails?: boolean): string;
  94863. /**
  94864. * @hidden
  94865. */
  94866. protected _getEffectiveParent(): Nullable<Node>;
  94867. /** @hidden */
  94868. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  94869. /** @hidden */
  94870. _rebuild(): void;
  94871. /** @hidden */
  94872. _resyncLightSources(): void;
  94873. /** @hidden */
  94874. _resyncLighSource(light: Light): void;
  94875. /** @hidden */
  94876. _unBindEffect(): void;
  94877. /** @hidden */
  94878. _removeLightSource(light: Light, dispose: boolean): void;
  94879. private _markSubMeshesAsDirty;
  94880. /** @hidden */
  94881. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  94882. /** @hidden */
  94883. _markSubMeshesAsAttributesDirty(): void;
  94884. /** @hidden */
  94885. _markSubMeshesAsMiscDirty(): void;
  94886. /**
  94887. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  94888. */
  94889. scaling: Vector3;
  94890. /**
  94891. * Returns true if the mesh is blocked. Implemented by child classes
  94892. */
  94893. readonly isBlocked: boolean;
  94894. /**
  94895. * Returns the mesh itself by default. Implemented by child classes
  94896. * @param camera defines the camera to use to pick the right LOD level
  94897. * @returns the currentAbstractMesh
  94898. */
  94899. getLOD(camera: Camera): Nullable<AbstractMesh>;
  94900. /**
  94901. * Returns 0 by default. Implemented by child classes
  94902. * @returns an integer
  94903. */
  94904. getTotalVertices(): number;
  94905. /**
  94906. * Returns a positive integer : the total number of indices in this mesh geometry.
  94907. * @returns the numner of indices or zero if the mesh has no geometry.
  94908. */
  94909. getTotalIndices(): number;
  94910. /**
  94911. * Returns null by default. Implemented by child classes
  94912. * @returns null
  94913. */
  94914. getIndices(): Nullable<IndicesArray>;
  94915. /**
  94916. * Returns the array of the requested vertex data kind. Implemented by child classes
  94917. * @param kind defines the vertex data kind to use
  94918. * @returns null
  94919. */
  94920. getVerticesData(kind: string): Nullable<FloatArray>;
  94921. /**
  94922. * Sets the vertex data of the mesh geometry for the requested `kind`.
  94923. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  94924. * Note that a new underlying VertexBuffer object is created each call.
  94925. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  94926. * @param kind defines vertex data kind:
  94927. * * VertexBuffer.PositionKind
  94928. * * VertexBuffer.UVKind
  94929. * * VertexBuffer.UV2Kind
  94930. * * VertexBuffer.UV3Kind
  94931. * * VertexBuffer.UV4Kind
  94932. * * VertexBuffer.UV5Kind
  94933. * * VertexBuffer.UV6Kind
  94934. * * VertexBuffer.ColorKind
  94935. * * VertexBuffer.MatricesIndicesKind
  94936. * * VertexBuffer.MatricesIndicesExtraKind
  94937. * * VertexBuffer.MatricesWeightsKind
  94938. * * VertexBuffer.MatricesWeightsExtraKind
  94939. * @param data defines the data source
  94940. * @param updatable defines if the data must be flagged as updatable (or static)
  94941. * @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
  94942. * @returns the current mesh
  94943. */
  94944. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94945. /**
  94946. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  94947. * If the mesh has no geometry, it is simply returned as it is.
  94948. * @param kind defines vertex data kind:
  94949. * * VertexBuffer.PositionKind
  94950. * * VertexBuffer.UVKind
  94951. * * VertexBuffer.UV2Kind
  94952. * * VertexBuffer.UV3Kind
  94953. * * VertexBuffer.UV4Kind
  94954. * * VertexBuffer.UV5Kind
  94955. * * VertexBuffer.UV6Kind
  94956. * * VertexBuffer.ColorKind
  94957. * * VertexBuffer.MatricesIndicesKind
  94958. * * VertexBuffer.MatricesIndicesExtraKind
  94959. * * VertexBuffer.MatricesWeightsKind
  94960. * * VertexBuffer.MatricesWeightsExtraKind
  94961. * @param data defines the data source
  94962. * @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
  94963. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  94964. * @returns the current mesh
  94965. */
  94966. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  94967. /**
  94968. * Sets the mesh indices,
  94969. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  94970. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  94971. * @param totalVertices Defines the total number of vertices
  94972. * @returns the current mesh
  94973. */
  94974. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  94975. /**
  94976. * Gets a boolean indicating if specific vertex data is present
  94977. * @param kind defines the vertex data kind to use
  94978. * @returns true is data kind is present
  94979. */
  94980. isVerticesDataPresent(kind: string): boolean;
  94981. /**
  94982. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  94983. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  94984. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  94985. * @returns a BoundingInfo
  94986. */
  94987. getBoundingInfo(): BoundingInfo;
  94988. /**
  94989. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  94990. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  94991. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  94992. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  94993. * @returns the current mesh
  94994. */
  94995. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  94996. /**
  94997. * Overwrite the current bounding info
  94998. * @param boundingInfo defines the new bounding info
  94999. * @returns the current mesh
  95000. */
  95001. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  95002. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  95003. readonly useBones: boolean;
  95004. /** @hidden */
  95005. _preActivate(): void;
  95006. /** @hidden */
  95007. _preActivateForIntermediateRendering(renderId: number): void;
  95008. /** @hidden */
  95009. _activate(renderId: number, intermediateRendering: boolean): boolean;
  95010. /** @hidden */
  95011. _postActivate(): void;
  95012. /** @hidden */
  95013. _freeze(): void;
  95014. /** @hidden */
  95015. _unFreeze(): void;
  95016. /**
  95017. * Gets the current world matrix
  95018. * @returns a Matrix
  95019. */
  95020. getWorldMatrix(): Matrix;
  95021. /** @hidden */
  95022. _getWorldMatrixDeterminant(): number;
  95023. /**
  95024. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  95025. */
  95026. readonly isAnInstance: boolean;
  95027. /**
  95028. * Gets a boolean indicating if this mesh has instances
  95029. */
  95030. readonly hasInstances: boolean;
  95031. /**
  95032. * Perform relative position change from the point of view of behind the front of the mesh.
  95033. * This is performed taking into account the meshes current rotation, so you do not have to care.
  95034. * Supports definition of mesh facing forward or backward
  95035. * @param amountRight defines the distance on the right axis
  95036. * @param amountUp defines the distance on the up axis
  95037. * @param amountForward defines the distance on the forward axis
  95038. * @returns the current mesh
  95039. */
  95040. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  95041. /**
  95042. * Calculate relative position change from the point of view of behind the front of the mesh.
  95043. * This is performed taking into account the meshes current rotation, so you do not have to care.
  95044. * Supports definition of mesh facing forward or backward
  95045. * @param amountRight defines the distance on the right axis
  95046. * @param amountUp defines the distance on the up axis
  95047. * @param amountForward defines the distance on the forward axis
  95048. * @returns the new displacement vector
  95049. */
  95050. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  95051. /**
  95052. * Perform relative rotation change from the point of view of behind the front of the mesh.
  95053. * Supports definition of mesh facing forward or backward
  95054. * @param flipBack defines the flip
  95055. * @param twirlClockwise defines the twirl
  95056. * @param tiltRight defines the tilt
  95057. * @returns the current mesh
  95058. */
  95059. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  95060. /**
  95061. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  95062. * Supports definition of mesh facing forward or backward.
  95063. * @param flipBack defines the flip
  95064. * @param twirlClockwise defines the twirl
  95065. * @param tiltRight defines the tilt
  95066. * @returns the new rotation vector
  95067. */
  95068. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  95069. /**
  95070. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  95071. * This means the mesh underlying bounding box and sphere are recomputed.
  95072. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  95073. * @returns the current mesh
  95074. */
  95075. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  95076. /** @hidden */
  95077. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  95078. /** @hidden */
  95079. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  95080. /** @hidden */
  95081. _updateBoundingInfo(): AbstractMesh;
  95082. /** @hidden */
  95083. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  95084. /** @hidden */
  95085. protected _afterComputeWorldMatrix(): void;
  95086. /** @hidden */
  95087. readonly _effectiveMesh: AbstractMesh;
  95088. /**
  95089. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  95090. * A mesh is in the frustum if its bounding box intersects the frustum
  95091. * @param frustumPlanes defines the frustum to test
  95092. * @returns true if the mesh is in the frustum planes
  95093. */
  95094. isInFrustum(frustumPlanes: Plane[]): boolean;
  95095. /**
  95096. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  95097. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  95098. * @param frustumPlanes defines the frustum to test
  95099. * @returns true if the mesh is completely in the frustum planes
  95100. */
  95101. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  95102. /**
  95103. * True if the mesh intersects another mesh or a SolidParticle object
  95104. * @param mesh defines a target mesh or SolidParticle to test
  95105. * @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)
  95106. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  95107. * @returns true if there is an intersection
  95108. */
  95109. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  95110. /**
  95111. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  95112. * @param point defines the point to test
  95113. * @returns true if there is an intersection
  95114. */
  95115. intersectsPoint(point: Vector3): boolean;
  95116. /**
  95117. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  95118. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95119. */
  95120. checkCollisions: boolean;
  95121. /**
  95122. * Gets Collider object used to compute collisions (not physics)
  95123. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95124. */
  95125. readonly collider: Nullable<Collider>;
  95126. /**
  95127. * Move the mesh using collision engine
  95128. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95129. * @param displacement defines the requested displacement vector
  95130. * @returns the current mesh
  95131. */
  95132. moveWithCollisions(displacement: Vector3): AbstractMesh;
  95133. private _onCollisionPositionChange;
  95134. /** @hidden */
  95135. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  95136. /** @hidden */
  95137. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  95138. /** @hidden */
  95139. _checkCollision(collider: Collider): AbstractMesh;
  95140. /** @hidden */
  95141. _generatePointsArray(): boolean;
  95142. /**
  95143. * Checks if the passed Ray intersects with the mesh
  95144. * @param ray defines the ray to use
  95145. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  95146. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95147. * @returns the picking info
  95148. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  95149. */
  95150. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  95151. /**
  95152. * Clones the current mesh
  95153. * @param name defines the mesh name
  95154. * @param newParent defines the new mesh parent
  95155. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  95156. * @returns the new mesh
  95157. */
  95158. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  95159. /**
  95160. * Disposes all the submeshes of the current meshnp
  95161. * @returns the current mesh
  95162. */
  95163. releaseSubMeshes(): AbstractMesh;
  95164. /**
  95165. * Releases resources associated with this abstract mesh.
  95166. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95167. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95168. */
  95169. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95170. /**
  95171. * Adds the passed mesh as a child to the current mesh
  95172. * @param mesh defines the child mesh
  95173. * @returns the current mesh
  95174. */
  95175. addChild(mesh: AbstractMesh): AbstractMesh;
  95176. /**
  95177. * Removes the passed mesh from the current mesh children list
  95178. * @param mesh defines the child mesh
  95179. * @returns the current mesh
  95180. */
  95181. removeChild(mesh: AbstractMesh): AbstractMesh;
  95182. /** @hidden */
  95183. private _initFacetData;
  95184. /**
  95185. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  95186. * This method can be called within the render loop.
  95187. * 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
  95188. * @returns the current mesh
  95189. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95190. */
  95191. updateFacetData(): AbstractMesh;
  95192. /**
  95193. * Returns the facetLocalNormals array.
  95194. * The normals are expressed in the mesh local spac
  95195. * @returns an array of Vector3
  95196. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95197. */
  95198. getFacetLocalNormals(): Vector3[];
  95199. /**
  95200. * Returns the facetLocalPositions array.
  95201. * The facet positions are expressed in the mesh local space
  95202. * @returns an array of Vector3
  95203. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95204. */
  95205. getFacetLocalPositions(): Vector3[];
  95206. /**
  95207. * Returns the facetLocalPartioning array
  95208. * @returns an array of array of numbers
  95209. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95210. */
  95211. getFacetLocalPartitioning(): number[][];
  95212. /**
  95213. * Returns the i-th facet position in the world system.
  95214. * This method allocates a new Vector3 per call
  95215. * @param i defines the facet index
  95216. * @returns a new Vector3
  95217. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95218. */
  95219. getFacetPosition(i: number): Vector3;
  95220. /**
  95221. * Sets the reference Vector3 with the i-th facet position in the world system
  95222. * @param i defines the facet index
  95223. * @param ref defines the target vector
  95224. * @returns the current mesh
  95225. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95226. */
  95227. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  95228. /**
  95229. * Returns the i-th facet normal in the world system.
  95230. * This method allocates a new Vector3 per call
  95231. * @param i defines the facet index
  95232. * @returns a new Vector3
  95233. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95234. */
  95235. getFacetNormal(i: number): Vector3;
  95236. /**
  95237. * Sets the reference Vector3 with the i-th facet normal in the world system
  95238. * @param i defines the facet index
  95239. * @param ref defines the target vector
  95240. * @returns the current mesh
  95241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95242. */
  95243. getFacetNormalToRef(i: number, ref: Vector3): this;
  95244. /**
  95245. * 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)
  95246. * @param x defines x coordinate
  95247. * @param y defines y coordinate
  95248. * @param z defines z coordinate
  95249. * @returns the array of facet indexes
  95250. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95251. */
  95252. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  95253. /**
  95254. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  95255. * @param projected sets as the (x,y,z) world projection on the facet
  95256. * @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
  95257. * @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
  95258. * @param x defines x coordinate
  95259. * @param y defines y coordinate
  95260. * @param z defines z coordinate
  95261. * @returns the face index if found (or null instead)
  95262. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95263. */
  95264. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  95265. /**
  95266. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  95267. * @param projected sets as the (x,y,z) local projection on the facet
  95268. * @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
  95269. * @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
  95270. * @param x defines x coordinate
  95271. * @param y defines y coordinate
  95272. * @param z defines z coordinate
  95273. * @returns the face index if found (or null instead)
  95274. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95275. */
  95276. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  95277. /**
  95278. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  95279. * @returns the parameters
  95280. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95281. */
  95282. getFacetDataParameters(): any;
  95283. /**
  95284. * Disables the feature FacetData and frees the related memory
  95285. * @returns the current mesh
  95286. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95287. */
  95288. disableFacetData(): AbstractMesh;
  95289. /**
  95290. * Updates the AbstractMesh indices array
  95291. * @param indices defines the data source
  95292. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  95293. * @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)
  95294. * @returns the current mesh
  95295. */
  95296. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  95297. /**
  95298. * Creates new normals data for the mesh
  95299. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  95300. * @returns the current mesh
  95301. */
  95302. createNormals(updatable: boolean): AbstractMesh;
  95303. /**
  95304. * Align the mesh with a normal
  95305. * @param normal defines the normal to use
  95306. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  95307. * @returns the current mesh
  95308. */
  95309. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  95310. /** @hidden */
  95311. _checkOcclusionQuery(): boolean;
  95312. /**
  95313. * Disables the mesh edge rendering mode
  95314. * @returns the currentAbstractMesh
  95315. */
  95316. disableEdgesRendering(): AbstractMesh;
  95317. /**
  95318. * Enables the edge rendering mode on the mesh.
  95319. * This mode makes the mesh edges visible
  95320. * @param epsilon defines the maximal distance between two angles to detect a face
  95321. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95322. * @returns the currentAbstractMesh
  95323. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95324. */
  95325. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  95326. }
  95327. }
  95328. declare module BABYLON {
  95329. /**
  95330. * Interface used to define ActionEvent
  95331. */
  95332. export interface IActionEvent {
  95333. /** The mesh or sprite that triggered the action */
  95334. source: any;
  95335. /** The X mouse cursor position at the time of the event */
  95336. pointerX: number;
  95337. /** The Y mouse cursor position at the time of the event */
  95338. pointerY: number;
  95339. /** The mesh that is currently pointed at (can be null) */
  95340. meshUnderPointer: Nullable<AbstractMesh>;
  95341. /** the original (browser) event that triggered the ActionEvent */
  95342. sourceEvent?: any;
  95343. /** additional data for the event */
  95344. additionalData?: any;
  95345. }
  95346. /**
  95347. * ActionEvent is the event being sent when an action is triggered.
  95348. */
  95349. export class ActionEvent implements IActionEvent {
  95350. /** The mesh or sprite that triggered the action */
  95351. source: any;
  95352. /** The X mouse cursor position at the time of the event */
  95353. pointerX: number;
  95354. /** The Y mouse cursor position at the time of the event */
  95355. pointerY: number;
  95356. /** The mesh that is currently pointed at (can be null) */
  95357. meshUnderPointer: Nullable<AbstractMesh>;
  95358. /** the original (browser) event that triggered the ActionEvent */
  95359. sourceEvent?: any;
  95360. /** additional data for the event */
  95361. additionalData?: any;
  95362. /**
  95363. * Creates a new ActionEvent
  95364. * @param source The mesh or sprite that triggered the action
  95365. * @param pointerX The X mouse cursor position at the time of the event
  95366. * @param pointerY The Y mouse cursor position at the time of the event
  95367. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  95368. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  95369. * @param additionalData additional data for the event
  95370. */
  95371. constructor(
  95372. /** The mesh or sprite that triggered the action */
  95373. source: any,
  95374. /** The X mouse cursor position at the time of the event */
  95375. pointerX: number,
  95376. /** The Y mouse cursor position at the time of the event */
  95377. pointerY: number,
  95378. /** The mesh that is currently pointed at (can be null) */
  95379. meshUnderPointer: Nullable<AbstractMesh>,
  95380. /** the original (browser) event that triggered the ActionEvent */
  95381. sourceEvent?: any,
  95382. /** additional data for the event */
  95383. additionalData?: any);
  95384. /**
  95385. * Helper function to auto-create an ActionEvent from a source mesh.
  95386. * @param source The source mesh that triggered the event
  95387. * @param evt The original (browser) event
  95388. * @param additionalData additional data for the event
  95389. * @returns the new ActionEvent
  95390. */
  95391. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  95392. /**
  95393. * Helper function to auto-create an ActionEvent from a source sprite
  95394. * @param source The source sprite that triggered the event
  95395. * @param scene Scene associated with the sprite
  95396. * @param evt The original (browser) event
  95397. * @param additionalData additional data for the event
  95398. * @returns the new ActionEvent
  95399. */
  95400. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  95401. /**
  95402. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  95403. * @param scene the scene where the event occurred
  95404. * @param evt The original (browser) event
  95405. * @returns the new ActionEvent
  95406. */
  95407. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  95408. /**
  95409. * Helper function to auto-create an ActionEvent from a primitive
  95410. * @param prim defines the target primitive
  95411. * @param pointerPos defines the pointer position
  95412. * @param evt The original (browser) event
  95413. * @param additionalData additional data for the event
  95414. * @returns the new ActionEvent
  95415. */
  95416. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  95417. }
  95418. }
  95419. declare module BABYLON {
  95420. /**
  95421. * Abstract class used to decouple action Manager from scene and meshes.
  95422. * Do not instantiate.
  95423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95424. */
  95425. export abstract class AbstractActionManager implements IDisposable {
  95426. /** Gets the list of active triggers */
  95427. static Triggers: {
  95428. [key: string]: number;
  95429. };
  95430. /** Gets the cursor to use when hovering items */
  95431. hoverCursor: string;
  95432. /** Gets the list of actions */
  95433. actions: IAction[];
  95434. /**
  95435. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  95436. */
  95437. isRecursive: boolean;
  95438. /**
  95439. * Releases all associated resources
  95440. */
  95441. abstract dispose(): void;
  95442. /**
  95443. * Does this action manager has pointer triggers
  95444. */
  95445. abstract readonly hasPointerTriggers: boolean;
  95446. /**
  95447. * Does this action manager has pick triggers
  95448. */
  95449. abstract readonly hasPickTriggers: boolean;
  95450. /**
  95451. * Process a specific trigger
  95452. * @param trigger defines the trigger to process
  95453. * @param evt defines the event details to be processed
  95454. */
  95455. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  95456. /**
  95457. * Does this action manager handles actions of any of the given triggers
  95458. * @param triggers defines the triggers to be tested
  95459. * @return a boolean indicating whether one (or more) of the triggers is handled
  95460. */
  95461. abstract hasSpecificTriggers(triggers: number[]): boolean;
  95462. /**
  95463. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  95464. * speed.
  95465. * @param triggerA defines the trigger to be tested
  95466. * @param triggerB defines the trigger to be tested
  95467. * @return a boolean indicating whether one (or more) of the triggers is handled
  95468. */
  95469. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  95470. /**
  95471. * Does this action manager handles actions of a given trigger
  95472. * @param trigger defines the trigger to be tested
  95473. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  95474. * @return whether the trigger is handled
  95475. */
  95476. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  95477. /**
  95478. * Serialize this manager to a JSON object
  95479. * @param name defines the property name to store this manager
  95480. * @returns a JSON representation of this manager
  95481. */
  95482. abstract serialize(name: string): any;
  95483. /**
  95484. * Registers an action to this action manager
  95485. * @param action defines the action to be registered
  95486. * @return the action amended (prepared) after registration
  95487. */
  95488. abstract registerAction(action: IAction): Nullable<IAction>;
  95489. /**
  95490. * Unregisters an action to this action manager
  95491. * @param action defines the action to be unregistered
  95492. * @return a boolean indicating whether the action has been unregistered
  95493. */
  95494. abstract unregisterAction(action: IAction): Boolean;
  95495. /**
  95496. * Does exist one action manager with at least one trigger
  95497. **/
  95498. static readonly HasTriggers: boolean;
  95499. /**
  95500. * Does exist one action manager with at least one pick trigger
  95501. **/
  95502. static readonly HasPickTriggers: boolean;
  95503. /**
  95504. * Does exist one action manager that handles actions of a given trigger
  95505. * @param trigger defines the trigger to be tested
  95506. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  95507. **/
  95508. static HasSpecificTrigger(trigger: number): boolean;
  95509. }
  95510. }
  95511. declare module BABYLON {
  95512. /**
  95513. * Defines how a node can be built from a string name.
  95514. */
  95515. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  95516. /**
  95517. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  95518. */
  95519. export class Node implements IBehaviorAware<Node> {
  95520. /** @hidden */
  95521. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  95522. private static _NodeConstructors;
  95523. /**
  95524. * Add a new node constructor
  95525. * @param type defines the type name of the node to construct
  95526. * @param constructorFunc defines the constructor function
  95527. */
  95528. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  95529. /**
  95530. * Returns a node constructor based on type name
  95531. * @param type defines the type name
  95532. * @param name defines the new node name
  95533. * @param scene defines the hosting scene
  95534. * @param options defines optional options to transmit to constructors
  95535. * @returns the new constructor or null
  95536. */
  95537. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  95538. /**
  95539. * Gets or sets the name of the node
  95540. */
  95541. name: string;
  95542. /**
  95543. * Gets or sets the id of the node
  95544. */
  95545. id: string;
  95546. /**
  95547. * Gets or sets the unique id of the node
  95548. */
  95549. uniqueId: number;
  95550. /**
  95551. * Gets or sets a string used to store user defined state for the node
  95552. */
  95553. state: string;
  95554. /**
  95555. * Gets or sets an object used to store user defined information for the node
  95556. */
  95557. metadata: any;
  95558. /**
  95559. * For internal use only. Please do not use.
  95560. */
  95561. reservedDataStore: any;
  95562. /**
  95563. * List of inspectable custom properties (used by the Inspector)
  95564. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95565. */
  95566. inspectableCustomProperties: IInspectable[];
  95567. private _doNotSerialize;
  95568. /**
  95569. * Gets or sets a boolean used to define if the node must be serialized
  95570. */
  95571. doNotSerialize: boolean;
  95572. /** @hidden */
  95573. _isDisposed: boolean;
  95574. /**
  95575. * Gets a list of Animations associated with the node
  95576. */
  95577. animations: Animation[];
  95578. protected _ranges: {
  95579. [name: string]: Nullable<AnimationRange>;
  95580. };
  95581. /**
  95582. * Callback raised when the node is ready to be used
  95583. */
  95584. onReady: Nullable<(node: Node) => void>;
  95585. private _isEnabled;
  95586. private _isParentEnabled;
  95587. private _isReady;
  95588. /** @hidden */
  95589. _currentRenderId: number;
  95590. private _parentUpdateId;
  95591. /** @hidden */
  95592. _childUpdateId: number;
  95593. /** @hidden */
  95594. _waitingParentId: Nullable<string>;
  95595. /** @hidden */
  95596. _scene: Scene;
  95597. /** @hidden */
  95598. _cache: any;
  95599. private _parentNode;
  95600. private _children;
  95601. /** @hidden */
  95602. _worldMatrix: Matrix;
  95603. /** @hidden */
  95604. _worldMatrixDeterminant: number;
  95605. /** @hidden */
  95606. _worldMatrixDeterminantIsDirty: boolean;
  95607. /** @hidden */
  95608. private _sceneRootNodesIndex;
  95609. /**
  95610. * Gets a boolean indicating if the node has been disposed
  95611. * @returns true if the node was disposed
  95612. */
  95613. isDisposed(): boolean;
  95614. /**
  95615. * Gets or sets the parent of the node (without keeping the current position in the scene)
  95616. * @see https://doc.babylonjs.com/how_to/parenting
  95617. */
  95618. parent: Nullable<Node>;
  95619. /** @hidden */
  95620. _addToSceneRootNodes(): void;
  95621. /** @hidden */
  95622. _removeFromSceneRootNodes(): void;
  95623. private _animationPropertiesOverride;
  95624. /**
  95625. * Gets or sets the animation properties override
  95626. */
  95627. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  95628. /**
  95629. * Gets a string idenfifying the name of the class
  95630. * @returns "Node" string
  95631. */
  95632. getClassName(): string;
  95633. /** @hidden */
  95634. readonly _isNode: boolean;
  95635. /**
  95636. * An event triggered when the mesh is disposed
  95637. */
  95638. onDisposeObservable: Observable<Node>;
  95639. private _onDisposeObserver;
  95640. /**
  95641. * Sets a callback that will be raised when the node will be disposed
  95642. */
  95643. onDispose: () => void;
  95644. /**
  95645. * Creates a new Node
  95646. * @param name the name and id to be given to this node
  95647. * @param scene the scene this node will be added to
  95648. */
  95649. constructor(name: string, scene?: Nullable<Scene>);
  95650. /**
  95651. * Gets the scene of the node
  95652. * @returns a scene
  95653. */
  95654. getScene(): Scene;
  95655. /**
  95656. * Gets the engine of the node
  95657. * @returns a Engine
  95658. */
  95659. getEngine(): Engine;
  95660. private _behaviors;
  95661. /**
  95662. * Attach a behavior to the node
  95663. * @see http://doc.babylonjs.com/features/behaviour
  95664. * @param behavior defines the behavior to attach
  95665. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  95666. * @returns the current Node
  95667. */
  95668. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  95669. /**
  95670. * Remove an attached behavior
  95671. * @see http://doc.babylonjs.com/features/behaviour
  95672. * @param behavior defines the behavior to attach
  95673. * @returns the current Node
  95674. */
  95675. removeBehavior(behavior: Behavior<Node>): Node;
  95676. /**
  95677. * Gets the list of attached behaviors
  95678. * @see http://doc.babylonjs.com/features/behaviour
  95679. */
  95680. readonly behaviors: Behavior<Node>[];
  95681. /**
  95682. * Gets an attached behavior by name
  95683. * @param name defines the name of the behavior to look for
  95684. * @see http://doc.babylonjs.com/features/behaviour
  95685. * @returns null if behavior was not found else the requested behavior
  95686. */
  95687. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  95688. /**
  95689. * Returns the latest update of the World matrix
  95690. * @returns a Matrix
  95691. */
  95692. getWorldMatrix(): Matrix;
  95693. /** @hidden */
  95694. _getWorldMatrixDeterminant(): number;
  95695. /**
  95696. * Returns directly the latest state of the mesh World matrix.
  95697. * A Matrix is returned.
  95698. */
  95699. readonly worldMatrixFromCache: Matrix;
  95700. /** @hidden */
  95701. _initCache(): void;
  95702. /** @hidden */
  95703. updateCache(force?: boolean): void;
  95704. /** @hidden */
  95705. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  95706. /** @hidden */
  95707. _updateCache(ignoreParentClass?: boolean): void;
  95708. /** @hidden */
  95709. _isSynchronized(): boolean;
  95710. /** @hidden */
  95711. _markSyncedWithParent(): void;
  95712. /** @hidden */
  95713. isSynchronizedWithParent(): boolean;
  95714. /** @hidden */
  95715. isSynchronized(): boolean;
  95716. /**
  95717. * Is this node ready to be used/rendered
  95718. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95719. * @return true if the node is ready
  95720. */
  95721. isReady(completeCheck?: boolean): boolean;
  95722. /**
  95723. * Is this node enabled?
  95724. * 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
  95725. * @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
  95726. * @return whether this node (and its parent) is enabled
  95727. */
  95728. isEnabled(checkAncestors?: boolean): boolean;
  95729. /** @hidden */
  95730. protected _syncParentEnabledState(): void;
  95731. /**
  95732. * Set the enabled state of this node
  95733. * @param value defines the new enabled state
  95734. */
  95735. setEnabled(value: boolean): void;
  95736. /**
  95737. * Is this node a descendant of the given node?
  95738. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  95739. * @param ancestor defines the parent node to inspect
  95740. * @returns a boolean indicating if this node is a descendant of the given node
  95741. */
  95742. isDescendantOf(ancestor: Node): boolean;
  95743. /** @hidden */
  95744. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  95745. /**
  95746. * Will return all nodes that have this node as ascendant
  95747. * @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
  95748. * @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
  95749. * @return all children nodes of all types
  95750. */
  95751. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  95752. /**
  95753. * Get all child-meshes of this node
  95754. * @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)
  95755. * @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
  95756. * @returns an array of AbstractMesh
  95757. */
  95758. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  95759. /**
  95760. * Get all direct children of this node
  95761. * @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
  95762. * @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)
  95763. * @returns an array of Node
  95764. */
  95765. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  95766. /** @hidden */
  95767. _setReady(state: boolean): void;
  95768. /**
  95769. * Get an animation by name
  95770. * @param name defines the name of the animation to look for
  95771. * @returns null if not found else the requested animation
  95772. */
  95773. getAnimationByName(name: string): Nullable<Animation>;
  95774. /**
  95775. * Creates an animation range for this node
  95776. * @param name defines the name of the range
  95777. * @param from defines the starting key
  95778. * @param to defines the end key
  95779. */
  95780. createAnimationRange(name: string, from: number, to: number): void;
  95781. /**
  95782. * Delete a specific animation range
  95783. * @param name defines the name of the range to delete
  95784. * @param deleteFrames defines if animation frames from the range must be deleted as well
  95785. */
  95786. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  95787. /**
  95788. * Get an animation range by name
  95789. * @param name defines the name of the animation range to look for
  95790. * @returns null if not found else the requested animation range
  95791. */
  95792. getAnimationRange(name: string): Nullable<AnimationRange>;
  95793. /**
  95794. * Gets the list of all animation ranges defined on this node
  95795. * @returns an array
  95796. */
  95797. getAnimationRanges(): Nullable<AnimationRange>[];
  95798. /**
  95799. * Will start the animation sequence
  95800. * @param name defines the range frames for animation sequence
  95801. * @param loop defines if the animation should loop (false by default)
  95802. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  95803. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  95804. * @returns the object created for this animation. If range does not exist, it will return null
  95805. */
  95806. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  95807. /**
  95808. * Serialize animation ranges into a JSON compatible object
  95809. * @returns serialization object
  95810. */
  95811. serializeAnimationRanges(): any;
  95812. /**
  95813. * Computes the world matrix of the node
  95814. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95815. * @returns the world matrix
  95816. */
  95817. computeWorldMatrix(force?: boolean): Matrix;
  95818. /**
  95819. * Releases resources associated with this node.
  95820. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95821. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95822. */
  95823. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95824. /**
  95825. * Parse animation range data from a serialization object and store them into a given node
  95826. * @param node defines where to store the animation ranges
  95827. * @param parsedNode defines the serialization object to read data from
  95828. * @param scene defines the hosting scene
  95829. */
  95830. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  95831. /**
  95832. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  95833. * @param includeDescendants Include bounding info from descendants as well (true by default)
  95834. * @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
  95835. * @returns the new bounding vectors
  95836. */
  95837. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  95838. min: Vector3;
  95839. max: Vector3;
  95840. };
  95841. }
  95842. }
  95843. declare module BABYLON {
  95844. /**
  95845. * @hidden
  95846. */
  95847. export class _IAnimationState {
  95848. key: number;
  95849. repeatCount: number;
  95850. workValue?: any;
  95851. loopMode?: number;
  95852. offsetValue?: any;
  95853. highLimitValue?: any;
  95854. }
  95855. /**
  95856. * Class used to store any kind of animation
  95857. */
  95858. export class Animation {
  95859. /**Name of the animation */
  95860. name: string;
  95861. /**Property to animate */
  95862. targetProperty: string;
  95863. /**The frames per second of the animation */
  95864. framePerSecond: number;
  95865. /**The data type of the animation */
  95866. dataType: number;
  95867. /**The loop mode of the animation */
  95868. loopMode?: number | undefined;
  95869. /**Specifies if blending should be enabled */
  95870. enableBlending?: boolean | undefined;
  95871. /**
  95872. * Use matrix interpolation instead of using direct key value when animating matrices
  95873. */
  95874. static AllowMatricesInterpolation: boolean;
  95875. /**
  95876. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  95877. */
  95878. static AllowMatrixDecomposeForInterpolation: boolean;
  95879. /**
  95880. * Stores the key frames of the animation
  95881. */
  95882. private _keys;
  95883. /**
  95884. * Stores the easing function of the animation
  95885. */
  95886. private _easingFunction;
  95887. /**
  95888. * @hidden Internal use only
  95889. */
  95890. _runtimeAnimations: RuntimeAnimation[];
  95891. /**
  95892. * The set of event that will be linked to this animation
  95893. */
  95894. private _events;
  95895. /**
  95896. * Stores an array of target property paths
  95897. */
  95898. targetPropertyPath: string[];
  95899. /**
  95900. * Stores the blending speed of the animation
  95901. */
  95902. blendingSpeed: number;
  95903. /**
  95904. * Stores the animation ranges for the animation
  95905. */
  95906. private _ranges;
  95907. /**
  95908. * @hidden Internal use
  95909. */
  95910. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  95911. /**
  95912. * Sets up an animation
  95913. * @param property The property to animate
  95914. * @param animationType The animation type to apply
  95915. * @param framePerSecond The frames per second of the animation
  95916. * @param easingFunction The easing function used in the animation
  95917. * @returns The created animation
  95918. */
  95919. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  95920. /**
  95921. * Create and start an animation on a node
  95922. * @param name defines the name of the global animation that will be run on all nodes
  95923. * @param node defines the root node where the animation will take place
  95924. * @param targetProperty defines property to animate
  95925. * @param framePerSecond defines the number of frame per second yo use
  95926. * @param totalFrame defines the number of frames in total
  95927. * @param from defines the initial value
  95928. * @param to defines the final value
  95929. * @param loopMode defines which loop mode you want to use (off by default)
  95930. * @param easingFunction defines the easing function to use (linear by default)
  95931. * @param onAnimationEnd defines the callback to call when animation end
  95932. * @returns the animatable created for this animation
  95933. */
  95934. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95935. /**
  95936. * Create and start an animation on a node and its descendants
  95937. * @param name defines the name of the global animation that will be run on all nodes
  95938. * @param node defines the root node where the animation will take place
  95939. * @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
  95940. * @param targetProperty defines property to animate
  95941. * @param framePerSecond defines the number of frame per second to use
  95942. * @param totalFrame defines the number of frames in total
  95943. * @param from defines the initial value
  95944. * @param to defines the final value
  95945. * @param loopMode defines which loop mode you want to use (off by default)
  95946. * @param easingFunction defines the easing function to use (linear by default)
  95947. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95948. * @returns the list of animatables created for all nodes
  95949. * @example https://www.babylonjs-playground.com/#MH0VLI
  95950. */
  95951. 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[]>;
  95952. /**
  95953. * Creates a new animation, merges it with the existing animations and starts it
  95954. * @param name Name of the animation
  95955. * @param node Node which contains the scene that begins the animations
  95956. * @param targetProperty Specifies which property to animate
  95957. * @param framePerSecond The frames per second of the animation
  95958. * @param totalFrame The total number of frames
  95959. * @param from The frame at the beginning of the animation
  95960. * @param to The frame at the end of the animation
  95961. * @param loopMode Specifies the loop mode of the animation
  95962. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  95963. * @param onAnimationEnd Callback to run once the animation is complete
  95964. * @returns Nullable animation
  95965. */
  95966. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95967. /**
  95968. * Transition property of an host to the target Value
  95969. * @param property The property to transition
  95970. * @param targetValue The target Value of the property
  95971. * @param host The object where the property to animate belongs
  95972. * @param scene Scene used to run the animation
  95973. * @param frameRate Framerate (in frame/s) to use
  95974. * @param transition The transition type we want to use
  95975. * @param duration The duration of the animation, in milliseconds
  95976. * @param onAnimationEnd Callback trigger at the end of the animation
  95977. * @returns Nullable animation
  95978. */
  95979. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  95980. /**
  95981. * Return the array of runtime animations currently using this animation
  95982. */
  95983. readonly runtimeAnimations: RuntimeAnimation[];
  95984. /**
  95985. * Specifies if any of the runtime animations are currently running
  95986. */
  95987. readonly hasRunningRuntimeAnimations: boolean;
  95988. /**
  95989. * Initializes the animation
  95990. * @param name Name of the animation
  95991. * @param targetProperty Property to animate
  95992. * @param framePerSecond The frames per second of the animation
  95993. * @param dataType The data type of the animation
  95994. * @param loopMode The loop mode of the animation
  95995. * @param enableBlending Specifies if blending should be enabled
  95996. */
  95997. constructor(
  95998. /**Name of the animation */
  95999. name: string,
  96000. /**Property to animate */
  96001. targetProperty: string,
  96002. /**The frames per second of the animation */
  96003. framePerSecond: number,
  96004. /**The data type of the animation */
  96005. dataType: number,
  96006. /**The loop mode of the animation */
  96007. loopMode?: number | undefined,
  96008. /**Specifies if blending should be enabled */
  96009. enableBlending?: boolean | undefined);
  96010. /**
  96011. * Converts the animation to a string
  96012. * @param fullDetails support for multiple levels of logging within scene loading
  96013. * @returns String form of the animation
  96014. */
  96015. toString(fullDetails?: boolean): string;
  96016. /**
  96017. * Add an event to this animation
  96018. * @param event Event to add
  96019. */
  96020. addEvent(event: AnimationEvent): void;
  96021. /**
  96022. * Remove all events found at the given frame
  96023. * @param frame The frame to remove events from
  96024. */
  96025. removeEvents(frame: number): void;
  96026. /**
  96027. * Retrieves all the events from the animation
  96028. * @returns Events from the animation
  96029. */
  96030. getEvents(): AnimationEvent[];
  96031. /**
  96032. * Creates an animation range
  96033. * @param name Name of the animation range
  96034. * @param from Starting frame of the animation range
  96035. * @param to Ending frame of the animation
  96036. */
  96037. createRange(name: string, from: number, to: number): void;
  96038. /**
  96039. * Deletes an animation range by name
  96040. * @param name Name of the animation range to delete
  96041. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  96042. */
  96043. deleteRange(name: string, deleteFrames?: boolean): void;
  96044. /**
  96045. * Gets the animation range by name, or null if not defined
  96046. * @param name Name of the animation range
  96047. * @returns Nullable animation range
  96048. */
  96049. getRange(name: string): Nullable<AnimationRange>;
  96050. /**
  96051. * Gets the key frames from the animation
  96052. * @returns The key frames of the animation
  96053. */
  96054. getKeys(): Array<IAnimationKey>;
  96055. /**
  96056. * Gets the highest frame rate of the animation
  96057. * @returns Highest frame rate of the animation
  96058. */
  96059. getHighestFrame(): number;
  96060. /**
  96061. * Gets the easing function of the animation
  96062. * @returns Easing function of the animation
  96063. */
  96064. getEasingFunction(): IEasingFunction;
  96065. /**
  96066. * Sets the easing function of the animation
  96067. * @param easingFunction A custom mathematical formula for animation
  96068. */
  96069. setEasingFunction(easingFunction: EasingFunction): void;
  96070. /**
  96071. * Interpolates a scalar linearly
  96072. * @param startValue Start value of the animation curve
  96073. * @param endValue End value of the animation curve
  96074. * @param gradient Scalar amount to interpolate
  96075. * @returns Interpolated scalar value
  96076. */
  96077. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  96078. /**
  96079. * Interpolates a scalar cubically
  96080. * @param startValue Start value of the animation curve
  96081. * @param outTangent End tangent of the animation
  96082. * @param endValue End value of the animation curve
  96083. * @param inTangent Start tangent of the animation curve
  96084. * @param gradient Scalar amount to interpolate
  96085. * @returns Interpolated scalar value
  96086. */
  96087. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  96088. /**
  96089. * Interpolates a quaternion using a spherical linear interpolation
  96090. * @param startValue Start value of the animation curve
  96091. * @param endValue End value of the animation curve
  96092. * @param gradient Scalar amount to interpolate
  96093. * @returns Interpolated quaternion value
  96094. */
  96095. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  96096. /**
  96097. * Interpolates a quaternion cubically
  96098. * @param startValue Start value of the animation curve
  96099. * @param outTangent End tangent of the animation curve
  96100. * @param endValue End value of the animation curve
  96101. * @param inTangent Start tangent of the animation curve
  96102. * @param gradient Scalar amount to interpolate
  96103. * @returns Interpolated quaternion value
  96104. */
  96105. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  96106. /**
  96107. * Interpolates a Vector3 linearl
  96108. * @param startValue Start value of the animation curve
  96109. * @param endValue End value of the animation curve
  96110. * @param gradient Scalar amount to interpolate
  96111. * @returns Interpolated scalar value
  96112. */
  96113. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  96114. /**
  96115. * Interpolates a Vector3 cubically
  96116. * @param startValue Start value of the animation curve
  96117. * @param outTangent End tangent of the animation
  96118. * @param endValue End value of the animation curve
  96119. * @param inTangent Start tangent of the animation curve
  96120. * @param gradient Scalar amount to interpolate
  96121. * @returns InterpolatedVector3 value
  96122. */
  96123. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  96124. /**
  96125. * Interpolates a Vector2 linearly
  96126. * @param startValue Start value of the animation curve
  96127. * @param endValue End value of the animation curve
  96128. * @param gradient Scalar amount to interpolate
  96129. * @returns Interpolated Vector2 value
  96130. */
  96131. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  96132. /**
  96133. * Interpolates a Vector2 cubically
  96134. * @param startValue Start value of the animation curve
  96135. * @param outTangent End tangent of the animation
  96136. * @param endValue End value of the animation curve
  96137. * @param inTangent Start tangent of the animation curve
  96138. * @param gradient Scalar amount to interpolate
  96139. * @returns Interpolated Vector2 value
  96140. */
  96141. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  96142. /**
  96143. * Interpolates a size linearly
  96144. * @param startValue Start value of the animation curve
  96145. * @param endValue End value of the animation curve
  96146. * @param gradient Scalar amount to interpolate
  96147. * @returns Interpolated Size value
  96148. */
  96149. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  96150. /**
  96151. * Interpolates a Color3 linearly
  96152. * @param startValue Start value of the animation curve
  96153. * @param endValue End value of the animation curve
  96154. * @param gradient Scalar amount to interpolate
  96155. * @returns Interpolated Color3 value
  96156. */
  96157. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  96158. /**
  96159. * Interpolates a Color4 linearly
  96160. * @param startValue Start value of the animation curve
  96161. * @param endValue End value of the animation curve
  96162. * @param gradient Scalar amount to interpolate
  96163. * @returns Interpolated Color3 value
  96164. */
  96165. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  96166. /**
  96167. * @hidden Internal use only
  96168. */
  96169. _getKeyValue(value: any): any;
  96170. /**
  96171. * @hidden Internal use only
  96172. */
  96173. _interpolate(currentFrame: number, state: _IAnimationState): any;
  96174. /**
  96175. * Defines the function to use to interpolate matrices
  96176. * @param startValue defines the start matrix
  96177. * @param endValue defines the end matrix
  96178. * @param gradient defines the gradient between both matrices
  96179. * @param result defines an optional target matrix where to store the interpolation
  96180. * @returns the interpolated matrix
  96181. */
  96182. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  96183. /**
  96184. * Makes a copy of the animation
  96185. * @returns Cloned animation
  96186. */
  96187. clone(): Animation;
  96188. /**
  96189. * Sets the key frames of the animation
  96190. * @param values The animation key frames to set
  96191. */
  96192. setKeys(values: Array<IAnimationKey>): void;
  96193. /**
  96194. * Serializes the animation to an object
  96195. * @returns Serialized object
  96196. */
  96197. serialize(): any;
  96198. /**
  96199. * Float animation type
  96200. */
  96201. static readonly ANIMATIONTYPE_FLOAT: number;
  96202. /**
  96203. * Vector3 animation type
  96204. */
  96205. static readonly ANIMATIONTYPE_VECTOR3: number;
  96206. /**
  96207. * Quaternion animation type
  96208. */
  96209. static readonly ANIMATIONTYPE_QUATERNION: number;
  96210. /**
  96211. * Matrix animation type
  96212. */
  96213. static readonly ANIMATIONTYPE_MATRIX: number;
  96214. /**
  96215. * Color3 animation type
  96216. */
  96217. static readonly ANIMATIONTYPE_COLOR3: number;
  96218. /**
  96219. * Color3 animation type
  96220. */
  96221. static readonly ANIMATIONTYPE_COLOR4: number;
  96222. /**
  96223. * Vector2 animation type
  96224. */
  96225. static readonly ANIMATIONTYPE_VECTOR2: number;
  96226. /**
  96227. * Size animation type
  96228. */
  96229. static readonly ANIMATIONTYPE_SIZE: number;
  96230. /**
  96231. * Relative Loop Mode
  96232. */
  96233. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  96234. /**
  96235. * Cycle Loop Mode
  96236. */
  96237. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  96238. /**
  96239. * Constant Loop Mode
  96240. */
  96241. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  96242. /** @hidden */
  96243. static _UniversalLerp(left: any, right: any, amount: number): any;
  96244. /**
  96245. * Parses an animation object and creates an animation
  96246. * @param parsedAnimation Parsed animation object
  96247. * @returns Animation object
  96248. */
  96249. static Parse(parsedAnimation: any): Animation;
  96250. /**
  96251. * Appends the serialized animations from the source animations
  96252. * @param source Source containing the animations
  96253. * @param destination Target to store the animations
  96254. */
  96255. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  96256. }
  96257. }
  96258. declare module BABYLON {
  96259. /**
  96260. * Interface containing an array of animations
  96261. */
  96262. export interface IAnimatable {
  96263. /**
  96264. * Array of animations
  96265. */
  96266. animations: Nullable<Array<Animation>>;
  96267. }
  96268. }
  96269. declare module BABYLON {
  96270. /**
  96271. * This represents all the required information to add a fresnel effect on a material:
  96272. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96273. */
  96274. export class FresnelParameters {
  96275. private _isEnabled;
  96276. /**
  96277. * Define if the fresnel effect is enable or not.
  96278. */
  96279. isEnabled: boolean;
  96280. /**
  96281. * Define the color used on edges (grazing angle)
  96282. */
  96283. leftColor: Color3;
  96284. /**
  96285. * Define the color used on center
  96286. */
  96287. rightColor: Color3;
  96288. /**
  96289. * Define bias applied to computed fresnel term
  96290. */
  96291. bias: number;
  96292. /**
  96293. * Defined the power exponent applied to fresnel term
  96294. */
  96295. power: number;
  96296. /**
  96297. * Clones the current fresnel and its valuues
  96298. * @returns a clone fresnel configuration
  96299. */
  96300. clone(): FresnelParameters;
  96301. /**
  96302. * Serializes the current fresnel parameters to a JSON representation.
  96303. * @return the JSON serialization
  96304. */
  96305. serialize(): any;
  96306. /**
  96307. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  96308. * @param parsedFresnelParameters Define the JSON representation
  96309. * @returns the parsed parameters
  96310. */
  96311. static Parse(parsedFresnelParameters: any): FresnelParameters;
  96312. }
  96313. }
  96314. declare module BABYLON {
  96315. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  96316. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96317. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96318. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96319. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96320. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96321. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96322. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96323. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96324. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96325. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96326. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96327. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96328. /**
  96329. * Decorator used to define property that can be serialized as reference to a camera
  96330. * @param sourceName defines the name of the property to decorate
  96331. */
  96332. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96333. /**
  96334. * Class used to help serialization objects
  96335. */
  96336. export class SerializationHelper {
  96337. /** @hidden */
  96338. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  96339. /** @hidden */
  96340. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  96341. /** @hidden */
  96342. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  96343. /** @hidden */
  96344. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  96345. /**
  96346. * Appends the serialized animations from the source animations
  96347. * @param source Source containing the animations
  96348. * @param destination Target to store the animations
  96349. */
  96350. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  96351. /**
  96352. * Static function used to serialized a specific entity
  96353. * @param entity defines the entity to serialize
  96354. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  96355. * @returns a JSON compatible object representing the serialization of the entity
  96356. */
  96357. static Serialize<T>(entity: T, serializationObject?: any): any;
  96358. /**
  96359. * Creates a new entity from a serialization data object
  96360. * @param creationFunction defines a function used to instanciated the new entity
  96361. * @param source defines the source serialization data
  96362. * @param scene defines the hosting scene
  96363. * @param rootUrl defines the root url for resources
  96364. * @returns a new entity
  96365. */
  96366. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  96367. /**
  96368. * Clones an object
  96369. * @param creationFunction defines the function used to instanciate the new object
  96370. * @param source defines the source object
  96371. * @returns the cloned object
  96372. */
  96373. static Clone<T>(creationFunction: () => T, source: T): T;
  96374. /**
  96375. * Instanciates a new object based on a source one (some data will be shared between both object)
  96376. * @param creationFunction defines the function used to instanciate the new object
  96377. * @param source defines the source object
  96378. * @returns the new object
  96379. */
  96380. static Instanciate<T>(creationFunction: () => T, source: T): T;
  96381. }
  96382. }
  96383. declare module BABYLON {
  96384. /**
  96385. * Class used to manipulate GUIDs
  96386. */
  96387. export class GUID {
  96388. /**
  96389. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96390. * Be aware Math.random() could cause collisions, but:
  96391. * "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"
  96392. * @returns a pseudo random id
  96393. */
  96394. static RandomId(): string;
  96395. }
  96396. }
  96397. declare module BABYLON {
  96398. /**
  96399. * Base class of all the textures in babylon.
  96400. * It groups all the common properties the materials, post process, lights... might need
  96401. * in order to make a correct use of the texture.
  96402. */
  96403. export class BaseTexture implements IAnimatable {
  96404. /**
  96405. * Default anisotropic filtering level for the application.
  96406. * It is set to 4 as a good tradeoff between perf and quality.
  96407. */
  96408. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  96409. /**
  96410. * Gets or sets the unique id of the texture
  96411. */
  96412. uniqueId: number;
  96413. /**
  96414. * Define the name of the texture.
  96415. */
  96416. name: string;
  96417. /**
  96418. * Gets or sets an object used to store user defined information.
  96419. */
  96420. metadata: any;
  96421. /**
  96422. * For internal use only. Please do not use.
  96423. */
  96424. reservedDataStore: any;
  96425. private _hasAlpha;
  96426. /**
  96427. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  96428. */
  96429. hasAlpha: boolean;
  96430. /**
  96431. * Defines if the alpha value should be determined via the rgb values.
  96432. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  96433. */
  96434. getAlphaFromRGB: boolean;
  96435. /**
  96436. * Intensity or strength of the texture.
  96437. * It is commonly used by materials to fine tune the intensity of the texture
  96438. */
  96439. level: number;
  96440. /**
  96441. * Define the UV chanel to use starting from 0 and defaulting to 0.
  96442. * This is part of the texture as textures usually maps to one uv set.
  96443. */
  96444. coordinatesIndex: number;
  96445. private _coordinatesMode;
  96446. /**
  96447. * How a texture is mapped.
  96448. *
  96449. * | Value | Type | Description |
  96450. * | ----- | ----------------------------------- | ----------- |
  96451. * | 0 | EXPLICIT_MODE | |
  96452. * | 1 | SPHERICAL_MODE | |
  96453. * | 2 | PLANAR_MODE | |
  96454. * | 3 | CUBIC_MODE | |
  96455. * | 4 | PROJECTION_MODE | |
  96456. * | 5 | SKYBOX_MODE | |
  96457. * | 6 | INVCUBIC_MODE | |
  96458. * | 7 | EQUIRECTANGULAR_MODE | |
  96459. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  96460. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  96461. */
  96462. coordinatesMode: number;
  96463. /**
  96464. * | Value | Type | Description |
  96465. * | ----- | ------------------ | ----------- |
  96466. * | 0 | CLAMP_ADDRESSMODE | |
  96467. * | 1 | WRAP_ADDRESSMODE | |
  96468. * | 2 | MIRROR_ADDRESSMODE | |
  96469. */
  96470. wrapU: number;
  96471. /**
  96472. * | Value | Type | Description |
  96473. * | ----- | ------------------ | ----------- |
  96474. * | 0 | CLAMP_ADDRESSMODE | |
  96475. * | 1 | WRAP_ADDRESSMODE | |
  96476. * | 2 | MIRROR_ADDRESSMODE | |
  96477. */
  96478. wrapV: number;
  96479. /**
  96480. * | Value | Type | Description |
  96481. * | ----- | ------------------ | ----------- |
  96482. * | 0 | CLAMP_ADDRESSMODE | |
  96483. * | 1 | WRAP_ADDRESSMODE | |
  96484. * | 2 | MIRROR_ADDRESSMODE | |
  96485. */
  96486. wrapR: number;
  96487. /**
  96488. * With compliant hardware and browser (supporting anisotropic filtering)
  96489. * this defines the level of anisotropic filtering in the texture.
  96490. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  96491. */
  96492. anisotropicFilteringLevel: number;
  96493. /**
  96494. * Define if the texture is a cube texture or if false a 2d texture.
  96495. */
  96496. isCube: boolean;
  96497. /**
  96498. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  96499. */
  96500. is3D: boolean;
  96501. /**
  96502. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  96503. */
  96504. is2DArray: boolean;
  96505. /**
  96506. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  96507. * HDR texture are usually stored in linear space.
  96508. * This only impacts the PBR and Background materials
  96509. */
  96510. gammaSpace: boolean;
  96511. /**
  96512. * Gets or sets whether or not the texture contains RGBD data.
  96513. */
  96514. isRGBD: boolean;
  96515. /**
  96516. * Is Z inverted in the texture (useful in a cube texture).
  96517. */
  96518. invertZ: boolean;
  96519. /**
  96520. * Are mip maps generated for this texture or not.
  96521. */
  96522. readonly noMipmap: boolean;
  96523. /**
  96524. * @hidden
  96525. */
  96526. lodLevelInAlpha: boolean;
  96527. /**
  96528. * With prefiltered texture, defined the offset used during the prefiltering steps.
  96529. */
  96530. lodGenerationOffset: number;
  96531. /**
  96532. * With prefiltered texture, defined the scale used during the prefiltering steps.
  96533. */
  96534. lodGenerationScale: number;
  96535. /**
  96536. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  96537. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  96538. * average roughness values.
  96539. */
  96540. linearSpecularLOD: boolean;
  96541. /**
  96542. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  96543. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  96544. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  96545. */
  96546. irradianceTexture: Nullable<BaseTexture>;
  96547. /**
  96548. * Define if the texture is a render target.
  96549. */
  96550. isRenderTarget: boolean;
  96551. /**
  96552. * Define the unique id of the texture in the scene.
  96553. */
  96554. readonly uid: string;
  96555. /**
  96556. * Return a string representation of the texture.
  96557. * @returns the texture as a string
  96558. */
  96559. toString(): string;
  96560. /**
  96561. * Get the class name of the texture.
  96562. * @returns "BaseTexture"
  96563. */
  96564. getClassName(): string;
  96565. /**
  96566. * Define the list of animation attached to the texture.
  96567. */
  96568. animations: Animation[];
  96569. /**
  96570. * An event triggered when the texture is disposed.
  96571. */
  96572. onDisposeObservable: Observable<BaseTexture>;
  96573. private _onDisposeObserver;
  96574. /**
  96575. * Callback triggered when the texture has been disposed.
  96576. * Kept for back compatibility, you can use the onDisposeObservable instead.
  96577. */
  96578. onDispose: () => void;
  96579. /**
  96580. * Define the current state of the loading sequence when in delayed load mode.
  96581. */
  96582. delayLoadState: number;
  96583. private _scene;
  96584. /** @hidden */
  96585. _texture: Nullable<InternalTexture>;
  96586. private _uid;
  96587. /**
  96588. * Define if the texture is preventinga material to render or not.
  96589. * If not and the texture is not ready, the engine will use a default black texture instead.
  96590. */
  96591. readonly isBlocking: boolean;
  96592. /**
  96593. * Instantiates a new BaseTexture.
  96594. * Base class of all the textures in babylon.
  96595. * It groups all the common properties the materials, post process, lights... might need
  96596. * in order to make a correct use of the texture.
  96597. * @param scene Define the scene the texture blongs to
  96598. */
  96599. constructor(scene: Nullable<Scene>);
  96600. /**
  96601. * Get the scene the texture belongs to.
  96602. * @returns the scene or null if undefined
  96603. */
  96604. getScene(): Nullable<Scene>;
  96605. /**
  96606. * Get the texture transform matrix used to offset tile the texture for istance.
  96607. * @returns the transformation matrix
  96608. */
  96609. getTextureMatrix(): Matrix;
  96610. /**
  96611. * Get the texture reflection matrix used to rotate/transform the reflection.
  96612. * @returns the reflection matrix
  96613. */
  96614. getReflectionTextureMatrix(): Matrix;
  96615. /**
  96616. * Get the underlying lower level texture from Babylon.
  96617. * @returns the insternal texture
  96618. */
  96619. getInternalTexture(): Nullable<InternalTexture>;
  96620. /**
  96621. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  96622. * @returns true if ready or not blocking
  96623. */
  96624. isReadyOrNotBlocking(): boolean;
  96625. /**
  96626. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  96627. * @returns true if fully ready
  96628. */
  96629. isReady(): boolean;
  96630. private _cachedSize;
  96631. /**
  96632. * Get the size of the texture.
  96633. * @returns the texture size.
  96634. */
  96635. getSize(): ISize;
  96636. /**
  96637. * Get the base size of the texture.
  96638. * It can be different from the size if the texture has been resized for POT for instance
  96639. * @returns the base size
  96640. */
  96641. getBaseSize(): ISize;
  96642. /**
  96643. * Update the sampling mode of the texture.
  96644. * Default is Trilinear mode.
  96645. *
  96646. * | Value | Type | Description |
  96647. * | ----- | ------------------ | ----------- |
  96648. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  96649. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  96650. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  96651. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  96652. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  96653. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  96654. * | 7 | NEAREST_LINEAR | |
  96655. * | 8 | NEAREST_NEAREST | |
  96656. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  96657. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  96658. * | 11 | LINEAR_LINEAR | |
  96659. * | 12 | LINEAR_NEAREST | |
  96660. *
  96661. * > _mag_: magnification filter (close to the viewer)
  96662. * > _min_: minification filter (far from the viewer)
  96663. * > _mip_: filter used between mip map levels
  96664. *@param samplingMode Define the new sampling mode of the texture
  96665. */
  96666. updateSamplingMode(samplingMode: number): void;
  96667. /**
  96668. * Scales the texture if is `canRescale()`
  96669. * @param ratio the resize factor we want to use to rescale
  96670. */
  96671. scale(ratio: number): void;
  96672. /**
  96673. * Get if the texture can rescale.
  96674. */
  96675. readonly canRescale: boolean;
  96676. /** @hidden */
  96677. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  96678. /** @hidden */
  96679. _rebuild(): void;
  96680. /**
  96681. * Triggers the load sequence in delayed load mode.
  96682. */
  96683. delayLoad(): void;
  96684. /**
  96685. * Clones the texture.
  96686. * @returns the cloned texture
  96687. */
  96688. clone(): Nullable<BaseTexture>;
  96689. /**
  96690. * Get the texture underlying type (INT, FLOAT...)
  96691. */
  96692. readonly textureType: number;
  96693. /**
  96694. * Get the texture underlying format (RGB, RGBA...)
  96695. */
  96696. readonly textureFormat: number;
  96697. /**
  96698. * Indicates that textures need to be re-calculated for all materials
  96699. */
  96700. protected _markAllSubMeshesAsTexturesDirty(): void;
  96701. /**
  96702. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  96703. * This will returns an RGBA array buffer containing either in values (0-255) or
  96704. * float values (0-1) depending of the underlying buffer type.
  96705. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  96706. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  96707. * @param buffer defines a user defined buffer to fill with data (can be null)
  96708. * @returns The Array buffer containing the pixels data.
  96709. */
  96710. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  96711. /**
  96712. * Release and destroy the underlying lower level texture aka internalTexture.
  96713. */
  96714. releaseInternalTexture(): void;
  96715. /** @hidden */
  96716. readonly _lodTextureHigh: Nullable<BaseTexture>;
  96717. /** @hidden */
  96718. readonly _lodTextureMid: Nullable<BaseTexture>;
  96719. /** @hidden */
  96720. readonly _lodTextureLow: Nullable<BaseTexture>;
  96721. /**
  96722. * Dispose the texture and release its associated resources.
  96723. */
  96724. dispose(): void;
  96725. /**
  96726. * Serialize the texture into a JSON representation that can be parsed later on.
  96727. * @returns the JSON representation of the texture
  96728. */
  96729. serialize(): any;
  96730. /**
  96731. * Helper function to be called back once a list of texture contains only ready textures.
  96732. * @param textures Define the list of textures to wait for
  96733. * @param callback Define the callback triggered once the entire list will be ready
  96734. */
  96735. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  96736. }
  96737. }
  96738. declare module BABYLON {
  96739. /**
  96740. * Options to be used when creating an effect.
  96741. */
  96742. export interface IEffectCreationOptions {
  96743. /**
  96744. * Atrributes that will be used in the shader.
  96745. */
  96746. attributes: string[];
  96747. /**
  96748. * Uniform varible names that will be set in the shader.
  96749. */
  96750. uniformsNames: string[];
  96751. /**
  96752. * Uniform buffer variable names that will be set in the shader.
  96753. */
  96754. uniformBuffersNames: string[];
  96755. /**
  96756. * Sampler texture variable names that will be set in the shader.
  96757. */
  96758. samplers: string[];
  96759. /**
  96760. * Define statements that will be set in the shader.
  96761. */
  96762. defines: any;
  96763. /**
  96764. * Possible fallbacks for this effect to improve performance when needed.
  96765. */
  96766. fallbacks: Nullable<IEffectFallbacks>;
  96767. /**
  96768. * Callback that will be called when the shader is compiled.
  96769. */
  96770. onCompiled: Nullable<(effect: Effect) => void>;
  96771. /**
  96772. * Callback that will be called if an error occurs during shader compilation.
  96773. */
  96774. onError: Nullable<(effect: Effect, errors: string) => void>;
  96775. /**
  96776. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96777. */
  96778. indexParameters?: any;
  96779. /**
  96780. * Max number of lights that can be used in the shader.
  96781. */
  96782. maxSimultaneousLights?: number;
  96783. /**
  96784. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  96785. */
  96786. transformFeedbackVaryings?: Nullable<string[]>;
  96787. }
  96788. /**
  96789. * Effect containing vertex and fragment shader that can be executed on an object.
  96790. */
  96791. export class Effect implements IDisposable {
  96792. /**
  96793. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96794. */
  96795. static ShadersRepository: string;
  96796. /**
  96797. * Name of the effect.
  96798. */
  96799. name: any;
  96800. /**
  96801. * String container all the define statements that should be set on the shader.
  96802. */
  96803. defines: string;
  96804. /**
  96805. * Callback that will be called when the shader is compiled.
  96806. */
  96807. onCompiled: Nullable<(effect: Effect) => void>;
  96808. /**
  96809. * Callback that will be called if an error occurs during shader compilation.
  96810. */
  96811. onError: Nullable<(effect: Effect, errors: string) => void>;
  96812. /**
  96813. * Callback that will be called when effect is bound.
  96814. */
  96815. onBind: Nullable<(effect: Effect) => void>;
  96816. /**
  96817. * Unique ID of the effect.
  96818. */
  96819. uniqueId: number;
  96820. /**
  96821. * Observable that will be called when the shader is compiled.
  96822. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  96823. */
  96824. onCompileObservable: Observable<Effect>;
  96825. /**
  96826. * Observable that will be called if an error occurs during shader compilation.
  96827. */
  96828. onErrorObservable: Observable<Effect>;
  96829. /** @hidden */
  96830. _onBindObservable: Nullable<Observable<Effect>>;
  96831. /**
  96832. * Observable that will be called when effect is bound.
  96833. */
  96834. readonly onBindObservable: Observable<Effect>;
  96835. /** @hidden */
  96836. _bonesComputationForcedToCPU: boolean;
  96837. private static _uniqueIdSeed;
  96838. private _engine;
  96839. private _uniformBuffersNames;
  96840. private _uniformsNames;
  96841. private _samplerList;
  96842. private _samplers;
  96843. private _isReady;
  96844. private _compilationError;
  96845. private _allFallbacksProcessed;
  96846. private _attributesNames;
  96847. private _attributes;
  96848. private _uniforms;
  96849. /**
  96850. * Key for the effect.
  96851. * @hidden
  96852. */
  96853. _key: string;
  96854. private _indexParameters;
  96855. private _fallbacks;
  96856. private _vertexSourceCode;
  96857. private _fragmentSourceCode;
  96858. private _vertexSourceCodeOverride;
  96859. private _fragmentSourceCodeOverride;
  96860. private _transformFeedbackVaryings;
  96861. /**
  96862. * Compiled shader to webGL program.
  96863. * @hidden
  96864. */
  96865. _pipelineContext: Nullable<IPipelineContext>;
  96866. private _valueCache;
  96867. private static _baseCache;
  96868. /**
  96869. * Instantiates an effect.
  96870. * An effect can be used to create/manage/execute vertex and fragment shaders.
  96871. * @param baseName Name of the effect.
  96872. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  96873. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  96874. * @param samplers List of sampler variables that will be passed to the shader.
  96875. * @param engine Engine to be used to render the effect
  96876. * @param defines Define statements to be added to the shader.
  96877. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  96878. * @param onCompiled Callback that will be called when the shader is compiled.
  96879. * @param onError Callback that will be called if an error occurs during shader compilation.
  96880. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96881. */
  96882. 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);
  96883. private _useFinalCode;
  96884. /**
  96885. * Unique key for this effect
  96886. */
  96887. readonly key: string;
  96888. /**
  96889. * If the effect has been compiled and prepared.
  96890. * @returns if the effect is compiled and prepared.
  96891. */
  96892. isReady(): boolean;
  96893. private _isReadyInternal;
  96894. /**
  96895. * The engine the effect was initialized with.
  96896. * @returns the engine.
  96897. */
  96898. getEngine(): Engine;
  96899. /**
  96900. * The pipeline context for this effect
  96901. * @returns the associated pipeline context
  96902. */
  96903. getPipelineContext(): Nullable<IPipelineContext>;
  96904. /**
  96905. * The set of names of attribute variables for the shader.
  96906. * @returns An array of attribute names.
  96907. */
  96908. getAttributesNames(): string[];
  96909. /**
  96910. * Returns the attribute at the given index.
  96911. * @param index The index of the attribute.
  96912. * @returns The location of the attribute.
  96913. */
  96914. getAttributeLocation(index: number): number;
  96915. /**
  96916. * Returns the attribute based on the name of the variable.
  96917. * @param name of the attribute to look up.
  96918. * @returns the attribute location.
  96919. */
  96920. getAttributeLocationByName(name: string): number;
  96921. /**
  96922. * The number of attributes.
  96923. * @returns the numnber of attributes.
  96924. */
  96925. getAttributesCount(): number;
  96926. /**
  96927. * Gets the index of a uniform variable.
  96928. * @param uniformName of the uniform to look up.
  96929. * @returns the index.
  96930. */
  96931. getUniformIndex(uniformName: string): number;
  96932. /**
  96933. * Returns the attribute based on the name of the variable.
  96934. * @param uniformName of the uniform to look up.
  96935. * @returns the location of the uniform.
  96936. */
  96937. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  96938. /**
  96939. * Returns an array of sampler variable names
  96940. * @returns The array of sampler variable neames.
  96941. */
  96942. getSamplers(): string[];
  96943. /**
  96944. * The error from the last compilation.
  96945. * @returns the error string.
  96946. */
  96947. getCompilationError(): string;
  96948. /**
  96949. * Gets a boolean indicating that all fallbacks were used during compilation
  96950. * @returns true if all fallbacks were used
  96951. */
  96952. allFallbacksProcessed(): boolean;
  96953. /**
  96954. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  96955. * @param func The callback to be used.
  96956. */
  96957. executeWhenCompiled(func: (effect: Effect) => void): void;
  96958. private _checkIsReady;
  96959. private _loadShader;
  96960. /**
  96961. * Recompiles the webGL program
  96962. * @param vertexSourceCode The source code for the vertex shader.
  96963. * @param fragmentSourceCode The source code for the fragment shader.
  96964. * @param onCompiled Callback called when completed.
  96965. * @param onError Callback called on error.
  96966. * @hidden
  96967. */
  96968. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  96969. /**
  96970. * Prepares the effect
  96971. * @hidden
  96972. */
  96973. _prepareEffect(): void;
  96974. private _processCompilationErrors;
  96975. /**
  96976. * Checks if the effect is supported. (Must be called after compilation)
  96977. */
  96978. readonly isSupported: boolean;
  96979. /**
  96980. * Binds a texture to the engine to be used as output of the shader.
  96981. * @param channel Name of the output variable.
  96982. * @param texture Texture to bind.
  96983. * @hidden
  96984. */
  96985. _bindTexture(channel: string, texture: InternalTexture): void;
  96986. /**
  96987. * Sets a texture on the engine to be used in the shader.
  96988. * @param channel Name of the sampler variable.
  96989. * @param texture Texture to set.
  96990. */
  96991. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  96992. /**
  96993. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  96994. * @param channel Name of the sampler variable.
  96995. * @param texture Texture to set.
  96996. */
  96997. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  96998. /**
  96999. * Sets an array of textures on the engine to be used in the shader.
  97000. * @param channel Name of the variable.
  97001. * @param textures Textures to set.
  97002. */
  97003. setTextureArray(channel: string, textures: BaseTexture[]): void;
  97004. /**
  97005. * 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)
  97006. * @param channel Name of the sampler variable.
  97007. * @param postProcess Post process to get the input texture from.
  97008. */
  97009. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  97010. /**
  97011. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  97012. * 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)
  97013. * @param channel Name of the sampler variable.
  97014. * @param postProcess Post process to get the output texture from.
  97015. */
  97016. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  97017. /** @hidden */
  97018. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  97019. /** @hidden */
  97020. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  97021. /** @hidden */
  97022. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  97023. /** @hidden */
  97024. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  97025. /**
  97026. * Binds a buffer to a uniform.
  97027. * @param buffer Buffer to bind.
  97028. * @param name Name of the uniform variable to bind to.
  97029. */
  97030. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  97031. /**
  97032. * Binds block to a uniform.
  97033. * @param blockName Name of the block to bind.
  97034. * @param index Index to bind.
  97035. */
  97036. bindUniformBlock(blockName: string, index: number): void;
  97037. /**
  97038. * Sets an interger value on a uniform variable.
  97039. * @param uniformName Name of the variable.
  97040. * @param value Value to be set.
  97041. * @returns this effect.
  97042. */
  97043. setInt(uniformName: string, value: number): Effect;
  97044. /**
  97045. * Sets an int array on a uniform variable.
  97046. * @param uniformName Name of the variable.
  97047. * @param array array to be set.
  97048. * @returns this effect.
  97049. */
  97050. setIntArray(uniformName: string, array: Int32Array): Effect;
  97051. /**
  97052. * 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)
  97053. * @param uniformName Name of the variable.
  97054. * @param array array to be set.
  97055. * @returns this effect.
  97056. */
  97057. setIntArray2(uniformName: string, array: Int32Array): Effect;
  97058. /**
  97059. * 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)
  97060. * @param uniformName Name of the variable.
  97061. * @param array array to be set.
  97062. * @returns this effect.
  97063. */
  97064. setIntArray3(uniformName: string, array: Int32Array): Effect;
  97065. /**
  97066. * 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)
  97067. * @param uniformName Name of the variable.
  97068. * @param array array to be set.
  97069. * @returns this effect.
  97070. */
  97071. setIntArray4(uniformName: string, array: Int32Array): Effect;
  97072. /**
  97073. * Sets an float array on a uniform variable.
  97074. * @param uniformName Name of the variable.
  97075. * @param array array to be set.
  97076. * @returns this effect.
  97077. */
  97078. setFloatArray(uniformName: string, array: Float32Array): Effect;
  97079. /**
  97080. * 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)
  97081. * @param uniformName Name of the variable.
  97082. * @param array array to be set.
  97083. * @returns this effect.
  97084. */
  97085. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  97086. /**
  97087. * 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)
  97088. * @param uniformName Name of the variable.
  97089. * @param array array to be set.
  97090. * @returns this effect.
  97091. */
  97092. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  97093. /**
  97094. * 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)
  97095. * @param uniformName Name of the variable.
  97096. * @param array array to be set.
  97097. * @returns this effect.
  97098. */
  97099. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  97100. /**
  97101. * Sets an array on a uniform variable.
  97102. * @param uniformName Name of the variable.
  97103. * @param array array to be set.
  97104. * @returns this effect.
  97105. */
  97106. setArray(uniformName: string, array: number[]): Effect;
  97107. /**
  97108. * 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)
  97109. * @param uniformName Name of the variable.
  97110. * @param array array to be set.
  97111. * @returns this effect.
  97112. */
  97113. setArray2(uniformName: string, array: number[]): Effect;
  97114. /**
  97115. * 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)
  97116. * @param uniformName Name of the variable.
  97117. * @param array array to be set.
  97118. * @returns this effect.
  97119. */
  97120. setArray3(uniformName: string, array: number[]): Effect;
  97121. /**
  97122. * 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)
  97123. * @param uniformName Name of the variable.
  97124. * @param array array to be set.
  97125. * @returns this effect.
  97126. */
  97127. setArray4(uniformName: string, array: number[]): Effect;
  97128. /**
  97129. * Sets matrices on a uniform variable.
  97130. * @param uniformName Name of the variable.
  97131. * @param matrices matrices to be set.
  97132. * @returns this effect.
  97133. */
  97134. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  97135. /**
  97136. * Sets matrix on a uniform variable.
  97137. * @param uniformName Name of the variable.
  97138. * @param matrix matrix to be set.
  97139. * @returns this effect.
  97140. */
  97141. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  97142. /**
  97143. * 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)
  97144. * @param uniformName Name of the variable.
  97145. * @param matrix matrix to be set.
  97146. * @returns this effect.
  97147. */
  97148. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  97149. /**
  97150. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  97151. * @param uniformName Name of the variable.
  97152. * @param matrix matrix to be set.
  97153. * @returns this effect.
  97154. */
  97155. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  97156. /**
  97157. * Sets a float on a uniform variable.
  97158. * @param uniformName Name of the variable.
  97159. * @param value value to be set.
  97160. * @returns this effect.
  97161. */
  97162. setFloat(uniformName: string, value: number): Effect;
  97163. /**
  97164. * Sets a boolean on a uniform variable.
  97165. * @param uniformName Name of the variable.
  97166. * @param bool value to be set.
  97167. * @returns this effect.
  97168. */
  97169. setBool(uniformName: string, bool: boolean): Effect;
  97170. /**
  97171. * Sets a Vector2 on a uniform variable.
  97172. * @param uniformName Name of the variable.
  97173. * @param vector2 vector2 to be set.
  97174. * @returns this effect.
  97175. */
  97176. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  97177. /**
  97178. * Sets a float2 on a uniform variable.
  97179. * @param uniformName Name of the variable.
  97180. * @param x First float in float2.
  97181. * @param y Second float in float2.
  97182. * @returns this effect.
  97183. */
  97184. setFloat2(uniformName: string, x: number, y: number): Effect;
  97185. /**
  97186. * Sets a Vector3 on a uniform variable.
  97187. * @param uniformName Name of the variable.
  97188. * @param vector3 Value to be set.
  97189. * @returns this effect.
  97190. */
  97191. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  97192. /**
  97193. * Sets a float3 on a uniform variable.
  97194. * @param uniformName Name of the variable.
  97195. * @param x First float in float3.
  97196. * @param y Second float in float3.
  97197. * @param z Third float in float3.
  97198. * @returns this effect.
  97199. */
  97200. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  97201. /**
  97202. * Sets a Vector4 on a uniform variable.
  97203. * @param uniformName Name of the variable.
  97204. * @param vector4 Value to be set.
  97205. * @returns this effect.
  97206. */
  97207. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  97208. /**
  97209. * Sets a float4 on a uniform variable.
  97210. * @param uniformName Name of the variable.
  97211. * @param x First float in float4.
  97212. * @param y Second float in float4.
  97213. * @param z Third float in float4.
  97214. * @param w Fourth float in float4.
  97215. * @returns this effect.
  97216. */
  97217. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  97218. /**
  97219. * Sets a Color3 on a uniform variable.
  97220. * @param uniformName Name of the variable.
  97221. * @param color3 Value to be set.
  97222. * @returns this effect.
  97223. */
  97224. setColor3(uniformName: string, color3: IColor3Like): Effect;
  97225. /**
  97226. * Sets a Color4 on a uniform variable.
  97227. * @param uniformName Name of the variable.
  97228. * @param color3 Value to be set.
  97229. * @param alpha Alpha value to be set.
  97230. * @returns this effect.
  97231. */
  97232. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  97233. /**
  97234. * Sets a Color4 on a uniform variable
  97235. * @param uniformName defines the name of the variable
  97236. * @param color4 defines the value to be set
  97237. * @returns this effect.
  97238. */
  97239. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  97240. /** Release all associated resources */
  97241. dispose(): void;
  97242. /**
  97243. * This function will add a new shader to the shader store
  97244. * @param name the name of the shader
  97245. * @param pixelShader optional pixel shader content
  97246. * @param vertexShader optional vertex shader content
  97247. */
  97248. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  97249. /**
  97250. * Store of each shader (The can be looked up using effect.key)
  97251. */
  97252. static ShadersStore: {
  97253. [key: string]: string;
  97254. };
  97255. /**
  97256. * Store of each included file for a shader (The can be looked up using effect.key)
  97257. */
  97258. static IncludesShadersStore: {
  97259. [key: string]: string;
  97260. };
  97261. /**
  97262. * Resets the cache of effects.
  97263. */
  97264. static ResetCache(): void;
  97265. }
  97266. }
  97267. declare module BABYLON {
  97268. /**
  97269. * Interface used to describe the capabilities of the engine relatively to the current browser
  97270. */
  97271. export interface EngineCapabilities {
  97272. /** Maximum textures units per fragment shader */
  97273. maxTexturesImageUnits: number;
  97274. /** Maximum texture units per vertex shader */
  97275. maxVertexTextureImageUnits: number;
  97276. /** Maximum textures units in the entire pipeline */
  97277. maxCombinedTexturesImageUnits: number;
  97278. /** Maximum texture size */
  97279. maxTextureSize: number;
  97280. /** Maximum texture samples */
  97281. maxSamples?: number;
  97282. /** Maximum cube texture size */
  97283. maxCubemapTextureSize: number;
  97284. /** Maximum render texture size */
  97285. maxRenderTextureSize: number;
  97286. /** Maximum number of vertex attributes */
  97287. maxVertexAttribs: number;
  97288. /** Maximum number of varyings */
  97289. maxVaryingVectors: number;
  97290. /** Maximum number of uniforms per vertex shader */
  97291. maxVertexUniformVectors: number;
  97292. /** Maximum number of uniforms per fragment shader */
  97293. maxFragmentUniformVectors: number;
  97294. /** Defines if standard derivates (dx/dy) are supported */
  97295. standardDerivatives: boolean;
  97296. /** Defines if s3tc texture compression is supported */
  97297. s3tc?: WEBGL_compressed_texture_s3tc;
  97298. /** Defines if pvrtc texture compression is supported */
  97299. pvrtc: any;
  97300. /** Defines if etc1 texture compression is supported */
  97301. etc1: any;
  97302. /** Defines if etc2 texture compression is supported */
  97303. etc2: any;
  97304. /** Defines if astc texture compression is supported */
  97305. astc: any;
  97306. /** Defines if float textures are supported */
  97307. textureFloat: boolean;
  97308. /** Defines if vertex array objects are supported */
  97309. vertexArrayObject: boolean;
  97310. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  97311. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  97312. /** Gets the maximum level of anisotropy supported */
  97313. maxAnisotropy: number;
  97314. /** Defines if instancing is supported */
  97315. instancedArrays: boolean;
  97316. /** Defines if 32 bits indices are supported */
  97317. uintIndices: boolean;
  97318. /** Defines if high precision shaders are supported */
  97319. highPrecisionShaderSupported: boolean;
  97320. /** Defines if depth reading in the fragment shader is supported */
  97321. fragmentDepthSupported: boolean;
  97322. /** Defines if float texture linear filtering is supported*/
  97323. textureFloatLinearFiltering: boolean;
  97324. /** Defines if rendering to float textures is supported */
  97325. textureFloatRender: boolean;
  97326. /** Defines if half float textures are supported*/
  97327. textureHalfFloat: boolean;
  97328. /** Defines if half float texture linear filtering is supported*/
  97329. textureHalfFloatLinearFiltering: boolean;
  97330. /** Defines if rendering to half float textures is supported */
  97331. textureHalfFloatRender: boolean;
  97332. /** Defines if textureLOD shader command is supported */
  97333. textureLOD: boolean;
  97334. /** Defines if draw buffers extension is supported */
  97335. drawBuffersExtension: boolean;
  97336. /** Defines if depth textures are supported */
  97337. depthTextureExtension: boolean;
  97338. /** Defines if float color buffer are supported */
  97339. colorBufferFloat: boolean;
  97340. /** Gets disjoint timer query extension (null if not supported) */
  97341. timerQuery?: EXT_disjoint_timer_query;
  97342. /** Defines if timestamp can be used with timer query */
  97343. canUseTimestampForTimerQuery: boolean;
  97344. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  97345. multiview?: any;
  97346. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  97347. oculusMultiview?: any;
  97348. /** Function used to let the system compiles shaders in background */
  97349. parallelShaderCompile?: {
  97350. COMPLETION_STATUS_KHR: number;
  97351. };
  97352. /** Max number of texture samples for MSAA */
  97353. maxMSAASamples: number;
  97354. /** Defines if the blend min max extension is supported */
  97355. blendMinMax: boolean;
  97356. }
  97357. }
  97358. declare module BABYLON {
  97359. /**
  97360. * @hidden
  97361. **/
  97362. export class DepthCullingState {
  97363. private _isDepthTestDirty;
  97364. private _isDepthMaskDirty;
  97365. private _isDepthFuncDirty;
  97366. private _isCullFaceDirty;
  97367. private _isCullDirty;
  97368. private _isZOffsetDirty;
  97369. private _isFrontFaceDirty;
  97370. private _depthTest;
  97371. private _depthMask;
  97372. private _depthFunc;
  97373. private _cull;
  97374. private _cullFace;
  97375. private _zOffset;
  97376. private _frontFace;
  97377. /**
  97378. * Initializes the state.
  97379. */
  97380. constructor();
  97381. readonly isDirty: boolean;
  97382. zOffset: number;
  97383. cullFace: Nullable<number>;
  97384. cull: Nullable<boolean>;
  97385. depthFunc: Nullable<number>;
  97386. depthMask: boolean;
  97387. depthTest: boolean;
  97388. frontFace: Nullable<number>;
  97389. reset(): void;
  97390. apply(gl: WebGLRenderingContext): void;
  97391. }
  97392. }
  97393. declare module BABYLON {
  97394. /**
  97395. * @hidden
  97396. **/
  97397. export class StencilState {
  97398. /** 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 */
  97399. static readonly ALWAYS: number;
  97400. /** Passed to stencilOperation to specify that stencil value must be kept */
  97401. static readonly KEEP: number;
  97402. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97403. static readonly REPLACE: number;
  97404. private _isStencilTestDirty;
  97405. private _isStencilMaskDirty;
  97406. private _isStencilFuncDirty;
  97407. private _isStencilOpDirty;
  97408. private _stencilTest;
  97409. private _stencilMask;
  97410. private _stencilFunc;
  97411. private _stencilFuncRef;
  97412. private _stencilFuncMask;
  97413. private _stencilOpStencilFail;
  97414. private _stencilOpDepthFail;
  97415. private _stencilOpStencilDepthPass;
  97416. readonly isDirty: boolean;
  97417. stencilFunc: number;
  97418. stencilFuncRef: number;
  97419. stencilFuncMask: number;
  97420. stencilOpStencilFail: number;
  97421. stencilOpDepthFail: number;
  97422. stencilOpStencilDepthPass: number;
  97423. stencilMask: number;
  97424. stencilTest: boolean;
  97425. constructor();
  97426. reset(): void;
  97427. apply(gl: WebGLRenderingContext): void;
  97428. }
  97429. }
  97430. declare module BABYLON {
  97431. /**
  97432. * @hidden
  97433. **/
  97434. export class AlphaState {
  97435. private _isAlphaBlendDirty;
  97436. private _isBlendFunctionParametersDirty;
  97437. private _isBlendEquationParametersDirty;
  97438. private _isBlendConstantsDirty;
  97439. private _alphaBlend;
  97440. private _blendFunctionParameters;
  97441. private _blendEquationParameters;
  97442. private _blendConstants;
  97443. /**
  97444. * Initializes the state.
  97445. */
  97446. constructor();
  97447. readonly isDirty: boolean;
  97448. alphaBlend: boolean;
  97449. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  97450. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  97451. setAlphaEquationParameters(rgb: number, alpha: number): void;
  97452. reset(): void;
  97453. apply(gl: WebGLRenderingContext): void;
  97454. }
  97455. }
  97456. declare module BABYLON {
  97457. /** @hidden */
  97458. export class WebGL2ShaderProcessor implements IShaderProcessor {
  97459. attributeProcessor(attribute: string): string;
  97460. varyingProcessor(varying: string, isFragment: boolean): string;
  97461. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  97462. }
  97463. }
  97464. declare module BABYLON {
  97465. /**
  97466. * Interface for attribute information associated with buffer instanciation
  97467. */
  97468. export interface InstancingAttributeInfo {
  97469. /**
  97470. * Index/offset of the attribute in the vertex shader
  97471. */
  97472. index: number;
  97473. /**
  97474. * size of the attribute, 1, 2, 3 or 4
  97475. */
  97476. attributeSize: number;
  97477. /**
  97478. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  97479. * default is FLOAT
  97480. */
  97481. attributeType: number;
  97482. /**
  97483. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  97484. */
  97485. normalized: boolean;
  97486. /**
  97487. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  97488. */
  97489. offset: number;
  97490. /**
  97491. * Name of the GLSL attribute, for debugging purpose only
  97492. */
  97493. attributeName: string;
  97494. }
  97495. }
  97496. declare module BABYLON {
  97497. interface ThinEngine {
  97498. /**
  97499. * Update a video texture
  97500. * @param texture defines the texture to update
  97501. * @param video defines the video element to use
  97502. * @param invertY defines if data must be stored with Y axis inverted
  97503. */
  97504. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  97505. }
  97506. }
  97507. declare module BABYLON {
  97508. /**
  97509. * Settings for finer control over video usage
  97510. */
  97511. export interface VideoTextureSettings {
  97512. /**
  97513. * Applies `autoplay` to video, if specified
  97514. */
  97515. autoPlay?: boolean;
  97516. /**
  97517. * Applies `loop` to video, if specified
  97518. */
  97519. loop?: boolean;
  97520. /**
  97521. * Automatically updates internal texture from video at every frame in the render loop
  97522. */
  97523. autoUpdateTexture: boolean;
  97524. /**
  97525. * Image src displayed during the video loading or until the user interacts with the video.
  97526. */
  97527. poster?: string;
  97528. }
  97529. /**
  97530. * If you want to display a video in your scene, this is the special texture for that.
  97531. * This special texture works similar to other textures, with the exception of a few parameters.
  97532. * @see https://doc.babylonjs.com/how_to/video_texture
  97533. */
  97534. export class VideoTexture extends Texture {
  97535. /**
  97536. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  97537. */
  97538. readonly autoUpdateTexture: boolean;
  97539. /**
  97540. * The video instance used by the texture internally
  97541. */
  97542. readonly video: HTMLVideoElement;
  97543. private _onUserActionRequestedObservable;
  97544. /**
  97545. * Event triggerd when a dom action is required by the user to play the video.
  97546. * This happens due to recent changes in browser policies preventing video to auto start.
  97547. */
  97548. readonly onUserActionRequestedObservable: Observable<Texture>;
  97549. private _generateMipMaps;
  97550. private _engine;
  97551. private _stillImageCaptured;
  97552. private _displayingPosterTexture;
  97553. private _settings;
  97554. private _createInternalTextureOnEvent;
  97555. private _frameId;
  97556. /**
  97557. * Creates a video texture.
  97558. * If you want to display a video in your scene, this is the special texture for that.
  97559. * This special texture works similar to other textures, with the exception of a few parameters.
  97560. * @see https://doc.babylonjs.com/how_to/video_texture
  97561. * @param name optional name, will detect from video source, if not defined
  97562. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  97563. * @param scene is obviously the current scene.
  97564. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  97565. * @param invertY is false by default but can be used to invert video on Y axis
  97566. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  97567. * @param settings allows finer control over video usage
  97568. */
  97569. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  97570. private _getName;
  97571. private _getVideo;
  97572. private _createInternalTexture;
  97573. private reset;
  97574. /**
  97575. * @hidden Internal method to initiate `update`.
  97576. */
  97577. _rebuild(): void;
  97578. /**
  97579. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  97580. */
  97581. update(): void;
  97582. /**
  97583. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  97584. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  97585. */
  97586. updateTexture(isVisible: boolean): void;
  97587. protected _updateInternalTexture: () => void;
  97588. /**
  97589. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  97590. * @param url New url.
  97591. */
  97592. updateURL(url: string): void;
  97593. /**
  97594. * Dispose the texture and release its associated resources.
  97595. */
  97596. dispose(): void;
  97597. /**
  97598. * Creates a video texture straight from a stream.
  97599. * @param scene Define the scene the texture should be created in
  97600. * @param stream Define the stream the texture should be created from
  97601. * @returns The created video texture as a promise
  97602. */
  97603. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  97604. /**
  97605. * Creates a video texture straight from your WebCam video feed.
  97606. * @param scene Define the scene the texture should be created in
  97607. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  97608. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  97609. * @returns The created video texture as a promise
  97610. */
  97611. static CreateFromWebCamAsync(scene: Scene, constraints: {
  97612. minWidth: number;
  97613. maxWidth: number;
  97614. minHeight: number;
  97615. maxHeight: number;
  97616. deviceId: string;
  97617. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  97618. /**
  97619. * Creates a video texture straight from your WebCam video feed.
  97620. * @param scene Define the scene the texture should be created in
  97621. * @param onReady Define a callback to triggered once the texture will be ready
  97622. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  97623. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  97624. */
  97625. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  97626. minWidth: number;
  97627. maxWidth: number;
  97628. minHeight: number;
  97629. maxHeight: number;
  97630. deviceId: string;
  97631. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  97632. }
  97633. }
  97634. declare module BABYLON {
  97635. /**
  97636. * Defines the interface used by objects working like Scene
  97637. * @hidden
  97638. */
  97639. interface ISceneLike {
  97640. _addPendingData(data: any): void;
  97641. _removePendingData(data: any): void;
  97642. offlineProvider: IOfflineProvider;
  97643. }
  97644. /** Interface defining initialization parameters for Engine class */
  97645. export interface EngineOptions extends WebGLContextAttributes {
  97646. /**
  97647. * Defines if the engine should no exceed a specified device ratio
  97648. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  97649. */
  97650. limitDeviceRatio?: number;
  97651. /**
  97652. * Defines if webvr should be enabled automatically
  97653. * @see http://doc.babylonjs.com/how_to/webvr_camera
  97654. */
  97655. autoEnableWebVR?: boolean;
  97656. /**
  97657. * Defines if webgl2 should be turned off even if supported
  97658. * @see http://doc.babylonjs.com/features/webgl2
  97659. */
  97660. disableWebGL2Support?: boolean;
  97661. /**
  97662. * Defines if webaudio should be initialized as well
  97663. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97664. */
  97665. audioEngine?: boolean;
  97666. /**
  97667. * Defines if animations should run using a deterministic lock step
  97668. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97669. */
  97670. deterministicLockstep?: boolean;
  97671. /** Defines the maximum steps to use with deterministic lock step mode */
  97672. lockstepMaxSteps?: number;
  97673. /**
  97674. * Defines that engine should ignore context lost events
  97675. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  97676. */
  97677. doNotHandleContextLost?: boolean;
  97678. /**
  97679. * Defines that engine should ignore modifying touch action attribute and style
  97680. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  97681. */
  97682. doNotHandleTouchAction?: boolean;
  97683. /**
  97684. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  97685. */
  97686. useHighPrecisionFloats?: boolean;
  97687. }
  97688. /**
  97689. * The base engine class (root of all engines)
  97690. */
  97691. export class ThinEngine {
  97692. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  97693. static ExceptionList: ({
  97694. key: string;
  97695. capture: string;
  97696. captureConstraint: number;
  97697. targets: string[];
  97698. } | {
  97699. key: string;
  97700. capture: null;
  97701. captureConstraint: null;
  97702. targets: string[];
  97703. })[];
  97704. /** @hidden */
  97705. static _TextureLoaders: IInternalTextureLoader[];
  97706. /**
  97707. * Returns the current npm package of the sdk
  97708. */
  97709. static readonly NpmPackage: string;
  97710. /**
  97711. * Returns the current version of the framework
  97712. */
  97713. static readonly Version: string;
  97714. /**
  97715. * Returns a string describing the current engine
  97716. */
  97717. readonly description: string;
  97718. /**
  97719. * Gets or sets the epsilon value used by collision engine
  97720. */
  97721. static CollisionsEpsilon: number;
  97722. /**
  97723. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  97724. */
  97725. static ShadersRepository: string;
  97726. /** @hidden */
  97727. _shaderProcessor: IShaderProcessor;
  97728. /**
  97729. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  97730. */
  97731. forcePOTTextures: boolean;
  97732. /**
  97733. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  97734. */
  97735. isFullscreen: boolean;
  97736. /**
  97737. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  97738. */
  97739. cullBackFaces: boolean;
  97740. /**
  97741. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  97742. */
  97743. renderEvenInBackground: boolean;
  97744. /**
  97745. * Gets or sets a boolean indicating that cache can be kept between frames
  97746. */
  97747. preventCacheWipeBetweenFrames: boolean;
  97748. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  97749. validateShaderPrograms: boolean;
  97750. /**
  97751. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  97752. */
  97753. disableUniformBuffers: boolean;
  97754. /** @hidden */
  97755. _uniformBuffers: UniformBuffer[];
  97756. /**
  97757. * Gets a boolean indicating that the engine supports uniform buffers
  97758. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  97759. */
  97760. readonly supportsUniformBuffers: boolean;
  97761. /** @hidden */
  97762. _gl: WebGLRenderingContext;
  97763. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  97764. protected _windowIsBackground: boolean;
  97765. protected _webGLVersion: number;
  97766. protected _creationOptions: EngineOptions;
  97767. protected _highPrecisionShadersAllowed: boolean;
  97768. /** @hidden */
  97769. readonly _shouldUseHighPrecisionShader: boolean;
  97770. /**
  97771. * Gets a boolean indicating that only power of 2 textures are supported
  97772. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  97773. */
  97774. readonly needPOTTextures: boolean;
  97775. /** @hidden */
  97776. _badOS: boolean;
  97777. /** @hidden */
  97778. _badDesktopOS: boolean;
  97779. private _hardwareScalingLevel;
  97780. /** @hidden */
  97781. _caps: EngineCapabilities;
  97782. private _isStencilEnable;
  97783. protected _colorWrite: boolean;
  97784. private _glVersion;
  97785. private _glRenderer;
  97786. private _glVendor;
  97787. /** @hidden */
  97788. _videoTextureSupported: boolean;
  97789. protected _renderingQueueLaunched: boolean;
  97790. protected _activeRenderLoops: (() => void)[];
  97791. /**
  97792. * Observable signaled when a context lost event is raised
  97793. */
  97794. onContextLostObservable: Observable<ThinEngine>;
  97795. /**
  97796. * Observable signaled when a context restored event is raised
  97797. */
  97798. onContextRestoredObservable: Observable<ThinEngine>;
  97799. private _onContextLost;
  97800. private _onContextRestored;
  97801. protected _contextWasLost: boolean;
  97802. /** @hidden */
  97803. _doNotHandleContextLost: boolean;
  97804. /**
  97805. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  97806. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  97807. */
  97808. doNotHandleContextLost: boolean;
  97809. /**
  97810. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  97811. */
  97812. disableVertexArrayObjects: boolean;
  97813. /** @hidden */
  97814. protected _depthCullingState: DepthCullingState;
  97815. /** @hidden */
  97816. protected _stencilState: StencilState;
  97817. /** @hidden */
  97818. protected _alphaState: AlphaState;
  97819. /** @hidden */
  97820. _internalTexturesCache: InternalTexture[];
  97821. /** @hidden */
  97822. protected _activeChannel: number;
  97823. private _currentTextureChannel;
  97824. /** @hidden */
  97825. protected _boundTexturesCache: {
  97826. [key: string]: Nullable<InternalTexture>;
  97827. };
  97828. /** @hidden */
  97829. protected _currentEffect: Nullable<Effect>;
  97830. /** @hidden */
  97831. protected _currentProgram: Nullable<WebGLProgram>;
  97832. private _compiledEffects;
  97833. private _vertexAttribArraysEnabled;
  97834. /** @hidden */
  97835. protected _cachedViewport: Nullable<IViewportLike>;
  97836. private _cachedVertexArrayObject;
  97837. /** @hidden */
  97838. protected _cachedVertexBuffers: any;
  97839. /** @hidden */
  97840. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  97841. /** @hidden */
  97842. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  97843. /** @hidden */
  97844. _currentRenderTarget: Nullable<InternalTexture>;
  97845. private _uintIndicesCurrentlySet;
  97846. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  97847. /** @hidden */
  97848. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  97849. private _currentBufferPointers;
  97850. private _currentInstanceLocations;
  97851. private _currentInstanceBuffers;
  97852. private _textureUnits;
  97853. /** @hidden */
  97854. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  97855. /** @hidden */
  97856. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  97857. /** @hidden */
  97858. _boundRenderFunction: any;
  97859. private _vaoRecordInProgress;
  97860. private _mustWipeVertexAttributes;
  97861. private _emptyTexture;
  97862. private _emptyCubeTexture;
  97863. private _emptyTexture3D;
  97864. private _emptyTexture2DArray;
  97865. /** @hidden */
  97866. _frameHandler: number;
  97867. private _nextFreeTextureSlots;
  97868. private _maxSimultaneousTextures;
  97869. private _activeRequests;
  97870. protected _texturesSupported: string[];
  97871. /** @hidden */
  97872. _textureFormatInUse: Nullable<string>;
  97873. protected readonly _supportsHardwareTextureRescaling: boolean;
  97874. /**
  97875. * Gets the list of texture formats supported
  97876. */
  97877. readonly texturesSupported: Array<string>;
  97878. /**
  97879. * Gets the list of texture formats in use
  97880. */
  97881. readonly textureFormatInUse: Nullable<string>;
  97882. /**
  97883. * Gets the current viewport
  97884. */
  97885. readonly currentViewport: Nullable<IViewportLike>;
  97886. /**
  97887. * Gets the default empty texture
  97888. */
  97889. readonly emptyTexture: InternalTexture;
  97890. /**
  97891. * Gets the default empty 3D texture
  97892. */
  97893. readonly emptyTexture3D: InternalTexture;
  97894. /**
  97895. * Gets the default empty 2D array texture
  97896. */
  97897. readonly emptyTexture2DArray: InternalTexture;
  97898. /**
  97899. * Gets the default empty cube texture
  97900. */
  97901. readonly emptyCubeTexture: InternalTexture;
  97902. /**
  97903. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  97904. */
  97905. readonly premultipliedAlpha: boolean;
  97906. /**
  97907. * Observable event triggered before each texture is initialized
  97908. */
  97909. onBeforeTextureInitObservable: Observable<Texture>;
  97910. /**
  97911. * Creates a new engine
  97912. * @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
  97913. * @param antialias defines enable antialiasing (default: false)
  97914. * @param options defines further options to be sent to the getContext() function
  97915. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  97916. */
  97917. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  97918. private _rebuildInternalTextures;
  97919. private _rebuildEffects;
  97920. /**
  97921. * Gets a boolean indicating if all created effects are ready
  97922. * @returns true if all effects are ready
  97923. */
  97924. areAllEffectsReady(): boolean;
  97925. protected _rebuildBuffers(): void;
  97926. private _initGLContext;
  97927. /**
  97928. * Gets version of the current webGL context
  97929. */
  97930. readonly webGLVersion: number;
  97931. /**
  97932. * Gets a string idenfifying the name of the class
  97933. * @returns "Engine" string
  97934. */
  97935. getClassName(): string;
  97936. /**
  97937. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  97938. */
  97939. readonly isStencilEnable: boolean;
  97940. /** @hidden */
  97941. _prepareWorkingCanvas(): void;
  97942. /**
  97943. * Reset the texture cache to empty state
  97944. */
  97945. resetTextureCache(): void;
  97946. /**
  97947. * Gets an object containing information about the current webGL context
  97948. * @returns an object containing the vender, the renderer and the version of the current webGL context
  97949. */
  97950. getGlInfo(): {
  97951. vendor: string;
  97952. renderer: string;
  97953. version: string;
  97954. };
  97955. /**
  97956. * Defines the hardware scaling level.
  97957. * By default the hardware scaling level is computed from the window device ratio.
  97958. * 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.
  97959. * @param level defines the level to use
  97960. */
  97961. setHardwareScalingLevel(level: number): void;
  97962. /**
  97963. * Gets the current hardware scaling level.
  97964. * By default the hardware scaling level is computed from the window device ratio.
  97965. * 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.
  97966. * @returns a number indicating the current hardware scaling level
  97967. */
  97968. getHardwareScalingLevel(): number;
  97969. /**
  97970. * Gets the list of loaded textures
  97971. * @returns an array containing all loaded textures
  97972. */
  97973. getLoadedTexturesCache(): InternalTexture[];
  97974. /**
  97975. * Gets the object containing all engine capabilities
  97976. * @returns the EngineCapabilities object
  97977. */
  97978. getCaps(): EngineCapabilities;
  97979. /**
  97980. * stop executing a render loop function and remove it from the execution array
  97981. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  97982. */
  97983. stopRenderLoop(renderFunction?: () => void): void;
  97984. /** @hidden */
  97985. _renderLoop(): void;
  97986. /**
  97987. * Gets the HTML canvas attached with the current webGL context
  97988. * @returns a HTML canvas
  97989. */
  97990. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  97991. /**
  97992. * Gets host window
  97993. * @returns the host window object
  97994. */
  97995. getHostWindow(): Nullable<Window>;
  97996. /**
  97997. * Gets the current render width
  97998. * @param useScreen defines if screen size must be used (or the current render target if any)
  97999. * @returns a number defining the current render width
  98000. */
  98001. getRenderWidth(useScreen?: boolean): number;
  98002. /**
  98003. * Gets the current render height
  98004. * @param useScreen defines if screen size must be used (or the current render target if any)
  98005. * @returns a number defining the current render height
  98006. */
  98007. getRenderHeight(useScreen?: boolean): number;
  98008. /**
  98009. * Can be used to override the current requestAnimationFrame requester.
  98010. * @hidden
  98011. */
  98012. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  98013. /**
  98014. * Register and execute a render loop. The engine can have more than one render function
  98015. * @param renderFunction defines the function to continuously execute
  98016. */
  98017. runRenderLoop(renderFunction: () => void): void;
  98018. /**
  98019. * Clear the current render buffer or the current render target (if any is set up)
  98020. * @param color defines the color to use
  98021. * @param backBuffer defines if the back buffer must be cleared
  98022. * @param depth defines if the depth buffer must be cleared
  98023. * @param stencil defines if the stencil buffer must be cleared
  98024. */
  98025. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  98026. private _viewportCached;
  98027. /** @hidden */
  98028. _viewport(x: number, y: number, width: number, height: number): void;
  98029. /**
  98030. * Set the WebGL's viewport
  98031. * @param viewport defines the viewport element to be used
  98032. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  98033. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  98034. */
  98035. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  98036. /**
  98037. * Begin a new frame
  98038. */
  98039. beginFrame(): void;
  98040. /**
  98041. * Enf the current frame
  98042. */
  98043. endFrame(): void;
  98044. /**
  98045. * Resize the view according to the canvas' size
  98046. */
  98047. resize(): void;
  98048. /**
  98049. * Force a specific size of the canvas
  98050. * @param width defines the new canvas' width
  98051. * @param height defines the new canvas' height
  98052. */
  98053. setSize(width: number, height: number): void;
  98054. /**
  98055. * Binds the frame buffer to the specified texture.
  98056. * @param texture The texture to render to or null for the default canvas
  98057. * @param faceIndex The face of the texture to render to in case of cube texture
  98058. * @param requiredWidth The width of the target to render to
  98059. * @param requiredHeight The height of the target to render to
  98060. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  98061. * @param depthStencilTexture The depth stencil texture to use to render
  98062. * @param lodLevel defines le lod level to bind to the frame buffer
  98063. */
  98064. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  98065. /** @hidden */
  98066. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  98067. /**
  98068. * Unbind the current render target texture from the webGL context
  98069. * @param texture defines the render target texture to unbind
  98070. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  98071. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  98072. */
  98073. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  98074. /**
  98075. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  98076. */
  98077. flushFramebuffer(): void;
  98078. /**
  98079. * Unbind the current render target and bind the default framebuffer
  98080. */
  98081. restoreDefaultFramebuffer(): void;
  98082. /** @hidden */
  98083. protected _resetVertexBufferBinding(): void;
  98084. /**
  98085. * Creates a vertex buffer
  98086. * @param data the data for the vertex buffer
  98087. * @returns the new WebGL static buffer
  98088. */
  98089. createVertexBuffer(data: DataArray): DataBuffer;
  98090. private _createVertexBuffer;
  98091. /**
  98092. * Creates a dynamic vertex buffer
  98093. * @param data the data for the dynamic vertex buffer
  98094. * @returns the new WebGL dynamic buffer
  98095. */
  98096. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  98097. protected _resetIndexBufferBinding(): void;
  98098. /**
  98099. * Creates a new index buffer
  98100. * @param indices defines the content of the index buffer
  98101. * @param updatable defines if the index buffer must be updatable
  98102. * @returns a new webGL buffer
  98103. */
  98104. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  98105. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  98106. /**
  98107. * Bind a webGL buffer to the webGL context
  98108. * @param buffer defines the buffer to bind
  98109. */
  98110. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  98111. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  98112. private bindBuffer;
  98113. /**
  98114. * update the bound buffer with the given data
  98115. * @param data defines the data to update
  98116. */
  98117. updateArrayBuffer(data: Float32Array): void;
  98118. private _vertexAttribPointer;
  98119. private _bindIndexBufferWithCache;
  98120. private _bindVertexBuffersAttributes;
  98121. /**
  98122. * Records a vertex array object
  98123. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  98124. * @param vertexBuffers defines the list of vertex buffers to store
  98125. * @param indexBuffer defines the index buffer to store
  98126. * @param effect defines the effect to store
  98127. * @returns the new vertex array object
  98128. */
  98129. recordVertexArrayObject(vertexBuffers: {
  98130. [key: string]: VertexBuffer;
  98131. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  98132. /**
  98133. * Bind a specific vertex array object
  98134. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  98135. * @param vertexArrayObject defines the vertex array object to bind
  98136. * @param indexBuffer defines the index buffer to bind
  98137. */
  98138. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  98139. /**
  98140. * Bind webGl buffers directly to the webGL context
  98141. * @param vertexBuffer defines the vertex buffer to bind
  98142. * @param indexBuffer defines the index buffer to bind
  98143. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  98144. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  98145. * @param effect defines the effect associated with the vertex buffer
  98146. */
  98147. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  98148. private _unbindVertexArrayObject;
  98149. /**
  98150. * Bind a list of vertex buffers to the webGL context
  98151. * @param vertexBuffers defines the list of vertex buffers to bind
  98152. * @param indexBuffer defines the index buffer to bind
  98153. * @param effect defines the effect associated with the vertex buffers
  98154. */
  98155. bindBuffers(vertexBuffers: {
  98156. [key: string]: Nullable<VertexBuffer>;
  98157. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  98158. /**
  98159. * Unbind all instance attributes
  98160. */
  98161. unbindInstanceAttributes(): void;
  98162. /**
  98163. * Release and free the memory of a vertex array object
  98164. * @param vao defines the vertex array object to delete
  98165. */
  98166. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  98167. /** @hidden */
  98168. _releaseBuffer(buffer: DataBuffer): boolean;
  98169. protected _deleteBuffer(buffer: DataBuffer): void;
  98170. /**
  98171. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  98172. * @param instancesBuffer defines the webGL buffer to update and bind
  98173. * @param data defines the data to store in the buffer
  98174. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  98175. */
  98176. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  98177. /**
  98178. * Apply all cached states (depth, culling, stencil and alpha)
  98179. */
  98180. applyStates(): void;
  98181. /**
  98182. * Send a draw order
  98183. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  98184. * @param indexStart defines the starting index
  98185. * @param indexCount defines the number of index to draw
  98186. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98187. */
  98188. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  98189. /**
  98190. * Draw a list of points
  98191. * @param verticesStart defines the index of first vertex to draw
  98192. * @param verticesCount defines the count of vertices to draw
  98193. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98194. */
  98195. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98196. /**
  98197. * Draw a list of unindexed primitives
  98198. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  98199. * @param verticesStart defines the index of first vertex to draw
  98200. * @param verticesCount defines the count of vertices to draw
  98201. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98202. */
  98203. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98204. /**
  98205. * Draw a list of indexed primitives
  98206. * @param fillMode defines the primitive to use
  98207. * @param indexStart defines the starting index
  98208. * @param indexCount defines the number of index to draw
  98209. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98210. */
  98211. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  98212. /**
  98213. * Draw a list of unindexed primitives
  98214. * @param fillMode defines the primitive to use
  98215. * @param verticesStart defines the index of first vertex to draw
  98216. * @param verticesCount defines the count of vertices to draw
  98217. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98218. */
  98219. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98220. private _drawMode;
  98221. /** @hidden */
  98222. protected _reportDrawCall(): void;
  98223. /** @hidden */
  98224. _releaseEffect(effect: Effect): void;
  98225. /** @hidden */
  98226. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98227. /**
  98228. * Create a new effect (used to store vertex/fragment shaders)
  98229. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  98230. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  98231. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  98232. * @param samplers defines an array of string used to represent textures
  98233. * @param defines defines the string containing the defines to use to compile the shaders
  98234. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  98235. * @param onCompiled defines a function to call when the effect creation is successful
  98236. * @param onError defines a function to call when the effect creation has failed
  98237. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  98238. * @returns the new Effect
  98239. */
  98240. 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;
  98241. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  98242. private _compileShader;
  98243. private _compileRawShader;
  98244. /**
  98245. * Directly creates a webGL program
  98246. * @param pipelineContext defines the pipeline context to attach to
  98247. * @param vertexCode defines the vertex shader code to use
  98248. * @param fragmentCode defines the fragment shader code to use
  98249. * @param context defines the webGL context to use (if not set, the current one will be used)
  98250. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  98251. * @returns the new webGL program
  98252. */
  98253. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98254. /**
  98255. * Creates a webGL program
  98256. * @param pipelineContext defines the pipeline context to attach to
  98257. * @param vertexCode defines the vertex shader code to use
  98258. * @param fragmentCode defines the fragment shader code to use
  98259. * @param defines defines the string containing the defines to use to compile the shaders
  98260. * @param context defines the webGL context to use (if not set, the current one will be used)
  98261. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  98262. * @returns the new webGL program
  98263. */
  98264. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98265. /**
  98266. * Creates a new pipeline context
  98267. * @returns the new pipeline
  98268. */
  98269. createPipelineContext(): IPipelineContext;
  98270. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98271. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  98272. /** @hidden */
  98273. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  98274. /** @hidden */
  98275. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  98276. /** @hidden */
  98277. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  98278. /**
  98279. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  98280. * @param pipelineContext defines the pipeline context to use
  98281. * @param uniformsNames defines the list of uniform names
  98282. * @returns an array of webGL uniform locations
  98283. */
  98284. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  98285. /**
  98286. * Gets the lsit of active attributes for a given webGL program
  98287. * @param pipelineContext defines the pipeline context to use
  98288. * @param attributesNames defines the list of attribute names to get
  98289. * @returns an array of indices indicating the offset of each attribute
  98290. */
  98291. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  98292. /**
  98293. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  98294. * @param effect defines the effect to activate
  98295. */
  98296. enableEffect(effect: Nullable<Effect>): void;
  98297. /**
  98298. * Set the value of an uniform to a number (int)
  98299. * @param uniform defines the webGL uniform location where to store the value
  98300. * @param value defines the int number to store
  98301. */
  98302. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  98303. /**
  98304. * Set the value of an uniform to an array of int32
  98305. * @param uniform defines the webGL uniform location where to store the value
  98306. * @param array defines the array of int32 to store
  98307. */
  98308. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98309. /**
  98310. * Set the value of an uniform to an array of int32 (stored as vec2)
  98311. * @param uniform defines the webGL uniform location where to store the value
  98312. * @param array defines the array of int32 to store
  98313. */
  98314. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98315. /**
  98316. * Set the value of an uniform to an array of int32 (stored as vec3)
  98317. * @param uniform defines the webGL uniform location where to store the value
  98318. * @param array defines the array of int32 to store
  98319. */
  98320. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98321. /**
  98322. * Set the value of an uniform to an array of int32 (stored as vec4)
  98323. * @param uniform defines the webGL uniform location where to store the value
  98324. * @param array defines the array of int32 to store
  98325. */
  98326. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98327. /**
  98328. * Set the value of an uniform to an array of number
  98329. * @param uniform defines the webGL uniform location where to store the value
  98330. * @param array defines the array of number to store
  98331. */
  98332. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98333. /**
  98334. * Set the value of an uniform to an array of number (stored as vec2)
  98335. * @param uniform defines the webGL uniform location where to store the value
  98336. * @param array defines the array of number to store
  98337. */
  98338. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98339. /**
  98340. * Set the value of an uniform to an array of number (stored as vec3)
  98341. * @param uniform defines the webGL uniform location where to store the value
  98342. * @param array defines the array of number to store
  98343. */
  98344. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98345. /**
  98346. * Set the value of an uniform to an array of number (stored as vec4)
  98347. * @param uniform defines the webGL uniform location where to store the value
  98348. * @param array defines the array of number to store
  98349. */
  98350. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98351. /**
  98352. * Set the value of an uniform to an array of float32 (stored as matrices)
  98353. * @param uniform defines the webGL uniform location where to store the value
  98354. * @param matrices defines the array of float32 to store
  98355. */
  98356. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  98357. /**
  98358. * Set the value of an uniform to a matrix (3x3)
  98359. * @param uniform defines the webGL uniform location where to store the value
  98360. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  98361. */
  98362. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  98363. /**
  98364. * Set the value of an uniform to a matrix (2x2)
  98365. * @param uniform defines the webGL uniform location where to store the value
  98366. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  98367. */
  98368. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  98369. /**
  98370. * Set the value of an uniform to a number (float)
  98371. * @param uniform defines the webGL uniform location where to store the value
  98372. * @param value defines the float number to store
  98373. */
  98374. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  98375. /**
  98376. * Set the value of an uniform to a vec2
  98377. * @param uniform defines the webGL uniform location where to store the value
  98378. * @param x defines the 1st component of the value
  98379. * @param y defines the 2nd component of the value
  98380. */
  98381. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  98382. /**
  98383. * Set the value of an uniform to a vec3
  98384. * @param uniform defines the webGL uniform location where to store the value
  98385. * @param x defines the 1st component of the value
  98386. * @param y defines the 2nd component of the value
  98387. * @param z defines the 3rd component of the value
  98388. */
  98389. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  98390. /**
  98391. * Set the value of an uniform to a vec4
  98392. * @param uniform defines the webGL uniform location where to store the value
  98393. * @param x defines the 1st component of the value
  98394. * @param y defines the 2nd component of the value
  98395. * @param z defines the 3rd component of the value
  98396. * @param w defines the 4th component of the value
  98397. */
  98398. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  98399. /**
  98400. * Gets the depth culling state manager
  98401. */
  98402. readonly depthCullingState: DepthCullingState;
  98403. /**
  98404. * Gets the alpha state manager
  98405. */
  98406. readonly alphaState: AlphaState;
  98407. /**
  98408. * Gets the stencil state manager
  98409. */
  98410. readonly stencilState: StencilState;
  98411. /**
  98412. * Clears the list of texture accessible through engine.
  98413. * This can help preventing texture load conflict due to name collision.
  98414. */
  98415. clearInternalTexturesCache(): void;
  98416. /**
  98417. * Force the entire cache to be cleared
  98418. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  98419. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  98420. */
  98421. wipeCaches(bruteForce?: boolean): void;
  98422. /** @hidden */
  98423. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  98424. min: number;
  98425. mag: number;
  98426. };
  98427. /** @hidden */
  98428. _createTexture(): WebGLTexture;
  98429. /**
  98430. * Usually called from Texture.ts.
  98431. * Passed information to create a WebGLTexture
  98432. * @param urlArg defines a value which contains one of the following:
  98433. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  98434. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  98435. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  98436. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  98437. * @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)
  98438. * @param scene needed for loading to the correct scene
  98439. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  98440. * @param onLoad optional callback to be called upon successful completion
  98441. * @param onError optional callback to be called upon failure
  98442. * @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
  98443. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  98444. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  98445. * @param forcedExtension defines the extension to use to pick the right loader
  98446. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  98447. * @param mimeType defines an optional mime type
  98448. * @returns a InternalTexture for assignment back into BABYLON.Texture
  98449. */
  98450. 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;
  98451. /**
  98452. * @hidden
  98453. */
  98454. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98455. /**
  98456. * Creates a raw texture
  98457. * @param data defines the data to store in the texture
  98458. * @param width defines the width of the texture
  98459. * @param height defines the height of the texture
  98460. * @param format defines the format of the data
  98461. * @param generateMipMaps defines if the engine should generate the mip levels
  98462. * @param invertY defines if data must be stored with Y axis inverted
  98463. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  98464. * @param compression defines the compression used (null by default)
  98465. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  98466. * @returns the raw texture inside an InternalTexture
  98467. */
  98468. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  98469. /**
  98470. * Creates a new raw cube texture
  98471. * @param data defines the array of data to use to create each face
  98472. * @param size defines the size of the textures
  98473. * @param format defines the format of the data
  98474. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  98475. * @param generateMipMaps defines if the engine should generate the mip levels
  98476. * @param invertY defines if data must be stored with Y axis inverted
  98477. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98478. * @param compression defines the compression used (null by default)
  98479. * @returns the cube texture as an InternalTexture
  98480. */
  98481. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  98482. /**
  98483. * Creates a new raw 3D texture
  98484. * @param data defines the data used to create the texture
  98485. * @param width defines the width of the texture
  98486. * @param height defines the height of the texture
  98487. * @param depth defines the depth of the texture
  98488. * @param format defines the format of the texture
  98489. * @param generateMipMaps defines if the engine must generate mip levels
  98490. * @param invertY defines if data must be stored with Y axis inverted
  98491. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98492. * @param compression defines the compressed used (can be null)
  98493. * @param textureType defines the compressed used (can be null)
  98494. * @returns a new raw 3D texture (stored in an InternalTexture)
  98495. */
  98496. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98497. /**
  98498. * Creates a new raw 2D array texture
  98499. * @param data defines the data used to create the texture
  98500. * @param width defines the width of the texture
  98501. * @param height defines the height of the texture
  98502. * @param depth defines the number of layers of the texture
  98503. * @param format defines the format of the texture
  98504. * @param generateMipMaps defines if the engine must generate mip levels
  98505. * @param invertY defines if data must be stored with Y axis inverted
  98506. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98507. * @param compression defines the compressed used (can be null)
  98508. * @param textureType defines the compressed used (can be null)
  98509. * @returns a new raw 2D array texture (stored in an InternalTexture)
  98510. */
  98511. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98512. private _unpackFlipYCached;
  98513. /**
  98514. * In case you are sharing the context with other applications, it might
  98515. * be interested to not cache the unpack flip y state to ensure a consistent
  98516. * value would be set.
  98517. */
  98518. enableUnpackFlipYCached: boolean;
  98519. /** @hidden */
  98520. _unpackFlipY(value: boolean): void;
  98521. /** @hidden */
  98522. _getUnpackAlignement(): number;
  98523. /**
  98524. * Update the sampling mode of a given texture
  98525. * @param samplingMode defines the required sampling mode
  98526. * @param texture defines the texture to update
  98527. */
  98528. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  98529. /** @hidden */
  98530. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  98531. width: number;
  98532. height: number;
  98533. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  98534. /** @hidden */
  98535. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98536. /** @hidden */
  98537. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  98538. /** @hidden */
  98539. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98540. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  98541. private _prepareWebGLTexture;
  98542. /** @hidden */
  98543. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  98544. /** @hidden */
  98545. _releaseFramebufferObjects(texture: InternalTexture): void;
  98546. /** @hidden */
  98547. _releaseTexture(texture: InternalTexture): void;
  98548. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  98549. protected _setProgram(program: WebGLProgram): void;
  98550. protected _boundUniforms: {
  98551. [key: number]: WebGLUniformLocation;
  98552. };
  98553. /**
  98554. * Binds an effect to the webGL context
  98555. * @param effect defines the effect to bind
  98556. */
  98557. bindSamplers(effect: Effect): void;
  98558. private _activateCurrentTexture;
  98559. /** @hidden */
  98560. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  98561. /** @hidden */
  98562. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  98563. /**
  98564. * Unbind all textures from the webGL context
  98565. */
  98566. unbindAllTextures(): void;
  98567. /**
  98568. * Sets a texture to the according uniform.
  98569. * @param channel The texture channel
  98570. * @param uniform The uniform to set
  98571. * @param texture The texture to apply
  98572. */
  98573. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  98574. private _bindSamplerUniformToChannel;
  98575. private _getTextureWrapMode;
  98576. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  98577. /**
  98578. * Sets an array of texture to the webGL context
  98579. * @param channel defines the channel where the texture array must be set
  98580. * @param uniform defines the associated uniform location
  98581. * @param textures defines the array of textures to bind
  98582. */
  98583. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  98584. /** @hidden */
  98585. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  98586. private _setTextureParameterFloat;
  98587. private _setTextureParameterInteger;
  98588. /**
  98589. * Unbind all vertex attributes from the webGL context
  98590. */
  98591. unbindAllAttributes(): void;
  98592. /**
  98593. * 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
  98594. */
  98595. releaseEffects(): void;
  98596. /**
  98597. * Dispose and release all associated resources
  98598. */
  98599. dispose(): void;
  98600. /**
  98601. * Attach a new callback raised when context lost event is fired
  98602. * @param callback defines the callback to call
  98603. */
  98604. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  98605. /**
  98606. * Attach a new callback raised when context restored event is fired
  98607. * @param callback defines the callback to call
  98608. */
  98609. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  98610. /**
  98611. * Get the current error code of the webGL context
  98612. * @returns the error code
  98613. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  98614. */
  98615. getError(): number;
  98616. private _canRenderToFloatFramebuffer;
  98617. private _canRenderToHalfFloatFramebuffer;
  98618. private _canRenderToFramebuffer;
  98619. /** @hidden */
  98620. _getWebGLTextureType(type: number): number;
  98621. /** @hidden */
  98622. _getInternalFormat(format: number): number;
  98623. /** @hidden */
  98624. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  98625. /** @hidden */
  98626. _getRGBAMultiSampleBufferFormat(type: number): number;
  98627. /** @hidden */
  98628. _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;
  98629. /**
  98630. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  98631. * @returns true if the engine can be created
  98632. * @ignorenaming
  98633. */
  98634. static isSupported(): boolean;
  98635. /**
  98636. * Find the next highest power of two.
  98637. * @param x Number to start search from.
  98638. * @return Next highest power of two.
  98639. */
  98640. static CeilingPOT(x: number): number;
  98641. /**
  98642. * Find the next lowest power of two.
  98643. * @param x Number to start search from.
  98644. * @return Next lowest power of two.
  98645. */
  98646. static FloorPOT(x: number): number;
  98647. /**
  98648. * Find the nearest power of two.
  98649. * @param x Number to start search from.
  98650. * @return Next nearest power of two.
  98651. */
  98652. static NearestPOT(x: number): number;
  98653. /**
  98654. * Get the closest exponent of two
  98655. * @param value defines the value to approximate
  98656. * @param max defines the maximum value to return
  98657. * @param mode defines how to define the closest value
  98658. * @returns closest exponent of two of the given value
  98659. */
  98660. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  98661. /**
  98662. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  98663. * @param func - the function to be called
  98664. * @param requester - the object that will request the next frame. Falls back to window.
  98665. * @returns frame number
  98666. */
  98667. static QueueNewFrame(func: () => void, requester?: any): number;
  98668. }
  98669. }
  98670. declare module BABYLON {
  98671. /**
  98672. * Class representing spherical harmonics coefficients to the 3rd degree
  98673. */
  98674. export class SphericalHarmonics {
  98675. /**
  98676. * Defines whether or not the harmonics have been prescaled for rendering.
  98677. */
  98678. preScaled: boolean;
  98679. /**
  98680. * The l0,0 coefficients of the spherical harmonics
  98681. */
  98682. l00: Vector3;
  98683. /**
  98684. * The l1,-1 coefficients of the spherical harmonics
  98685. */
  98686. l1_1: Vector3;
  98687. /**
  98688. * The l1,0 coefficients of the spherical harmonics
  98689. */
  98690. l10: Vector3;
  98691. /**
  98692. * The l1,1 coefficients of the spherical harmonics
  98693. */
  98694. l11: Vector3;
  98695. /**
  98696. * The l2,-2 coefficients of the spherical harmonics
  98697. */
  98698. l2_2: Vector3;
  98699. /**
  98700. * The l2,-1 coefficients of the spherical harmonics
  98701. */
  98702. l2_1: Vector3;
  98703. /**
  98704. * The l2,0 coefficients of the spherical harmonics
  98705. */
  98706. l20: Vector3;
  98707. /**
  98708. * The l2,1 coefficients of the spherical harmonics
  98709. */
  98710. l21: Vector3;
  98711. /**
  98712. * The l2,2 coefficients of the spherical harmonics
  98713. */
  98714. l22: Vector3;
  98715. /**
  98716. * Adds a light to the spherical harmonics
  98717. * @param direction the direction of the light
  98718. * @param color the color of the light
  98719. * @param deltaSolidAngle the delta solid angle of the light
  98720. */
  98721. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  98722. /**
  98723. * Scales the spherical harmonics by the given amount
  98724. * @param scale the amount to scale
  98725. */
  98726. scaleInPlace(scale: number): void;
  98727. /**
  98728. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  98729. *
  98730. * ```
  98731. * E_lm = A_l * L_lm
  98732. * ```
  98733. *
  98734. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  98735. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  98736. * the scaling factors are given in equation 9.
  98737. */
  98738. convertIncidentRadianceToIrradiance(): void;
  98739. /**
  98740. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  98741. *
  98742. * ```
  98743. * L = (1/pi) * E * rho
  98744. * ```
  98745. *
  98746. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  98747. */
  98748. convertIrradianceToLambertianRadiance(): void;
  98749. /**
  98750. * Integrates the reconstruction coefficients directly in to the SH preventing further
  98751. * required operations at run time.
  98752. *
  98753. * This is simply done by scaling back the SH with Ylm constants parameter.
  98754. * The trigonometric part being applied by the shader at run time.
  98755. */
  98756. preScaleForRendering(): void;
  98757. /**
  98758. * Constructs a spherical harmonics from an array.
  98759. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  98760. * @returns the spherical harmonics
  98761. */
  98762. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  98763. /**
  98764. * Gets the spherical harmonics from polynomial
  98765. * @param polynomial the spherical polynomial
  98766. * @returns the spherical harmonics
  98767. */
  98768. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  98769. }
  98770. /**
  98771. * Class representing spherical polynomial coefficients to the 3rd degree
  98772. */
  98773. export class SphericalPolynomial {
  98774. private _harmonics;
  98775. /**
  98776. * The spherical harmonics used to create the polynomials.
  98777. */
  98778. readonly preScaledHarmonics: SphericalHarmonics;
  98779. /**
  98780. * The x coefficients of the spherical polynomial
  98781. */
  98782. x: Vector3;
  98783. /**
  98784. * The y coefficients of the spherical polynomial
  98785. */
  98786. y: Vector3;
  98787. /**
  98788. * The z coefficients of the spherical polynomial
  98789. */
  98790. z: Vector3;
  98791. /**
  98792. * The xx coefficients of the spherical polynomial
  98793. */
  98794. xx: Vector3;
  98795. /**
  98796. * The yy coefficients of the spherical polynomial
  98797. */
  98798. yy: Vector3;
  98799. /**
  98800. * The zz coefficients of the spherical polynomial
  98801. */
  98802. zz: Vector3;
  98803. /**
  98804. * The xy coefficients of the spherical polynomial
  98805. */
  98806. xy: Vector3;
  98807. /**
  98808. * The yz coefficients of the spherical polynomial
  98809. */
  98810. yz: Vector3;
  98811. /**
  98812. * The zx coefficients of the spherical polynomial
  98813. */
  98814. zx: Vector3;
  98815. /**
  98816. * Adds an ambient color to the spherical polynomial
  98817. * @param color the color to add
  98818. */
  98819. addAmbient(color: Color3): void;
  98820. /**
  98821. * Scales the spherical polynomial by the given amount
  98822. * @param scale the amount to scale
  98823. */
  98824. scaleInPlace(scale: number): void;
  98825. /**
  98826. * Gets the spherical polynomial from harmonics
  98827. * @param harmonics the spherical harmonics
  98828. * @returns the spherical polynomial
  98829. */
  98830. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  98831. /**
  98832. * Constructs a spherical polynomial from an array.
  98833. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  98834. * @returns the spherical polynomial
  98835. */
  98836. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  98837. }
  98838. }
  98839. declare module BABYLON {
  98840. /**
  98841. * Defines the source of the internal texture
  98842. */
  98843. export enum InternalTextureSource {
  98844. /**
  98845. * The source of the texture data is unknown
  98846. */
  98847. Unknown = 0,
  98848. /**
  98849. * Texture data comes from an URL
  98850. */
  98851. Url = 1,
  98852. /**
  98853. * Texture data is only used for temporary storage
  98854. */
  98855. Temp = 2,
  98856. /**
  98857. * Texture data comes from raw data (ArrayBuffer)
  98858. */
  98859. Raw = 3,
  98860. /**
  98861. * Texture content is dynamic (video or dynamic texture)
  98862. */
  98863. Dynamic = 4,
  98864. /**
  98865. * Texture content is generated by rendering to it
  98866. */
  98867. RenderTarget = 5,
  98868. /**
  98869. * Texture content is part of a multi render target process
  98870. */
  98871. MultiRenderTarget = 6,
  98872. /**
  98873. * Texture data comes from a cube data file
  98874. */
  98875. Cube = 7,
  98876. /**
  98877. * Texture data comes from a raw cube data
  98878. */
  98879. CubeRaw = 8,
  98880. /**
  98881. * Texture data come from a prefiltered cube data file
  98882. */
  98883. CubePrefiltered = 9,
  98884. /**
  98885. * Texture content is raw 3D data
  98886. */
  98887. Raw3D = 10,
  98888. /**
  98889. * Texture content is raw 2D array data
  98890. */
  98891. Raw2DArray = 11,
  98892. /**
  98893. * Texture content is a depth texture
  98894. */
  98895. Depth = 12,
  98896. /**
  98897. * Texture data comes from a raw cube data encoded with RGBD
  98898. */
  98899. CubeRawRGBD = 13
  98900. }
  98901. /**
  98902. * Class used to store data associated with WebGL texture data for the engine
  98903. * This class should not be used directly
  98904. */
  98905. export class InternalTexture {
  98906. /** @hidden */
  98907. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  98908. /**
  98909. * Defines if the texture is ready
  98910. */
  98911. isReady: boolean;
  98912. /**
  98913. * Defines if the texture is a cube texture
  98914. */
  98915. isCube: boolean;
  98916. /**
  98917. * Defines if the texture contains 3D data
  98918. */
  98919. is3D: boolean;
  98920. /**
  98921. * Defines if the texture contains 2D array data
  98922. */
  98923. is2DArray: boolean;
  98924. /**
  98925. * Defines if the texture contains multiview data
  98926. */
  98927. isMultiview: boolean;
  98928. /**
  98929. * Gets the URL used to load this texture
  98930. */
  98931. url: string;
  98932. /**
  98933. * Gets the sampling mode of the texture
  98934. */
  98935. samplingMode: number;
  98936. /**
  98937. * Gets a boolean indicating if the texture needs mipmaps generation
  98938. */
  98939. generateMipMaps: boolean;
  98940. /**
  98941. * Gets the number of samples used by the texture (WebGL2+ only)
  98942. */
  98943. samples: number;
  98944. /**
  98945. * Gets the type of the texture (int, float...)
  98946. */
  98947. type: number;
  98948. /**
  98949. * Gets the format of the texture (RGB, RGBA...)
  98950. */
  98951. format: number;
  98952. /**
  98953. * Observable called when the texture is loaded
  98954. */
  98955. onLoadedObservable: Observable<InternalTexture>;
  98956. /**
  98957. * Gets the width of the texture
  98958. */
  98959. width: number;
  98960. /**
  98961. * Gets the height of the texture
  98962. */
  98963. height: number;
  98964. /**
  98965. * Gets the depth of the texture
  98966. */
  98967. depth: number;
  98968. /**
  98969. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  98970. */
  98971. baseWidth: number;
  98972. /**
  98973. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  98974. */
  98975. baseHeight: number;
  98976. /**
  98977. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  98978. */
  98979. baseDepth: number;
  98980. /**
  98981. * Gets a boolean indicating if the texture is inverted on Y axis
  98982. */
  98983. invertY: boolean;
  98984. /** @hidden */
  98985. _invertVScale: boolean;
  98986. /** @hidden */
  98987. _associatedChannel: number;
  98988. /** @hidden */
  98989. _source: InternalTextureSource;
  98990. /** @hidden */
  98991. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  98992. /** @hidden */
  98993. _bufferView: Nullable<ArrayBufferView>;
  98994. /** @hidden */
  98995. _bufferViewArray: Nullable<ArrayBufferView[]>;
  98996. /** @hidden */
  98997. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  98998. /** @hidden */
  98999. _size: number;
  99000. /** @hidden */
  99001. _extension: string;
  99002. /** @hidden */
  99003. _files: Nullable<string[]>;
  99004. /** @hidden */
  99005. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  99006. /** @hidden */
  99007. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  99008. /** @hidden */
  99009. _framebuffer: Nullable<WebGLFramebuffer>;
  99010. /** @hidden */
  99011. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  99012. /** @hidden */
  99013. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  99014. /** @hidden */
  99015. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  99016. /** @hidden */
  99017. _attachments: Nullable<number[]>;
  99018. /** @hidden */
  99019. _cachedCoordinatesMode: Nullable<number>;
  99020. /** @hidden */
  99021. _cachedWrapU: Nullable<number>;
  99022. /** @hidden */
  99023. _cachedWrapV: Nullable<number>;
  99024. /** @hidden */
  99025. _cachedWrapR: Nullable<number>;
  99026. /** @hidden */
  99027. _cachedAnisotropicFilteringLevel: Nullable<number>;
  99028. /** @hidden */
  99029. _isDisabled: boolean;
  99030. /** @hidden */
  99031. _compression: Nullable<string>;
  99032. /** @hidden */
  99033. _generateStencilBuffer: boolean;
  99034. /** @hidden */
  99035. _generateDepthBuffer: boolean;
  99036. /** @hidden */
  99037. _comparisonFunction: number;
  99038. /** @hidden */
  99039. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  99040. /** @hidden */
  99041. _lodGenerationScale: number;
  99042. /** @hidden */
  99043. _lodGenerationOffset: number;
  99044. /** @hidden */
  99045. _colorTextureArray: Nullable<WebGLTexture>;
  99046. /** @hidden */
  99047. _depthStencilTextureArray: Nullable<WebGLTexture>;
  99048. /** @hidden */
  99049. _lodTextureHigh: Nullable<BaseTexture>;
  99050. /** @hidden */
  99051. _lodTextureMid: Nullable<BaseTexture>;
  99052. /** @hidden */
  99053. _lodTextureLow: Nullable<BaseTexture>;
  99054. /** @hidden */
  99055. _isRGBD: boolean;
  99056. /** @hidden */
  99057. _linearSpecularLOD: boolean;
  99058. /** @hidden */
  99059. _irradianceTexture: Nullable<BaseTexture>;
  99060. /** @hidden */
  99061. _webGLTexture: Nullable<WebGLTexture>;
  99062. /** @hidden */
  99063. _references: number;
  99064. private _engine;
  99065. /**
  99066. * Gets the Engine the texture belongs to.
  99067. * @returns The babylon engine
  99068. */
  99069. getEngine(): ThinEngine;
  99070. /**
  99071. * Gets the data source type of the texture
  99072. */
  99073. readonly source: InternalTextureSource;
  99074. /**
  99075. * Creates a new InternalTexture
  99076. * @param engine defines the engine to use
  99077. * @param source defines the type of data that will be used
  99078. * @param delayAllocation if the texture allocation should be delayed (default: false)
  99079. */
  99080. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  99081. /**
  99082. * Increments the number of references (ie. the number of Texture that point to it)
  99083. */
  99084. incrementReferences(): void;
  99085. /**
  99086. * Change the size of the texture (not the size of the content)
  99087. * @param width defines the new width
  99088. * @param height defines the new height
  99089. * @param depth defines the new depth (1 by default)
  99090. */
  99091. updateSize(width: int, height: int, depth?: int): void;
  99092. /** @hidden */
  99093. _rebuild(): void;
  99094. /** @hidden */
  99095. _swapAndDie(target: InternalTexture): void;
  99096. /**
  99097. * Dispose the current allocated resources
  99098. */
  99099. dispose(): void;
  99100. }
  99101. }
  99102. declare module BABYLON {
  99103. /**
  99104. * Class used to work with sound analyzer using fast fourier transform (FFT)
  99105. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99106. */
  99107. export class Analyser {
  99108. /**
  99109. * Gets or sets the smoothing
  99110. * @ignorenaming
  99111. */
  99112. SMOOTHING: number;
  99113. /**
  99114. * Gets or sets the FFT table size
  99115. * @ignorenaming
  99116. */
  99117. FFT_SIZE: number;
  99118. /**
  99119. * Gets or sets the bar graph amplitude
  99120. * @ignorenaming
  99121. */
  99122. BARGRAPHAMPLITUDE: number;
  99123. /**
  99124. * Gets or sets the position of the debug canvas
  99125. * @ignorenaming
  99126. */
  99127. DEBUGCANVASPOS: {
  99128. x: number;
  99129. y: number;
  99130. };
  99131. /**
  99132. * Gets or sets the debug canvas size
  99133. * @ignorenaming
  99134. */
  99135. DEBUGCANVASSIZE: {
  99136. width: number;
  99137. height: number;
  99138. };
  99139. private _byteFreqs;
  99140. private _byteTime;
  99141. private _floatFreqs;
  99142. private _webAudioAnalyser;
  99143. private _debugCanvas;
  99144. private _debugCanvasContext;
  99145. private _scene;
  99146. private _registerFunc;
  99147. private _audioEngine;
  99148. /**
  99149. * Creates a new analyser
  99150. * @param scene defines hosting scene
  99151. */
  99152. constructor(scene: Scene);
  99153. /**
  99154. * Get the number of data values you will have to play with for the visualization
  99155. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  99156. * @returns a number
  99157. */
  99158. getFrequencyBinCount(): number;
  99159. /**
  99160. * Gets the current frequency data as a byte array
  99161. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  99162. * @returns a Uint8Array
  99163. */
  99164. getByteFrequencyData(): Uint8Array;
  99165. /**
  99166. * Gets the current waveform as a byte array
  99167. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  99168. * @returns a Uint8Array
  99169. */
  99170. getByteTimeDomainData(): Uint8Array;
  99171. /**
  99172. * Gets the current frequency data as a float array
  99173. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  99174. * @returns a Float32Array
  99175. */
  99176. getFloatFrequencyData(): Float32Array;
  99177. /**
  99178. * Renders the debug canvas
  99179. */
  99180. drawDebugCanvas(): void;
  99181. /**
  99182. * Stops rendering the debug canvas and removes it
  99183. */
  99184. stopDebugCanvas(): void;
  99185. /**
  99186. * Connects two audio nodes
  99187. * @param inputAudioNode defines first node to connect
  99188. * @param outputAudioNode defines second node to connect
  99189. */
  99190. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  99191. /**
  99192. * Releases all associated resources
  99193. */
  99194. dispose(): void;
  99195. }
  99196. }
  99197. declare module BABYLON {
  99198. /**
  99199. * This represents an audio engine and it is responsible
  99200. * to play, synchronize and analyse sounds throughout the application.
  99201. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99202. */
  99203. export interface IAudioEngine extends IDisposable {
  99204. /**
  99205. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  99206. */
  99207. readonly canUseWebAudio: boolean;
  99208. /**
  99209. * Gets the current AudioContext if available.
  99210. */
  99211. readonly audioContext: Nullable<AudioContext>;
  99212. /**
  99213. * The master gain node defines the global audio volume of your audio engine.
  99214. */
  99215. readonly masterGain: GainNode;
  99216. /**
  99217. * Gets whether or not mp3 are supported by your browser.
  99218. */
  99219. readonly isMP3supported: boolean;
  99220. /**
  99221. * Gets whether or not ogg are supported by your browser.
  99222. */
  99223. readonly isOGGsupported: boolean;
  99224. /**
  99225. * Defines if Babylon should emit a warning if WebAudio is not supported.
  99226. * @ignoreNaming
  99227. */
  99228. WarnedWebAudioUnsupported: boolean;
  99229. /**
  99230. * Defines if the audio engine relies on a custom unlocked button.
  99231. * In this case, the embedded button will not be displayed.
  99232. */
  99233. useCustomUnlockedButton: boolean;
  99234. /**
  99235. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  99236. */
  99237. readonly unlocked: boolean;
  99238. /**
  99239. * Event raised when audio has been unlocked on the browser.
  99240. */
  99241. onAudioUnlockedObservable: Observable<AudioEngine>;
  99242. /**
  99243. * Event raised when audio has been locked on the browser.
  99244. */
  99245. onAudioLockedObservable: Observable<AudioEngine>;
  99246. /**
  99247. * Flags the audio engine in Locked state.
  99248. * This happens due to new browser policies preventing audio to autoplay.
  99249. */
  99250. lock(): void;
  99251. /**
  99252. * Unlocks the audio engine once a user action has been done on the dom.
  99253. * This is helpful to resume play once browser policies have been satisfied.
  99254. */
  99255. unlock(): void;
  99256. }
  99257. /**
  99258. * This represents the default audio engine used in babylon.
  99259. * It is responsible to play, synchronize and analyse sounds throughout the application.
  99260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99261. */
  99262. export class AudioEngine implements IAudioEngine {
  99263. private _audioContext;
  99264. private _audioContextInitialized;
  99265. private _muteButton;
  99266. private _hostElement;
  99267. /**
  99268. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  99269. */
  99270. canUseWebAudio: boolean;
  99271. /**
  99272. * The master gain node defines the global audio volume of your audio engine.
  99273. */
  99274. masterGain: GainNode;
  99275. /**
  99276. * Defines if Babylon should emit a warning if WebAudio is not supported.
  99277. * @ignoreNaming
  99278. */
  99279. WarnedWebAudioUnsupported: boolean;
  99280. /**
  99281. * Gets whether or not mp3 are supported by your browser.
  99282. */
  99283. isMP3supported: boolean;
  99284. /**
  99285. * Gets whether or not ogg are supported by your browser.
  99286. */
  99287. isOGGsupported: boolean;
  99288. /**
  99289. * Gets whether audio has been unlocked on the device.
  99290. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  99291. * a user interaction has happened.
  99292. */
  99293. unlocked: boolean;
  99294. /**
  99295. * Defines if the audio engine relies on a custom unlocked button.
  99296. * In this case, the embedded button will not be displayed.
  99297. */
  99298. useCustomUnlockedButton: boolean;
  99299. /**
  99300. * Event raised when audio has been unlocked on the browser.
  99301. */
  99302. onAudioUnlockedObservable: Observable<AudioEngine>;
  99303. /**
  99304. * Event raised when audio has been locked on the browser.
  99305. */
  99306. onAudioLockedObservable: Observable<AudioEngine>;
  99307. /**
  99308. * Gets the current AudioContext if available.
  99309. */
  99310. readonly audioContext: Nullable<AudioContext>;
  99311. private _connectedAnalyser;
  99312. /**
  99313. * Instantiates a new audio engine.
  99314. *
  99315. * There should be only one per page as some browsers restrict the number
  99316. * of audio contexts you can create.
  99317. * @param hostElement defines the host element where to display the mute icon if necessary
  99318. */
  99319. constructor(hostElement?: Nullable<HTMLElement>);
  99320. /**
  99321. * Flags the audio engine in Locked state.
  99322. * This happens due to new browser policies preventing audio to autoplay.
  99323. */
  99324. lock(): void;
  99325. /**
  99326. * Unlocks the audio engine once a user action has been done on the dom.
  99327. * This is helpful to resume play once browser policies have been satisfied.
  99328. */
  99329. unlock(): void;
  99330. private _resumeAudioContext;
  99331. private _initializeAudioContext;
  99332. private _tryToRun;
  99333. private _triggerRunningState;
  99334. private _triggerSuspendedState;
  99335. private _displayMuteButton;
  99336. private _moveButtonToTopLeft;
  99337. private _onResize;
  99338. private _hideMuteButton;
  99339. /**
  99340. * Destroy and release the resources associated with the audio ccontext.
  99341. */
  99342. dispose(): void;
  99343. /**
  99344. * Gets the global volume sets on the master gain.
  99345. * @returns the global volume if set or -1 otherwise
  99346. */
  99347. getGlobalVolume(): number;
  99348. /**
  99349. * Sets the global volume of your experience (sets on the master gain).
  99350. * @param newVolume Defines the new global volume of the application
  99351. */
  99352. setGlobalVolume(newVolume: number): void;
  99353. /**
  99354. * Connect the audio engine to an audio analyser allowing some amazing
  99355. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  99356. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  99357. * @param analyser The analyser to connect to the engine
  99358. */
  99359. connectToAnalyser(analyser: Analyser): void;
  99360. }
  99361. }
  99362. declare module BABYLON {
  99363. /**
  99364. * Interface used to present a loading screen while loading a scene
  99365. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99366. */
  99367. export interface ILoadingScreen {
  99368. /**
  99369. * Function called to display the loading screen
  99370. */
  99371. displayLoadingUI: () => void;
  99372. /**
  99373. * Function called to hide the loading screen
  99374. */
  99375. hideLoadingUI: () => void;
  99376. /**
  99377. * Gets or sets the color to use for the background
  99378. */
  99379. loadingUIBackgroundColor: string;
  99380. /**
  99381. * Gets or sets the text to display while loading
  99382. */
  99383. loadingUIText: string;
  99384. }
  99385. /**
  99386. * Class used for the default loading screen
  99387. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99388. */
  99389. export class DefaultLoadingScreen implements ILoadingScreen {
  99390. private _renderingCanvas;
  99391. private _loadingText;
  99392. private _loadingDivBackgroundColor;
  99393. private _loadingDiv;
  99394. private _loadingTextDiv;
  99395. /** Gets or sets the logo url to use for the default loading screen */
  99396. static DefaultLogoUrl: string;
  99397. /** Gets or sets the spinner url to use for the default loading screen */
  99398. static DefaultSpinnerUrl: string;
  99399. /**
  99400. * Creates a new default loading screen
  99401. * @param _renderingCanvas defines the canvas used to render the scene
  99402. * @param _loadingText defines the default text to display
  99403. * @param _loadingDivBackgroundColor defines the default background color
  99404. */
  99405. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  99406. /**
  99407. * Function called to display the loading screen
  99408. */
  99409. displayLoadingUI(): void;
  99410. /**
  99411. * Function called to hide the loading screen
  99412. */
  99413. hideLoadingUI(): void;
  99414. /**
  99415. * Gets or sets the text to display while loading
  99416. */
  99417. loadingUIText: string;
  99418. /**
  99419. * Gets or sets the color to use for the background
  99420. */
  99421. loadingUIBackgroundColor: string;
  99422. private _resizeLoadingUI;
  99423. }
  99424. }
  99425. declare module BABYLON {
  99426. /**
  99427. * Interface for any object that can request an animation frame
  99428. */
  99429. export interface ICustomAnimationFrameRequester {
  99430. /**
  99431. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  99432. */
  99433. renderFunction?: Function;
  99434. /**
  99435. * Called to request the next frame to render to
  99436. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  99437. */
  99438. requestAnimationFrame: Function;
  99439. /**
  99440. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  99441. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  99442. */
  99443. requestID?: number;
  99444. }
  99445. }
  99446. declare module BABYLON {
  99447. /**
  99448. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  99449. */
  99450. export class PerformanceMonitor {
  99451. private _enabled;
  99452. private _rollingFrameTime;
  99453. private _lastFrameTimeMs;
  99454. /**
  99455. * constructor
  99456. * @param frameSampleSize The number of samples required to saturate the sliding window
  99457. */
  99458. constructor(frameSampleSize?: number);
  99459. /**
  99460. * Samples current frame
  99461. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  99462. */
  99463. sampleFrame(timeMs?: number): void;
  99464. /**
  99465. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99466. */
  99467. readonly averageFrameTime: number;
  99468. /**
  99469. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99470. */
  99471. readonly averageFrameTimeVariance: number;
  99472. /**
  99473. * Returns the frame time of the most recent frame
  99474. */
  99475. readonly instantaneousFrameTime: number;
  99476. /**
  99477. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  99478. */
  99479. readonly averageFPS: number;
  99480. /**
  99481. * Returns the average framerate in frames per second using the most recent frame time
  99482. */
  99483. readonly instantaneousFPS: number;
  99484. /**
  99485. * Returns true if enough samples have been taken to completely fill the sliding window
  99486. */
  99487. readonly isSaturated: boolean;
  99488. /**
  99489. * Enables contributions to the sliding window sample set
  99490. */
  99491. enable(): void;
  99492. /**
  99493. * Disables contributions to the sliding window sample set
  99494. * Samples will not be interpolated over the disabled period
  99495. */
  99496. disable(): void;
  99497. /**
  99498. * Returns true if sampling is enabled
  99499. */
  99500. readonly isEnabled: boolean;
  99501. /**
  99502. * Resets performance monitor
  99503. */
  99504. reset(): void;
  99505. }
  99506. /**
  99507. * RollingAverage
  99508. *
  99509. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  99510. */
  99511. export class RollingAverage {
  99512. /**
  99513. * Current average
  99514. */
  99515. average: number;
  99516. /**
  99517. * Current variance
  99518. */
  99519. variance: number;
  99520. protected _samples: Array<number>;
  99521. protected _sampleCount: number;
  99522. protected _pos: number;
  99523. protected _m2: number;
  99524. /**
  99525. * constructor
  99526. * @param length The number of samples required to saturate the sliding window
  99527. */
  99528. constructor(length: number);
  99529. /**
  99530. * Adds a sample to the sample set
  99531. * @param v The sample value
  99532. */
  99533. add(v: number): void;
  99534. /**
  99535. * Returns previously added values or null if outside of history or outside the sliding window domain
  99536. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  99537. * @return Value previously recorded with add() or null if outside of range
  99538. */
  99539. history(i: number): number;
  99540. /**
  99541. * Returns true if enough samples have been taken to completely fill the sliding window
  99542. * @return true if sample-set saturated
  99543. */
  99544. isSaturated(): boolean;
  99545. /**
  99546. * Resets the rolling average (equivalent to 0 samples taken so far)
  99547. */
  99548. reset(): void;
  99549. /**
  99550. * Wraps a value around the sample range boundaries
  99551. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  99552. * @return Wrapped position in sample range
  99553. */
  99554. protected _wrapPosition(i: number): number;
  99555. }
  99556. }
  99557. declare module BABYLON {
  99558. /**
  99559. * This class is used to track a performance counter which is number based.
  99560. * The user has access to many properties which give statistics of different nature.
  99561. *
  99562. * The implementer can track two kinds of Performance Counter: time and count.
  99563. * 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.
  99564. * 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.
  99565. */
  99566. export class PerfCounter {
  99567. /**
  99568. * Gets or sets a global boolean to turn on and off all the counters
  99569. */
  99570. static Enabled: boolean;
  99571. /**
  99572. * Returns the smallest value ever
  99573. */
  99574. readonly min: number;
  99575. /**
  99576. * Returns the biggest value ever
  99577. */
  99578. readonly max: number;
  99579. /**
  99580. * Returns the average value since the performance counter is running
  99581. */
  99582. readonly average: number;
  99583. /**
  99584. * Returns the average value of the last second the counter was monitored
  99585. */
  99586. readonly lastSecAverage: number;
  99587. /**
  99588. * Returns the current value
  99589. */
  99590. readonly current: number;
  99591. /**
  99592. * Gets the accumulated total
  99593. */
  99594. readonly total: number;
  99595. /**
  99596. * Gets the total value count
  99597. */
  99598. readonly count: number;
  99599. /**
  99600. * Creates a new counter
  99601. */
  99602. constructor();
  99603. /**
  99604. * Call this method to start monitoring a new frame.
  99605. * 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.
  99606. */
  99607. fetchNewFrame(): void;
  99608. /**
  99609. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  99610. * @param newCount the count value to add to the monitored count
  99611. * @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.
  99612. */
  99613. addCount(newCount: number, fetchResult: boolean): void;
  99614. /**
  99615. * Start monitoring this performance counter
  99616. */
  99617. beginMonitoring(): void;
  99618. /**
  99619. * Compute the time lapsed since the previous beginMonitoring() call.
  99620. * @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
  99621. */
  99622. endMonitoring(newFrame?: boolean): void;
  99623. private _fetchResult;
  99624. private _startMonitoringTime;
  99625. private _min;
  99626. private _max;
  99627. private _average;
  99628. private _current;
  99629. private _totalValueCount;
  99630. private _totalAccumulated;
  99631. private _lastSecAverage;
  99632. private _lastSecAccumulated;
  99633. private _lastSecTime;
  99634. private _lastSecValueCount;
  99635. }
  99636. }
  99637. declare module BABYLON {
  99638. /**
  99639. * Defines the interface used by display changed events
  99640. */
  99641. export interface IDisplayChangedEventArgs {
  99642. /** Gets the vrDisplay object (if any) */
  99643. vrDisplay: Nullable<any>;
  99644. /** Gets a boolean indicating if webVR is supported */
  99645. vrSupported: boolean;
  99646. }
  99647. /**
  99648. * Defines the interface used by objects containing a viewport (like a camera)
  99649. */
  99650. interface IViewportOwnerLike {
  99651. /**
  99652. * Gets or sets the viewport
  99653. */
  99654. viewport: IViewportLike;
  99655. }
  99656. /**
  99657. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  99658. */
  99659. export class Engine extends ThinEngine {
  99660. /** Defines that alpha blending is disabled */
  99661. static readonly ALPHA_DISABLE: number;
  99662. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  99663. static readonly ALPHA_ADD: number;
  99664. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  99665. static readonly ALPHA_COMBINE: number;
  99666. /** Defines that alpha blending to DEST - SRC * DEST */
  99667. static readonly ALPHA_SUBTRACT: number;
  99668. /** Defines that alpha blending to SRC * DEST */
  99669. static readonly ALPHA_MULTIPLY: number;
  99670. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  99671. static readonly ALPHA_MAXIMIZED: number;
  99672. /** Defines that alpha blending to SRC + DEST */
  99673. static readonly ALPHA_ONEONE: number;
  99674. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  99675. static readonly ALPHA_PREMULTIPLIED: number;
  99676. /**
  99677. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  99678. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  99679. */
  99680. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  99681. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  99682. static readonly ALPHA_INTERPOLATE: number;
  99683. /**
  99684. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  99685. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  99686. */
  99687. static readonly ALPHA_SCREENMODE: number;
  99688. /** Defines that the ressource is not delayed*/
  99689. static readonly DELAYLOADSTATE_NONE: number;
  99690. /** Defines that the ressource was successfully delay loaded */
  99691. static readonly DELAYLOADSTATE_LOADED: number;
  99692. /** Defines that the ressource is currently delay loading */
  99693. static readonly DELAYLOADSTATE_LOADING: number;
  99694. /** Defines that the ressource is delayed and has not started loading */
  99695. static readonly DELAYLOADSTATE_NOTLOADED: number;
  99696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  99697. static readonly NEVER: number;
  99698. /** 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 */
  99699. static readonly ALWAYS: number;
  99700. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  99701. static readonly LESS: number;
  99702. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  99703. static readonly EQUAL: number;
  99704. /** 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 */
  99705. static readonly LEQUAL: number;
  99706. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  99707. static readonly GREATER: number;
  99708. /** 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 */
  99709. static readonly GEQUAL: number;
  99710. /** 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 */
  99711. static readonly NOTEQUAL: number;
  99712. /** Passed to stencilOperation to specify that stencil value must be kept */
  99713. static readonly KEEP: number;
  99714. /** Passed to stencilOperation to specify that stencil value must be replaced */
  99715. static readonly REPLACE: number;
  99716. /** Passed to stencilOperation to specify that stencil value must be incremented */
  99717. static readonly INCR: number;
  99718. /** Passed to stencilOperation to specify that stencil value must be decremented */
  99719. static readonly DECR: number;
  99720. /** Passed to stencilOperation to specify that stencil value must be inverted */
  99721. static readonly INVERT: number;
  99722. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  99723. static readonly INCR_WRAP: number;
  99724. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  99725. static readonly DECR_WRAP: number;
  99726. /** Texture is not repeating outside of 0..1 UVs */
  99727. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  99728. /** Texture is repeating outside of 0..1 UVs */
  99729. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  99730. /** Texture is repeating and mirrored */
  99731. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  99732. /** ALPHA */
  99733. static readonly TEXTUREFORMAT_ALPHA: number;
  99734. /** LUMINANCE */
  99735. static readonly TEXTUREFORMAT_LUMINANCE: number;
  99736. /** LUMINANCE_ALPHA */
  99737. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  99738. /** RGB */
  99739. static readonly TEXTUREFORMAT_RGB: number;
  99740. /** RGBA */
  99741. static readonly TEXTUREFORMAT_RGBA: number;
  99742. /** RED */
  99743. static readonly TEXTUREFORMAT_RED: number;
  99744. /** RED (2nd reference) */
  99745. static readonly TEXTUREFORMAT_R: number;
  99746. /** RG */
  99747. static readonly TEXTUREFORMAT_RG: number;
  99748. /** RED_INTEGER */
  99749. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  99750. /** RED_INTEGER (2nd reference) */
  99751. static readonly TEXTUREFORMAT_R_INTEGER: number;
  99752. /** RG_INTEGER */
  99753. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  99754. /** RGB_INTEGER */
  99755. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  99756. /** RGBA_INTEGER */
  99757. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  99758. /** UNSIGNED_BYTE */
  99759. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  99760. /** UNSIGNED_BYTE (2nd reference) */
  99761. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  99762. /** FLOAT */
  99763. static readonly TEXTURETYPE_FLOAT: number;
  99764. /** HALF_FLOAT */
  99765. static readonly TEXTURETYPE_HALF_FLOAT: number;
  99766. /** BYTE */
  99767. static readonly TEXTURETYPE_BYTE: number;
  99768. /** SHORT */
  99769. static readonly TEXTURETYPE_SHORT: number;
  99770. /** UNSIGNED_SHORT */
  99771. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  99772. /** INT */
  99773. static readonly TEXTURETYPE_INT: number;
  99774. /** UNSIGNED_INT */
  99775. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  99776. /** UNSIGNED_SHORT_4_4_4_4 */
  99777. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  99778. /** UNSIGNED_SHORT_5_5_5_1 */
  99779. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  99780. /** UNSIGNED_SHORT_5_6_5 */
  99781. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  99782. /** UNSIGNED_INT_2_10_10_10_REV */
  99783. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  99784. /** UNSIGNED_INT_24_8 */
  99785. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  99786. /** UNSIGNED_INT_10F_11F_11F_REV */
  99787. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  99788. /** UNSIGNED_INT_5_9_9_9_REV */
  99789. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  99790. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  99791. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  99792. /** nearest is mag = nearest and min = nearest and mip = linear */
  99793. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  99794. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99795. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  99796. /** Trilinear is mag = linear and min = linear and mip = linear */
  99797. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  99798. /** nearest is mag = nearest and min = nearest and mip = linear */
  99799. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  99800. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99801. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  99802. /** Trilinear is mag = linear and min = linear and mip = linear */
  99803. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  99804. /** mag = nearest and min = nearest and mip = nearest */
  99805. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  99806. /** mag = nearest and min = linear and mip = nearest */
  99807. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  99808. /** mag = nearest and min = linear and mip = linear */
  99809. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  99810. /** mag = nearest and min = linear and mip = none */
  99811. static readonly TEXTURE_NEAREST_LINEAR: number;
  99812. /** mag = nearest and min = nearest and mip = none */
  99813. static readonly TEXTURE_NEAREST_NEAREST: number;
  99814. /** mag = linear and min = nearest and mip = nearest */
  99815. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  99816. /** mag = linear and min = nearest and mip = linear */
  99817. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  99818. /** mag = linear and min = linear and mip = none */
  99819. static readonly TEXTURE_LINEAR_LINEAR: number;
  99820. /** mag = linear and min = nearest and mip = none */
  99821. static readonly TEXTURE_LINEAR_NEAREST: number;
  99822. /** Explicit coordinates mode */
  99823. static readonly TEXTURE_EXPLICIT_MODE: number;
  99824. /** Spherical coordinates mode */
  99825. static readonly TEXTURE_SPHERICAL_MODE: number;
  99826. /** Planar coordinates mode */
  99827. static readonly TEXTURE_PLANAR_MODE: number;
  99828. /** Cubic coordinates mode */
  99829. static readonly TEXTURE_CUBIC_MODE: number;
  99830. /** Projection coordinates mode */
  99831. static readonly TEXTURE_PROJECTION_MODE: number;
  99832. /** Skybox coordinates mode */
  99833. static readonly TEXTURE_SKYBOX_MODE: number;
  99834. /** Inverse Cubic coordinates mode */
  99835. static readonly TEXTURE_INVCUBIC_MODE: number;
  99836. /** Equirectangular coordinates mode */
  99837. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  99838. /** Equirectangular Fixed coordinates mode */
  99839. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  99840. /** Equirectangular Fixed Mirrored coordinates mode */
  99841. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  99842. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  99843. static readonly SCALEMODE_FLOOR: number;
  99844. /** Defines that texture rescaling will look for the nearest power of 2 size */
  99845. static readonly SCALEMODE_NEAREST: number;
  99846. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  99847. static readonly SCALEMODE_CEILING: number;
  99848. /**
  99849. * Returns the current npm package of the sdk
  99850. */
  99851. static readonly NpmPackage: string;
  99852. /**
  99853. * Returns the current version of the framework
  99854. */
  99855. static readonly Version: string;
  99856. /** Gets the list of created engines */
  99857. static readonly Instances: Engine[];
  99858. /**
  99859. * Gets the latest created engine
  99860. */
  99861. static readonly LastCreatedEngine: Nullable<Engine>;
  99862. /**
  99863. * Gets the latest created scene
  99864. */
  99865. static readonly LastCreatedScene: Nullable<Scene>;
  99866. /**
  99867. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  99868. * @param flag defines which part of the materials must be marked as dirty
  99869. * @param predicate defines a predicate used to filter which materials should be affected
  99870. */
  99871. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  99872. /**
  99873. * Method called to create the default loading screen.
  99874. * This can be overriden in your own app.
  99875. * @param canvas The rendering canvas element
  99876. * @returns The loading screen
  99877. */
  99878. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  99879. /**
  99880. * Method called to create the default rescale post process on each engine.
  99881. */
  99882. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  99883. /**
  99884. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  99885. **/
  99886. enableOfflineSupport: boolean;
  99887. /**
  99888. * 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)
  99889. **/
  99890. disableManifestCheck: boolean;
  99891. /**
  99892. * Gets the list of created scenes
  99893. */
  99894. scenes: Scene[];
  99895. /**
  99896. * Event raised when a new scene is created
  99897. */
  99898. onNewSceneAddedObservable: Observable<Scene>;
  99899. /**
  99900. * Gets the list of created postprocesses
  99901. */
  99902. postProcesses: PostProcess[];
  99903. /**
  99904. * Gets a boolean indicating if the pointer is currently locked
  99905. */
  99906. isPointerLock: boolean;
  99907. /**
  99908. * Observable event triggered each time the rendering canvas is resized
  99909. */
  99910. onResizeObservable: Observable<Engine>;
  99911. /**
  99912. * Observable event triggered each time the canvas loses focus
  99913. */
  99914. onCanvasBlurObservable: Observable<Engine>;
  99915. /**
  99916. * Observable event triggered each time the canvas gains focus
  99917. */
  99918. onCanvasFocusObservable: Observable<Engine>;
  99919. /**
  99920. * Observable event triggered each time the canvas receives pointerout event
  99921. */
  99922. onCanvasPointerOutObservable: Observable<PointerEvent>;
  99923. /**
  99924. * Observable raised when the engine begins a new frame
  99925. */
  99926. onBeginFrameObservable: Observable<Engine>;
  99927. /**
  99928. * If set, will be used to request the next animation frame for the render loop
  99929. */
  99930. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  99931. /**
  99932. * Observable raised when the engine ends the current frame
  99933. */
  99934. onEndFrameObservable: Observable<Engine>;
  99935. /**
  99936. * Observable raised when the engine is about to compile a shader
  99937. */
  99938. onBeforeShaderCompilationObservable: Observable<Engine>;
  99939. /**
  99940. * Observable raised when the engine has jsut compiled a shader
  99941. */
  99942. onAfterShaderCompilationObservable: Observable<Engine>;
  99943. /**
  99944. * Gets the audio engine
  99945. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99946. * @ignorenaming
  99947. */
  99948. static audioEngine: IAudioEngine;
  99949. /**
  99950. * Default AudioEngine factory responsible of creating the Audio Engine.
  99951. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  99952. */
  99953. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  99954. /**
  99955. * Default offline support factory responsible of creating a tool used to store data locally.
  99956. * By default, this will create a Database object if the workload has been embedded.
  99957. */
  99958. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  99959. private _loadingScreen;
  99960. private _pointerLockRequested;
  99961. private _dummyFramebuffer;
  99962. private _rescalePostProcess;
  99963. /** @hidden */
  99964. protected _alphaMode: number;
  99965. /** @hidden */
  99966. protected _alphaEquation: number;
  99967. private _deterministicLockstep;
  99968. private _lockstepMaxSteps;
  99969. protected readonly _supportsHardwareTextureRescaling: boolean;
  99970. private _fps;
  99971. private _deltaTime;
  99972. /** @hidden */
  99973. _drawCalls: PerfCounter;
  99974. /**
  99975. * Turn this value on if you want to pause FPS computation when in background
  99976. */
  99977. disablePerformanceMonitorInBackground: boolean;
  99978. private _performanceMonitor;
  99979. /**
  99980. * Gets the performance monitor attached to this engine
  99981. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99982. */
  99983. readonly performanceMonitor: PerformanceMonitor;
  99984. private _onFocus;
  99985. private _onBlur;
  99986. private _onCanvasPointerOut;
  99987. private _onCanvasBlur;
  99988. private _onCanvasFocus;
  99989. private _onFullscreenChange;
  99990. private _onPointerLockChange;
  99991. /**
  99992. * Gets the HTML element used to attach event listeners
  99993. * @returns a HTML element
  99994. */
  99995. getInputElement(): Nullable<HTMLElement>;
  99996. /**
  99997. * Creates a new engine
  99998. * @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
  99999. * @param antialias defines enable antialiasing (default: false)
  100000. * @param options defines further options to be sent to the getContext() function
  100001. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  100002. */
  100003. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  100004. /**
  100005. * Gets current aspect ratio
  100006. * @param viewportOwner defines the camera to use to get the aspect ratio
  100007. * @param useScreen defines if screen size must be used (or the current render target if any)
  100008. * @returns a number defining the aspect ratio
  100009. */
  100010. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  100011. /**
  100012. * Gets current screen aspect ratio
  100013. * @returns a number defining the aspect ratio
  100014. */
  100015. getScreenAspectRatio(): number;
  100016. /**
  100017. * Gets host document
  100018. * @returns the host document object
  100019. */
  100020. getHostDocument(): Document;
  100021. /**
  100022. * Gets the client rect of the HTML canvas attached with the current webGL context
  100023. * @returns a client rectanglee
  100024. */
  100025. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  100026. /**
  100027. * Gets the client rect of the HTML element used for events
  100028. * @returns a client rectanglee
  100029. */
  100030. getInputElementClientRect(): Nullable<ClientRect>;
  100031. /**
  100032. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  100033. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100034. * @returns true if engine is in deterministic lock step mode
  100035. */
  100036. isDeterministicLockStep(): boolean;
  100037. /**
  100038. * Gets the max steps when engine is running in deterministic lock step
  100039. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100040. * @returns the max steps
  100041. */
  100042. getLockstepMaxSteps(): number;
  100043. /**
  100044. * Force the mipmap generation for the given render target texture
  100045. * @param texture defines the render target texture to use
  100046. */
  100047. generateMipMapsForCubemap(texture: InternalTexture): void;
  100048. /** States */
  100049. /**
  100050. * Set various states to the webGL context
  100051. * @param culling defines backface culling state
  100052. * @param zOffset defines the value to apply to zOffset (0 by default)
  100053. * @param force defines if states must be applied even if cache is up to date
  100054. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  100055. */
  100056. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  100057. /**
  100058. * Set the z offset to apply to current rendering
  100059. * @param value defines the offset to apply
  100060. */
  100061. setZOffset(value: number): void;
  100062. /**
  100063. * Gets the current value of the zOffset
  100064. * @returns the current zOffset state
  100065. */
  100066. getZOffset(): number;
  100067. /**
  100068. * Enable or disable depth buffering
  100069. * @param enable defines the state to set
  100070. */
  100071. setDepthBuffer(enable: boolean): void;
  100072. /**
  100073. * Gets a boolean indicating if depth writing is enabled
  100074. * @returns the current depth writing state
  100075. */
  100076. getDepthWrite(): boolean;
  100077. /**
  100078. * Enable or disable depth writing
  100079. * @param enable defines the state to set
  100080. */
  100081. setDepthWrite(enable: boolean): void;
  100082. /**
  100083. * Enable or disable color writing
  100084. * @param enable defines the state to set
  100085. */
  100086. setColorWrite(enable: boolean): void;
  100087. /**
  100088. * Gets a boolean indicating if color writing is enabled
  100089. * @returns the current color writing state
  100090. */
  100091. getColorWrite(): boolean;
  100092. /**
  100093. * Sets alpha constants used by some alpha blending modes
  100094. * @param r defines the red component
  100095. * @param g defines the green component
  100096. * @param b defines the blue component
  100097. * @param a defines the alpha component
  100098. */
  100099. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  100100. /**
  100101. * Sets the current alpha mode
  100102. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  100103. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  100104. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  100105. */
  100106. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  100107. /**
  100108. * Gets the current alpha mode
  100109. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  100110. * @returns the current alpha mode
  100111. */
  100112. getAlphaMode(): number;
  100113. /**
  100114. * Sets the current alpha equation
  100115. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  100116. */
  100117. setAlphaEquation(equation: number): void;
  100118. /**
  100119. * Gets the current alpha equation.
  100120. * @returns the current alpha equation
  100121. */
  100122. getAlphaEquation(): number;
  100123. /**
  100124. * Gets a boolean indicating if stencil buffer is enabled
  100125. * @returns the current stencil buffer state
  100126. */
  100127. getStencilBuffer(): boolean;
  100128. /**
  100129. * Enable or disable the stencil buffer
  100130. * @param enable defines if the stencil buffer must be enabled or disabled
  100131. */
  100132. setStencilBuffer(enable: boolean): void;
  100133. /**
  100134. * Gets the current stencil mask
  100135. * @returns a number defining the new stencil mask to use
  100136. */
  100137. getStencilMask(): number;
  100138. /**
  100139. * Sets the current stencil mask
  100140. * @param mask defines the new stencil mask to use
  100141. */
  100142. setStencilMask(mask: number): void;
  100143. /**
  100144. * Gets the current stencil function
  100145. * @returns a number defining the stencil function to use
  100146. */
  100147. getStencilFunction(): number;
  100148. /**
  100149. * Gets the current stencil reference value
  100150. * @returns a number defining the stencil reference value to use
  100151. */
  100152. getStencilFunctionReference(): number;
  100153. /**
  100154. * Gets the current stencil mask
  100155. * @returns a number defining the stencil mask to use
  100156. */
  100157. getStencilFunctionMask(): number;
  100158. /**
  100159. * Sets the current stencil function
  100160. * @param stencilFunc defines the new stencil function to use
  100161. */
  100162. setStencilFunction(stencilFunc: number): void;
  100163. /**
  100164. * Sets the current stencil reference
  100165. * @param reference defines the new stencil reference to use
  100166. */
  100167. setStencilFunctionReference(reference: number): void;
  100168. /**
  100169. * Sets the current stencil mask
  100170. * @param mask defines the new stencil mask to use
  100171. */
  100172. setStencilFunctionMask(mask: number): void;
  100173. /**
  100174. * Gets the current stencil operation when stencil fails
  100175. * @returns a number defining stencil operation to use when stencil fails
  100176. */
  100177. getStencilOperationFail(): number;
  100178. /**
  100179. * Gets the current stencil operation when depth fails
  100180. * @returns a number defining stencil operation to use when depth fails
  100181. */
  100182. getStencilOperationDepthFail(): number;
  100183. /**
  100184. * Gets the current stencil operation when stencil passes
  100185. * @returns a number defining stencil operation to use when stencil passes
  100186. */
  100187. getStencilOperationPass(): number;
  100188. /**
  100189. * Sets the stencil operation to use when stencil fails
  100190. * @param operation defines the stencil operation to use when stencil fails
  100191. */
  100192. setStencilOperationFail(operation: number): void;
  100193. /**
  100194. * Sets the stencil operation to use when depth fails
  100195. * @param operation defines the stencil operation to use when depth fails
  100196. */
  100197. setStencilOperationDepthFail(operation: number): void;
  100198. /**
  100199. * Sets the stencil operation to use when stencil passes
  100200. * @param operation defines the stencil operation to use when stencil passes
  100201. */
  100202. setStencilOperationPass(operation: number): void;
  100203. /**
  100204. * Sets a boolean indicating if the dithering state is enabled or disabled
  100205. * @param value defines the dithering state
  100206. */
  100207. setDitheringState(value: boolean): void;
  100208. /**
  100209. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  100210. * @param value defines the rasterizer state
  100211. */
  100212. setRasterizerState(value: boolean): void;
  100213. /**
  100214. * Gets the current depth function
  100215. * @returns a number defining the depth function
  100216. */
  100217. getDepthFunction(): Nullable<number>;
  100218. /**
  100219. * Sets the current depth function
  100220. * @param depthFunc defines the function to use
  100221. */
  100222. setDepthFunction(depthFunc: number): void;
  100223. /**
  100224. * Sets the current depth function to GREATER
  100225. */
  100226. setDepthFunctionToGreater(): void;
  100227. /**
  100228. * Sets the current depth function to GEQUAL
  100229. */
  100230. setDepthFunctionToGreaterOrEqual(): void;
  100231. /**
  100232. * Sets the current depth function to LESS
  100233. */
  100234. setDepthFunctionToLess(): void;
  100235. /**
  100236. * Sets the current depth function to LEQUAL
  100237. */
  100238. setDepthFunctionToLessOrEqual(): void;
  100239. private _cachedStencilBuffer;
  100240. private _cachedStencilFunction;
  100241. private _cachedStencilMask;
  100242. private _cachedStencilOperationPass;
  100243. private _cachedStencilOperationFail;
  100244. private _cachedStencilOperationDepthFail;
  100245. private _cachedStencilReference;
  100246. /**
  100247. * Caches the the state of the stencil buffer
  100248. */
  100249. cacheStencilState(): void;
  100250. /**
  100251. * Restores the state of the stencil buffer
  100252. */
  100253. restoreStencilState(): void;
  100254. /**
  100255. * Directly set the WebGL Viewport
  100256. * @param x defines the x coordinate of the viewport (in screen space)
  100257. * @param y defines the y coordinate of the viewport (in screen space)
  100258. * @param width defines the width of the viewport (in screen space)
  100259. * @param height defines the height of the viewport (in screen space)
  100260. * @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
  100261. */
  100262. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  100263. /**
  100264. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  100265. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  100266. * @param y defines the y-coordinate of the corner of the clear rectangle
  100267. * @param width defines the width of the clear rectangle
  100268. * @param height defines the height of the clear rectangle
  100269. * @param clearColor defines the clear color
  100270. */
  100271. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  100272. /**
  100273. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  100274. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  100275. * @param y defines the y-coordinate of the corner of the clear rectangle
  100276. * @param width defines the width of the clear rectangle
  100277. * @param height defines the height of the clear rectangle
  100278. */
  100279. enableScissor(x: number, y: number, width: number, height: number): void;
  100280. /**
  100281. * Disable previously set scissor test rectangle
  100282. */
  100283. disableScissor(): void;
  100284. protected _reportDrawCall(): void;
  100285. /**
  100286. * Initializes a webVR display and starts listening to display change events
  100287. * The onVRDisplayChangedObservable will be notified upon these changes
  100288. * @returns The onVRDisplayChangedObservable
  100289. */
  100290. initWebVR(): Observable<IDisplayChangedEventArgs>;
  100291. /** @hidden */
  100292. _prepareVRComponent(): void;
  100293. /** @hidden */
  100294. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  100295. /** @hidden */
  100296. _submitVRFrame(): void;
  100297. /**
  100298. * Call this function to leave webVR mode
  100299. * Will do nothing if webVR is not supported or if there is no webVR device
  100300. * @see http://doc.babylonjs.com/how_to/webvr_camera
  100301. */
  100302. disableVR(): void;
  100303. /**
  100304. * Gets a boolean indicating that the system is in VR mode and is presenting
  100305. * @returns true if VR mode is engaged
  100306. */
  100307. isVRPresenting(): boolean;
  100308. /** @hidden */
  100309. _requestVRFrame(): void;
  100310. /** @hidden */
  100311. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  100312. /**
  100313. * Gets the source code of the vertex shader associated with a specific webGL program
  100314. * @param program defines the program to use
  100315. * @returns a string containing the source code of the vertex shader associated with the program
  100316. */
  100317. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  100318. /**
  100319. * Gets the source code of the fragment shader associated with a specific webGL program
  100320. * @param program defines the program to use
  100321. * @returns a string containing the source code of the fragment shader associated with the program
  100322. */
  100323. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  100324. /**
  100325. * Reads pixels from the current frame buffer. Please note that this function can be slow
  100326. * @param x defines the x coordinate of the rectangle where pixels must be read
  100327. * @param y defines the y coordinate of the rectangle where pixels must be read
  100328. * @param width defines the width of the rectangle where pixels must be read
  100329. * @param height defines the height of the rectangle where pixels must be read
  100330. * @returns a Uint8Array containing RGBA colors
  100331. */
  100332. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  100333. /**
  100334. * Sets a depth stencil texture from a render target to the according uniform.
  100335. * @param channel The texture channel
  100336. * @param uniform The uniform to set
  100337. * @param texture The render target texture containing the depth stencil texture to apply
  100338. */
  100339. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  100340. /**
  100341. * Sets a texture to the webGL context from a postprocess
  100342. * @param channel defines the channel to use
  100343. * @param postProcess defines the source postprocess
  100344. */
  100345. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  100346. /**
  100347. * Binds the output of the passed in post process to the texture channel specified
  100348. * @param channel The channel the texture should be bound to
  100349. * @param postProcess The post process which's output should be bound
  100350. */
  100351. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  100352. /** @hidden */
  100353. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  100354. protected _rebuildBuffers(): void;
  100355. /** @hidden */
  100356. _renderFrame(): void;
  100357. _renderLoop(): void;
  100358. /** @hidden */
  100359. _renderViews(): boolean;
  100360. /**
  100361. * Toggle full screen mode
  100362. * @param requestPointerLock defines if a pointer lock should be requested from the user
  100363. */
  100364. switchFullscreen(requestPointerLock: boolean): void;
  100365. /**
  100366. * Enters full screen mode
  100367. * @param requestPointerLock defines if a pointer lock should be requested from the user
  100368. */
  100369. enterFullscreen(requestPointerLock: boolean): void;
  100370. /**
  100371. * Exits full screen mode
  100372. */
  100373. exitFullscreen(): void;
  100374. /**
  100375. * Enters Pointerlock mode
  100376. */
  100377. enterPointerlock(): void;
  100378. /**
  100379. * Exits Pointerlock mode
  100380. */
  100381. exitPointerlock(): void;
  100382. /**
  100383. * Begin a new frame
  100384. */
  100385. beginFrame(): void;
  100386. /**
  100387. * Enf the current frame
  100388. */
  100389. endFrame(): void;
  100390. resize(): void;
  100391. /**
  100392. * Set the compressed texture format to use, based on the formats you have, and the formats
  100393. * supported by the hardware / browser.
  100394. *
  100395. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  100396. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  100397. * to API arguments needed to compressed textures. This puts the burden on the container
  100398. * generator to house the arcane code for determining these for current & future formats.
  100399. *
  100400. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  100401. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  100402. *
  100403. * Note: The result of this call is not taken into account when a texture is base64.
  100404. *
  100405. * @param formatsAvailable defines the list of those format families you have created
  100406. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  100407. *
  100408. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  100409. * @returns The extension selected.
  100410. */
  100411. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  100412. /**
  100413. * Force a specific size of the canvas
  100414. * @param width defines the new canvas' width
  100415. * @param height defines the new canvas' height
  100416. */
  100417. setSize(width: number, height: number): void;
  100418. /**
  100419. * Updates a dynamic vertex buffer.
  100420. * @param vertexBuffer the vertex buffer to update
  100421. * @param data the data used to update the vertex buffer
  100422. * @param byteOffset the byte offset of the data
  100423. * @param byteLength the byte length of the data
  100424. */
  100425. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  100426. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  100427. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100428. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100429. _releaseTexture(texture: InternalTexture): void;
  100430. /**
  100431. * @hidden
  100432. * Rescales a texture
  100433. * @param source input texutre
  100434. * @param destination destination texture
  100435. * @param scene scene to use to render the resize
  100436. * @param internalFormat format to use when resizing
  100437. * @param onComplete callback to be called when resize has completed
  100438. */
  100439. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  100440. /**
  100441. * Gets the current framerate
  100442. * @returns a number representing the framerate
  100443. */
  100444. getFps(): number;
  100445. /**
  100446. * Gets the time spent between current and previous frame
  100447. * @returns a number representing the delta time in ms
  100448. */
  100449. getDeltaTime(): number;
  100450. private _measureFps;
  100451. /** @hidden */
  100452. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  100453. /**
  100454. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  100455. * @param renderTarget The render target to set the frame buffer for
  100456. */
  100457. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  100458. /**
  100459. * Update a dynamic index buffer
  100460. * @param indexBuffer defines the target index buffer
  100461. * @param indices defines the data to update
  100462. * @param offset defines the offset in the target index buffer where update should start
  100463. */
  100464. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  100465. /**
  100466. * Updates the sample count of a render target texture
  100467. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  100468. * @param texture defines the texture to update
  100469. * @param samples defines the sample count to set
  100470. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  100471. */
  100472. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  100473. /**
  100474. * Updates a depth texture Comparison Mode and Function.
  100475. * If the comparison Function is equal to 0, the mode will be set to none.
  100476. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  100477. * @param texture The texture to set the comparison function for
  100478. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  100479. */
  100480. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  100481. /**
  100482. * Creates a webGL buffer to use with instanciation
  100483. * @param capacity defines the size of the buffer
  100484. * @returns the webGL buffer
  100485. */
  100486. createInstancesBuffer(capacity: number): DataBuffer;
  100487. /**
  100488. * Delete a webGL buffer used with instanciation
  100489. * @param buffer defines the webGL buffer to delete
  100490. */
  100491. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  100492. /** @hidden */
  100493. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  100494. dispose(): void;
  100495. private _disableTouchAction;
  100496. /**
  100497. * Display the loading screen
  100498. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100499. */
  100500. displayLoadingUI(): void;
  100501. /**
  100502. * Hide the loading screen
  100503. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100504. */
  100505. hideLoadingUI(): void;
  100506. /**
  100507. * Gets the current loading screen object
  100508. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100509. */
  100510. /**
  100511. * Sets the current loading screen object
  100512. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100513. */
  100514. loadingScreen: ILoadingScreen;
  100515. /**
  100516. * Sets the current loading screen text
  100517. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100518. */
  100519. loadingUIText: string;
  100520. /**
  100521. * Sets the current loading screen background color
  100522. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100523. */
  100524. loadingUIBackgroundColor: string;
  100525. /** Pointerlock and fullscreen */
  100526. /**
  100527. * Ask the browser to promote the current element to pointerlock mode
  100528. * @param element defines the DOM element to promote
  100529. */
  100530. static _RequestPointerlock(element: HTMLElement): void;
  100531. /**
  100532. * Asks the browser to exit pointerlock mode
  100533. */
  100534. static _ExitPointerlock(): void;
  100535. /**
  100536. * Ask the browser to promote the current element to fullscreen rendering mode
  100537. * @param element defines the DOM element to promote
  100538. */
  100539. static _RequestFullscreen(element: HTMLElement): void;
  100540. /**
  100541. * Asks the browser to exit fullscreen mode
  100542. */
  100543. static _ExitFullscreen(): void;
  100544. }
  100545. }
  100546. declare module BABYLON {
  100547. /**
  100548. * The engine store class is responsible to hold all the instances of Engine and Scene created
  100549. * during the life time of the application.
  100550. */
  100551. export class EngineStore {
  100552. /** Gets the list of created engines */
  100553. static Instances: Engine[];
  100554. /** @hidden */
  100555. static _LastCreatedScene: Nullable<Scene>;
  100556. /**
  100557. * Gets the latest created engine
  100558. */
  100559. static readonly LastCreatedEngine: Nullable<Engine>;
  100560. /**
  100561. * Gets the latest created scene
  100562. */
  100563. static readonly LastCreatedScene: Nullable<Scene>;
  100564. /**
  100565. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100566. * @ignorenaming
  100567. */
  100568. static UseFallbackTexture: boolean;
  100569. /**
  100570. * Texture content used if a texture cannot loaded
  100571. * @ignorenaming
  100572. */
  100573. static FallbackTexture: string;
  100574. }
  100575. }
  100576. declare module BABYLON {
  100577. /**
  100578. * Helper class that provides a small promise polyfill
  100579. */
  100580. export class PromisePolyfill {
  100581. /**
  100582. * Static function used to check if the polyfill is required
  100583. * If this is the case then the function will inject the polyfill to window.Promise
  100584. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  100585. */
  100586. static Apply(force?: boolean): void;
  100587. }
  100588. }
  100589. declare module BABYLON {
  100590. /**
  100591. * Interface for screenshot methods with describe argument called `size` as object with options
  100592. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  100593. */
  100594. export interface IScreenshotSize {
  100595. /**
  100596. * number in pixels for canvas height
  100597. */
  100598. height?: number;
  100599. /**
  100600. * multiplier allowing render at a higher or lower resolution
  100601. * If value is defined then height and width will be ignored and taken from camera
  100602. */
  100603. precision?: number;
  100604. /**
  100605. * number in pixels for canvas width
  100606. */
  100607. width?: number;
  100608. }
  100609. }
  100610. declare module BABYLON {
  100611. interface IColor4Like {
  100612. r: float;
  100613. g: float;
  100614. b: float;
  100615. a: float;
  100616. }
  100617. /**
  100618. * Class containing a set of static utilities functions
  100619. */
  100620. export class Tools {
  100621. /**
  100622. * Gets or sets the base URL to use to load assets
  100623. */
  100624. static BaseUrl: string;
  100625. /**
  100626. * Enable/Disable Custom HTTP Request Headers globally.
  100627. * default = false
  100628. * @see CustomRequestHeaders
  100629. */
  100630. static UseCustomRequestHeaders: boolean;
  100631. /**
  100632. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  100633. * i.e. when loading files, where the server/service expects an Authorization header
  100634. */
  100635. static CustomRequestHeaders: {
  100636. [key: string]: string;
  100637. };
  100638. /**
  100639. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  100640. */
  100641. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  100642. /**
  100643. * Default behaviour for cors in the application.
  100644. * It can be a string if the expected behavior is identical in the entire app.
  100645. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  100646. */
  100647. static CorsBehavior: string | ((url: string | string[]) => string);
  100648. /**
  100649. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100650. * @ignorenaming
  100651. */
  100652. static UseFallbackTexture: boolean;
  100653. /**
  100654. * Use this object to register external classes like custom textures or material
  100655. * to allow the laoders to instantiate them
  100656. */
  100657. static RegisteredExternalClasses: {
  100658. [key: string]: Object;
  100659. };
  100660. /**
  100661. * Texture content used if a texture cannot loaded
  100662. * @ignorenaming
  100663. */
  100664. static fallbackTexture: string;
  100665. /**
  100666. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  100667. * @param u defines the coordinate on X axis
  100668. * @param v defines the coordinate on Y axis
  100669. * @param width defines the width of the source data
  100670. * @param height defines the height of the source data
  100671. * @param pixels defines the source byte array
  100672. * @param color defines the output color
  100673. */
  100674. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  100675. /**
  100676. * Interpolates between a and b via alpha
  100677. * @param a The lower value (returned when alpha = 0)
  100678. * @param b The upper value (returned when alpha = 1)
  100679. * @param alpha The interpolation-factor
  100680. * @return The mixed value
  100681. */
  100682. static Mix(a: number, b: number, alpha: number): number;
  100683. /**
  100684. * Tries to instantiate a new object from a given class name
  100685. * @param className defines the class name to instantiate
  100686. * @returns the new object or null if the system was not able to do the instantiation
  100687. */
  100688. static Instantiate(className: string): any;
  100689. /**
  100690. * Provides a slice function that will work even on IE
  100691. * @param data defines the array to slice
  100692. * @param start defines the start of the data (optional)
  100693. * @param end defines the end of the data (optional)
  100694. * @returns the new sliced array
  100695. */
  100696. static Slice<T>(data: T, start?: number, end?: number): T;
  100697. /**
  100698. * Polyfill for setImmediate
  100699. * @param action defines the action to execute after the current execution block
  100700. */
  100701. static SetImmediate(action: () => void): void;
  100702. /**
  100703. * Function indicating if a number is an exponent of 2
  100704. * @param value defines the value to test
  100705. * @returns true if the value is an exponent of 2
  100706. */
  100707. static IsExponentOfTwo(value: number): boolean;
  100708. private static _tmpFloatArray;
  100709. /**
  100710. * Returns the nearest 32-bit single precision float representation of a Number
  100711. * @param value A Number. If the parameter is of a different type, it will get converted
  100712. * to a number or to NaN if it cannot be converted
  100713. * @returns number
  100714. */
  100715. static FloatRound(value: number): number;
  100716. /**
  100717. * Extracts the filename from a path
  100718. * @param path defines the path to use
  100719. * @returns the filename
  100720. */
  100721. static GetFilename(path: string): string;
  100722. /**
  100723. * Extracts the "folder" part of a path (everything before the filename).
  100724. * @param uri The URI to extract the info from
  100725. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  100726. * @returns The "folder" part of the path
  100727. */
  100728. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  100729. /**
  100730. * Extracts text content from a DOM element hierarchy
  100731. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  100732. */
  100733. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  100734. /**
  100735. * Convert an angle in radians to degrees
  100736. * @param angle defines the angle to convert
  100737. * @returns the angle in degrees
  100738. */
  100739. static ToDegrees(angle: number): number;
  100740. /**
  100741. * Convert an angle in degrees to radians
  100742. * @param angle defines the angle to convert
  100743. * @returns the angle in radians
  100744. */
  100745. static ToRadians(angle: number): number;
  100746. /**
  100747. * Returns an array if obj is not an array
  100748. * @param obj defines the object to evaluate as an array
  100749. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  100750. * @returns either obj directly if obj is an array or a new array containing obj
  100751. */
  100752. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  100753. /**
  100754. * Gets the pointer prefix to use
  100755. * @returns "pointer" if touch is enabled. Else returns "mouse"
  100756. */
  100757. static GetPointerPrefix(): string;
  100758. /**
  100759. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  100760. * @param url define the url we are trying
  100761. * @param element define the dom element where to configure the cors policy
  100762. */
  100763. static SetCorsBehavior(url: string | string[], element: {
  100764. crossOrigin: string | null;
  100765. }): void;
  100766. /**
  100767. * Removes unwanted characters from an url
  100768. * @param url defines the url to clean
  100769. * @returns the cleaned url
  100770. */
  100771. static CleanUrl(url: string): string;
  100772. /**
  100773. * Gets or sets a function used to pre-process url before using them to load assets
  100774. */
  100775. static PreprocessUrl: (url: string) => string;
  100776. /**
  100777. * Loads an image as an HTMLImageElement.
  100778. * @param input url string, ArrayBuffer, or Blob to load
  100779. * @param onLoad callback called when the image successfully loads
  100780. * @param onError callback called when the image fails to load
  100781. * @param offlineProvider offline provider for caching
  100782. * @param mimeType optional mime type
  100783. * @returns the HTMLImageElement of the loaded image
  100784. */
  100785. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  100786. /**
  100787. * Loads a file from a url
  100788. * @param url url string, ArrayBuffer, or Blob to load
  100789. * @param onSuccess callback called when the file successfully loads
  100790. * @param onProgress callback called while file is loading (if the server supports this mode)
  100791. * @param offlineProvider defines the offline provider for caching
  100792. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  100793. * @param onError callback called when the file fails to load
  100794. * @returns a file request object
  100795. */
  100796. 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;
  100797. /**
  100798. * Loads a file from a url
  100799. * @param url the file url to load
  100800. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  100801. */
  100802. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  100803. /**
  100804. * Load a script (identified by an url). When the url returns, the
  100805. * content of this file is added into a new script element, attached to the DOM (body element)
  100806. * @param scriptUrl defines the url of the script to laod
  100807. * @param onSuccess defines the callback called when the script is loaded
  100808. * @param onError defines the callback to call if an error occurs
  100809. * @param scriptId defines the id of the script element
  100810. */
  100811. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  100812. /**
  100813. * Load an asynchronous script (identified by an url). When the url returns, the
  100814. * content of this file is added into a new script element, attached to the DOM (body element)
  100815. * @param scriptUrl defines the url of the script to laod
  100816. * @param scriptId defines the id of the script element
  100817. * @returns a promise request object
  100818. */
  100819. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  100820. /**
  100821. * Loads a file from a blob
  100822. * @param fileToLoad defines the blob to use
  100823. * @param callback defines the callback to call when data is loaded
  100824. * @param progressCallback defines the callback to call during loading process
  100825. * @returns a file request object
  100826. */
  100827. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  100828. /**
  100829. * Reads a file from a File object
  100830. * @param file defines the file to load
  100831. * @param onSuccess defines the callback to call when data is loaded
  100832. * @param onProgress defines the callback to call during loading process
  100833. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  100834. * @param onError defines the callback to call when an error occurs
  100835. * @returns a file request object
  100836. */
  100837. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  100838. /**
  100839. * Creates a data url from a given string content
  100840. * @param content defines the content to convert
  100841. * @returns the new data url link
  100842. */
  100843. static FileAsURL(content: string): string;
  100844. /**
  100845. * Format the given number to a specific decimal format
  100846. * @param value defines the number to format
  100847. * @param decimals defines the number of decimals to use
  100848. * @returns the formatted string
  100849. */
  100850. static Format(value: number, decimals?: number): string;
  100851. /**
  100852. * Tries to copy an object by duplicating every property
  100853. * @param source defines the source object
  100854. * @param destination defines the target object
  100855. * @param doNotCopyList defines a list of properties to avoid
  100856. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  100857. */
  100858. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  100859. /**
  100860. * Gets a boolean indicating if the given object has no own property
  100861. * @param obj defines the object to test
  100862. * @returns true if object has no own property
  100863. */
  100864. static IsEmpty(obj: any): boolean;
  100865. /**
  100866. * Function used to register events at window level
  100867. * @param windowElement defines the Window object to use
  100868. * @param events defines the events to register
  100869. */
  100870. static RegisterTopRootEvents(windowElement: Window, events: {
  100871. name: string;
  100872. handler: Nullable<(e: FocusEvent) => any>;
  100873. }[]): void;
  100874. /**
  100875. * Function used to unregister events from window level
  100876. * @param windowElement defines the Window object to use
  100877. * @param events defines the events to unregister
  100878. */
  100879. static UnregisterTopRootEvents(windowElement: Window, events: {
  100880. name: string;
  100881. handler: Nullable<(e: FocusEvent) => any>;
  100882. }[]): void;
  100883. /**
  100884. * @ignore
  100885. */
  100886. static _ScreenshotCanvas: HTMLCanvasElement;
  100887. /**
  100888. * Dumps the current bound framebuffer
  100889. * @param width defines the rendering width
  100890. * @param height defines the rendering height
  100891. * @param engine defines the hosting engine
  100892. * @param successCallback defines the callback triggered once the data are available
  100893. * @param mimeType defines the mime type of the result
  100894. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  100895. */
  100896. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  100897. /**
  100898. * Converts the canvas data to blob.
  100899. * This acts as a polyfill for browsers not supporting the to blob function.
  100900. * @param canvas Defines the canvas to extract the data from
  100901. * @param successCallback Defines the callback triggered once the data are available
  100902. * @param mimeType Defines the mime type of the result
  100903. */
  100904. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  100905. /**
  100906. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  100907. * @param successCallback defines the callback triggered once the data are available
  100908. * @param mimeType defines the mime type of the result
  100909. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  100910. */
  100911. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  100912. /**
  100913. * Downloads a blob in the browser
  100914. * @param blob defines the blob to download
  100915. * @param fileName defines the name of the downloaded file
  100916. */
  100917. static Download(blob: Blob, fileName: string): void;
  100918. /**
  100919. * Captures a screenshot of the current rendering
  100920. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100921. * @param engine defines the rendering engine
  100922. * @param camera defines the source camera
  100923. * @param size This parameter can be set to a single number or to an object with the
  100924. * following (optional) properties: precision, width, height. If a single number is passed,
  100925. * it will be used for both width and height. If an object is passed, the screenshot size
  100926. * will be derived from the parameters. The precision property is a multiplier allowing
  100927. * rendering at a higher or lower resolution
  100928. * @param successCallback defines the callback receives a single parameter which contains the
  100929. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100930. * src parameter of an <img> to display it
  100931. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100932. * Check your browser for supported MIME types
  100933. */
  100934. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  100935. /**
  100936. * Captures a screenshot of the current rendering
  100937. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100938. * @param engine defines the rendering engine
  100939. * @param camera defines the source camera
  100940. * @param size This parameter can be set to a single number or to an object with the
  100941. * following (optional) properties: precision, width, height. If a single number is passed,
  100942. * it will be used for both width and height. If an object is passed, the screenshot size
  100943. * will be derived from the parameters. The precision property is a multiplier allowing
  100944. * rendering at a higher or lower resolution
  100945. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100946. * Check your browser for supported MIME types
  100947. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100948. * to the src parameter of an <img> to display it
  100949. */
  100950. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  100951. /**
  100952. * Generates an image screenshot from the specified camera.
  100953. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100954. * @param engine The engine to use for rendering
  100955. * @param camera The camera to use for rendering
  100956. * @param size This parameter can be set to a single number or to an object with the
  100957. * following (optional) properties: precision, width, height. If a single number is passed,
  100958. * it will be used for both width and height. If an object is passed, the screenshot size
  100959. * will be derived from the parameters. The precision property is a multiplier allowing
  100960. * rendering at a higher or lower resolution
  100961. * @param successCallback The callback receives a single parameter which contains the
  100962. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100963. * src parameter of an <img> to display it
  100964. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100965. * Check your browser for supported MIME types
  100966. * @param samples Texture samples (default: 1)
  100967. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100968. * @param fileName A name for for the downloaded file.
  100969. */
  100970. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  100971. /**
  100972. * Generates an image screenshot from the specified camera.
  100973. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100974. * @param engine The engine to use for rendering
  100975. * @param camera The camera to use for rendering
  100976. * @param size This parameter can be set to a single number or to an object with the
  100977. * following (optional) properties: precision, width, height. If a single number is passed,
  100978. * it will be used for both width and height. If an object is passed, the screenshot size
  100979. * will be derived from the parameters. The precision property is a multiplier allowing
  100980. * rendering at a higher or lower resolution
  100981. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100982. * Check your browser for supported MIME types
  100983. * @param samples Texture samples (default: 1)
  100984. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100985. * @param fileName A name for for the downloaded file.
  100986. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100987. * to the src parameter of an <img> to display it
  100988. */
  100989. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  100990. /**
  100991. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100992. * Be aware Math.random() could cause collisions, but:
  100993. * "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"
  100994. * @returns a pseudo random id
  100995. */
  100996. static RandomId(): string;
  100997. /**
  100998. * Test if the given uri is a base64 string
  100999. * @param uri The uri to test
  101000. * @return True if the uri is a base64 string or false otherwise
  101001. */
  101002. static IsBase64(uri: string): boolean;
  101003. /**
  101004. * Decode the given base64 uri.
  101005. * @param uri The uri to decode
  101006. * @return The decoded base64 data.
  101007. */
  101008. static DecodeBase64(uri: string): ArrayBuffer;
  101009. /**
  101010. * Gets the absolute url.
  101011. * @param url the input url
  101012. * @return the absolute url
  101013. */
  101014. static GetAbsoluteUrl(url: string): string;
  101015. /**
  101016. * No log
  101017. */
  101018. static readonly NoneLogLevel: number;
  101019. /**
  101020. * Only message logs
  101021. */
  101022. static readonly MessageLogLevel: number;
  101023. /**
  101024. * Only warning logs
  101025. */
  101026. static readonly WarningLogLevel: number;
  101027. /**
  101028. * Only error logs
  101029. */
  101030. static readonly ErrorLogLevel: number;
  101031. /**
  101032. * All logs
  101033. */
  101034. static readonly AllLogLevel: number;
  101035. /**
  101036. * Gets a value indicating the number of loading errors
  101037. * @ignorenaming
  101038. */
  101039. static readonly errorsCount: number;
  101040. /**
  101041. * Callback called when a new log is added
  101042. */
  101043. static OnNewCacheEntry: (entry: string) => void;
  101044. /**
  101045. * Log a message to the console
  101046. * @param message defines the message to log
  101047. */
  101048. static Log(message: string): void;
  101049. /**
  101050. * Write a warning message to the console
  101051. * @param message defines the message to log
  101052. */
  101053. static Warn(message: string): void;
  101054. /**
  101055. * Write an error message to the console
  101056. * @param message defines the message to log
  101057. */
  101058. static Error(message: string): void;
  101059. /**
  101060. * Gets current log cache (list of logs)
  101061. */
  101062. static readonly LogCache: string;
  101063. /**
  101064. * Clears the log cache
  101065. */
  101066. static ClearLogCache(): void;
  101067. /**
  101068. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  101069. */
  101070. static LogLevels: number;
  101071. /**
  101072. * Checks if the window object exists
  101073. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  101074. */
  101075. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  101076. /**
  101077. * No performance log
  101078. */
  101079. static readonly PerformanceNoneLogLevel: number;
  101080. /**
  101081. * Use user marks to log performance
  101082. */
  101083. static readonly PerformanceUserMarkLogLevel: number;
  101084. /**
  101085. * Log performance to the console
  101086. */
  101087. static readonly PerformanceConsoleLogLevel: number;
  101088. private static _performance;
  101089. /**
  101090. * Sets the current performance log level
  101091. */
  101092. static PerformanceLogLevel: number;
  101093. private static _StartPerformanceCounterDisabled;
  101094. private static _EndPerformanceCounterDisabled;
  101095. private static _StartUserMark;
  101096. private static _EndUserMark;
  101097. private static _StartPerformanceConsole;
  101098. private static _EndPerformanceConsole;
  101099. /**
  101100. * Starts a performance counter
  101101. */
  101102. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  101103. /**
  101104. * Ends a specific performance coutner
  101105. */
  101106. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  101107. /**
  101108. * Gets either window.performance.now() if supported or Date.now() else
  101109. */
  101110. static readonly Now: number;
  101111. /**
  101112. * This method will return the name of the class used to create the instance of the given object.
  101113. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  101114. * @param object the object to get the class name from
  101115. * @param isType defines if the object is actually a type
  101116. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  101117. */
  101118. static GetClassName(object: any, isType?: boolean): string;
  101119. /**
  101120. * Gets the first element of an array satisfying a given predicate
  101121. * @param array defines the array to browse
  101122. * @param predicate defines the predicate to use
  101123. * @returns null if not found or the element
  101124. */
  101125. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  101126. /**
  101127. * This method will return the name of the full name of the class, including its owning module (if any).
  101128. * 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).
  101129. * @param object the object to get the class name from
  101130. * @param isType defines if the object is actually a type
  101131. * @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.
  101132. * @ignorenaming
  101133. */
  101134. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  101135. /**
  101136. * Returns a promise that resolves after the given amount of time.
  101137. * @param delay Number of milliseconds to delay
  101138. * @returns Promise that resolves after the given amount of time
  101139. */
  101140. static DelayAsync(delay: number): Promise<void>;
  101141. }
  101142. /**
  101143. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  101144. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  101145. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  101146. * @param name The name of the class, case should be preserved
  101147. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  101148. */
  101149. export function className(name: string, module?: string): (target: Object) => void;
  101150. /**
  101151. * An implementation of a loop for asynchronous functions.
  101152. */
  101153. export class AsyncLoop {
  101154. /**
  101155. * Defines the number of iterations for the loop
  101156. */
  101157. iterations: number;
  101158. /**
  101159. * Defines the current index of the loop.
  101160. */
  101161. index: number;
  101162. private _done;
  101163. private _fn;
  101164. private _successCallback;
  101165. /**
  101166. * Constructor.
  101167. * @param iterations the number of iterations.
  101168. * @param func the function to run each iteration
  101169. * @param successCallback the callback that will be called upon succesful execution
  101170. * @param offset starting offset.
  101171. */
  101172. constructor(
  101173. /**
  101174. * Defines the number of iterations for the loop
  101175. */
  101176. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  101177. /**
  101178. * Execute the next iteration. Must be called after the last iteration was finished.
  101179. */
  101180. executeNext(): void;
  101181. /**
  101182. * Break the loop and run the success callback.
  101183. */
  101184. breakLoop(): void;
  101185. /**
  101186. * Create and run an async loop.
  101187. * @param iterations the number of iterations.
  101188. * @param fn the function to run each iteration
  101189. * @param successCallback the callback that will be called upon succesful execution
  101190. * @param offset starting offset.
  101191. * @returns the created async loop object
  101192. */
  101193. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  101194. /**
  101195. * A for-loop that will run a given number of iterations synchronous and the rest async.
  101196. * @param iterations total number of iterations
  101197. * @param syncedIterations number of synchronous iterations in each async iteration.
  101198. * @param fn the function to call each iteration.
  101199. * @param callback a success call back that will be called when iterating stops.
  101200. * @param breakFunction a break condition (optional)
  101201. * @param timeout timeout settings for the setTimeout function. default - 0.
  101202. * @returns the created async loop object
  101203. */
  101204. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  101205. }
  101206. }
  101207. declare module BABYLON {
  101208. /**
  101209. * This class implement a typical dictionary using a string as key and the generic type T as value.
  101210. * The underlying implementation relies on an associative array to ensure the best performances.
  101211. * The value can be anything including 'null' but except 'undefined'
  101212. */
  101213. export class StringDictionary<T> {
  101214. /**
  101215. * This will clear this dictionary and copy the content from the 'source' one.
  101216. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  101217. * @param source the dictionary to take the content from and copy to this dictionary
  101218. */
  101219. copyFrom(source: StringDictionary<T>): void;
  101220. /**
  101221. * Get a value based from its key
  101222. * @param key the given key to get the matching value from
  101223. * @return the value if found, otherwise undefined is returned
  101224. */
  101225. get(key: string): T | undefined;
  101226. /**
  101227. * Get a value from its key or add it if it doesn't exist.
  101228. * This method will ensure you that a given key/data will be present in the dictionary.
  101229. * @param key the given key to get the matching value from
  101230. * @param factory the factory that will create the value if the key is not present in the dictionary.
  101231. * The factory will only be invoked if there's no data for the given key.
  101232. * @return the value corresponding to the key.
  101233. */
  101234. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  101235. /**
  101236. * Get a value from its key if present in the dictionary otherwise add it
  101237. * @param key the key to get the value from
  101238. * @param val if there's no such key/value pair in the dictionary add it with this value
  101239. * @return the value corresponding to the key
  101240. */
  101241. getOrAdd(key: string, val: T): T;
  101242. /**
  101243. * Check if there's a given key in the dictionary
  101244. * @param key the key to check for
  101245. * @return true if the key is present, false otherwise
  101246. */
  101247. contains(key: string): boolean;
  101248. /**
  101249. * Add a new key and its corresponding value
  101250. * @param key the key to add
  101251. * @param value the value corresponding to the key
  101252. * @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
  101253. */
  101254. add(key: string, value: T): boolean;
  101255. /**
  101256. * Update a specific value associated to a key
  101257. * @param key defines the key to use
  101258. * @param value defines the value to store
  101259. * @returns true if the value was updated (or false if the key was not found)
  101260. */
  101261. set(key: string, value: T): boolean;
  101262. /**
  101263. * Get the element of the given key and remove it from the dictionary
  101264. * @param key defines the key to search
  101265. * @returns the value associated with the key or null if not found
  101266. */
  101267. getAndRemove(key: string): Nullable<T>;
  101268. /**
  101269. * Remove a key/value from the dictionary.
  101270. * @param key the key to remove
  101271. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  101272. */
  101273. remove(key: string): boolean;
  101274. /**
  101275. * Clear the whole content of the dictionary
  101276. */
  101277. clear(): void;
  101278. /**
  101279. * Gets the current count
  101280. */
  101281. readonly count: number;
  101282. /**
  101283. * Execute a callback on each key/val of the dictionary.
  101284. * Note that you can remove any element in this dictionary in the callback implementation
  101285. * @param callback the callback to execute on a given key/value pair
  101286. */
  101287. forEach(callback: (key: string, val: T) => void): void;
  101288. /**
  101289. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  101290. * If the callback returns null or undefined the method will iterate to the next key/value pair
  101291. * Note that you can remove any element in this dictionary in the callback implementation
  101292. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  101293. * @returns the first item
  101294. */
  101295. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  101296. private _count;
  101297. private _data;
  101298. }
  101299. }
  101300. declare module BABYLON {
  101301. /** @hidden */
  101302. export interface ICollisionCoordinator {
  101303. createCollider(): Collider;
  101304. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  101305. init(scene: Scene): void;
  101306. }
  101307. /** @hidden */
  101308. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  101309. private _scene;
  101310. private _scaledPosition;
  101311. private _scaledVelocity;
  101312. private _finalPosition;
  101313. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  101314. createCollider(): Collider;
  101315. init(scene: Scene): void;
  101316. private _collideWithWorld;
  101317. }
  101318. }
  101319. declare module BABYLON {
  101320. /**
  101321. * Class used to manage all inputs for the scene.
  101322. */
  101323. export class InputManager {
  101324. /** The distance in pixel that you have to move to prevent some events */
  101325. static DragMovementThreshold: number;
  101326. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  101327. static LongPressDelay: number;
  101328. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  101329. static DoubleClickDelay: number;
  101330. /** If you need to check double click without raising a single click at first click, enable this flag */
  101331. static ExclusiveDoubleClickMode: boolean;
  101332. private _wheelEventName;
  101333. private _onPointerMove;
  101334. private _onPointerDown;
  101335. private _onPointerUp;
  101336. private _initClickEvent;
  101337. private _initActionManager;
  101338. private _delayedSimpleClick;
  101339. private _delayedSimpleClickTimeout;
  101340. private _previousDelayedSimpleClickTimeout;
  101341. private _meshPickProceed;
  101342. private _previousButtonPressed;
  101343. private _currentPickResult;
  101344. private _previousPickResult;
  101345. private _totalPointersPressed;
  101346. private _doubleClickOccured;
  101347. private _pointerOverMesh;
  101348. private _pickedDownMesh;
  101349. private _pickedUpMesh;
  101350. private _pointerX;
  101351. private _pointerY;
  101352. private _unTranslatedPointerX;
  101353. private _unTranslatedPointerY;
  101354. private _startingPointerPosition;
  101355. private _previousStartingPointerPosition;
  101356. private _startingPointerTime;
  101357. private _previousStartingPointerTime;
  101358. private _pointerCaptures;
  101359. private _onKeyDown;
  101360. private _onKeyUp;
  101361. private _onCanvasFocusObserver;
  101362. private _onCanvasBlurObserver;
  101363. private _scene;
  101364. /**
  101365. * Creates a new InputManager
  101366. * @param scene defines the hosting scene
  101367. */
  101368. constructor(scene: Scene);
  101369. /**
  101370. * Gets the mesh that is currently under the pointer
  101371. */
  101372. readonly meshUnderPointer: Nullable<AbstractMesh>;
  101373. /**
  101374. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  101375. */
  101376. readonly unTranslatedPointer: Vector2;
  101377. /**
  101378. * Gets or sets the current on-screen X position of the pointer
  101379. */
  101380. pointerX: number;
  101381. /**
  101382. * Gets or sets the current on-screen Y position of the pointer
  101383. */
  101384. pointerY: number;
  101385. private _updatePointerPosition;
  101386. private _processPointerMove;
  101387. private _setRayOnPointerInfo;
  101388. private _checkPrePointerObservable;
  101389. /**
  101390. * Use this method to simulate a pointer move on a mesh
  101391. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101392. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101393. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101394. */
  101395. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  101396. /**
  101397. * Use this method to simulate a pointer down on a mesh
  101398. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101399. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101400. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101401. */
  101402. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  101403. private _processPointerDown;
  101404. /** @hidden */
  101405. _isPointerSwiping(): boolean;
  101406. /**
  101407. * Use this method to simulate a pointer up on a mesh
  101408. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101409. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101410. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101411. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  101412. */
  101413. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  101414. private _processPointerUp;
  101415. /**
  101416. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  101417. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  101418. * @returns true if the pointer was captured
  101419. */
  101420. isPointerCaptured(pointerId?: number): boolean;
  101421. /**
  101422. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  101423. * @param attachUp defines if you want to attach events to pointerup
  101424. * @param attachDown defines if you want to attach events to pointerdown
  101425. * @param attachMove defines if you want to attach events to pointermove
  101426. */
  101427. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  101428. /**
  101429. * Detaches all event handlers
  101430. */
  101431. detachControl(): void;
  101432. /**
  101433. * Force the value of meshUnderPointer
  101434. * @param mesh defines the mesh to use
  101435. */
  101436. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101437. /**
  101438. * Gets the mesh under the pointer
  101439. * @returns a Mesh or null if no mesh is under the pointer
  101440. */
  101441. getPointerOverMesh(): Nullable<AbstractMesh>;
  101442. }
  101443. }
  101444. declare module BABYLON {
  101445. /**
  101446. * Helper class used to generate session unique ID
  101447. */
  101448. export class UniqueIdGenerator {
  101449. private static _UniqueIdCounter;
  101450. /**
  101451. * Gets an unique (relatively to the current scene) Id
  101452. */
  101453. static readonly UniqueId: number;
  101454. }
  101455. }
  101456. declare module BABYLON {
  101457. /**
  101458. * This class defines the direct association between an animation and a target
  101459. */
  101460. export class TargetedAnimation {
  101461. /**
  101462. * Animation to perform
  101463. */
  101464. animation: Animation;
  101465. /**
  101466. * Target to animate
  101467. */
  101468. target: any;
  101469. /**
  101470. * Serialize the object
  101471. * @returns the JSON object representing the current entity
  101472. */
  101473. serialize(): any;
  101474. }
  101475. /**
  101476. * Use this class to create coordinated animations on multiple targets
  101477. */
  101478. export class AnimationGroup implements IDisposable {
  101479. /** The name of the animation group */
  101480. name: string;
  101481. private _scene;
  101482. private _targetedAnimations;
  101483. private _animatables;
  101484. private _from;
  101485. private _to;
  101486. private _isStarted;
  101487. private _isPaused;
  101488. private _speedRatio;
  101489. private _loopAnimation;
  101490. /**
  101491. * Gets or sets the unique id of the node
  101492. */
  101493. uniqueId: number;
  101494. /**
  101495. * This observable will notify when one animation have ended
  101496. */
  101497. onAnimationEndObservable: Observable<TargetedAnimation>;
  101498. /**
  101499. * Observer raised when one animation loops
  101500. */
  101501. onAnimationLoopObservable: Observable<TargetedAnimation>;
  101502. /**
  101503. * Observer raised when all animations have looped
  101504. */
  101505. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  101506. /**
  101507. * This observable will notify when all animations have ended.
  101508. */
  101509. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  101510. /**
  101511. * This observable will notify when all animations have paused.
  101512. */
  101513. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  101514. /**
  101515. * This observable will notify when all animations are playing.
  101516. */
  101517. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  101518. /**
  101519. * Gets the first frame
  101520. */
  101521. readonly from: number;
  101522. /**
  101523. * Gets the last frame
  101524. */
  101525. readonly to: number;
  101526. /**
  101527. * Define if the animations are started
  101528. */
  101529. readonly isStarted: boolean;
  101530. /**
  101531. * Gets a value indicating that the current group is playing
  101532. */
  101533. readonly isPlaying: boolean;
  101534. /**
  101535. * Gets or sets the speed ratio to use for all animations
  101536. */
  101537. /**
  101538. * Gets or sets the speed ratio to use for all animations
  101539. */
  101540. speedRatio: number;
  101541. /**
  101542. * Gets or sets if all animations should loop or not
  101543. */
  101544. loopAnimation: boolean;
  101545. /**
  101546. * Gets the targeted animations for this animation group
  101547. */
  101548. readonly targetedAnimations: Array<TargetedAnimation>;
  101549. /**
  101550. * returning the list of animatables controlled by this animation group.
  101551. */
  101552. readonly animatables: Array<Animatable>;
  101553. /**
  101554. * Instantiates a new Animation Group.
  101555. * This helps managing several animations at once.
  101556. * @see http://doc.babylonjs.com/how_to/group
  101557. * @param name Defines the name of the group
  101558. * @param scene Defines the scene the group belongs to
  101559. */
  101560. constructor(
  101561. /** The name of the animation group */
  101562. name: string, scene?: Nullable<Scene>);
  101563. /**
  101564. * Add an animation (with its target) in the group
  101565. * @param animation defines the animation we want to add
  101566. * @param target defines the target of the animation
  101567. * @returns the TargetedAnimation object
  101568. */
  101569. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  101570. /**
  101571. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  101572. * It can add constant keys at begin or end
  101573. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  101574. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  101575. * @returns the animation group
  101576. */
  101577. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  101578. private _animationLoopCount;
  101579. private _animationLoopFlags;
  101580. private _processLoop;
  101581. /**
  101582. * Start all animations on given targets
  101583. * @param loop defines if animations must loop
  101584. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  101585. * @param from defines the from key (optional)
  101586. * @param to defines the to key (optional)
  101587. * @returns the current animation group
  101588. */
  101589. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  101590. /**
  101591. * Pause all animations
  101592. * @returns the animation group
  101593. */
  101594. pause(): AnimationGroup;
  101595. /**
  101596. * Play all animations to initial state
  101597. * This function will start() the animations if they were not started or will restart() them if they were paused
  101598. * @param loop defines if animations must loop
  101599. * @returns the animation group
  101600. */
  101601. play(loop?: boolean): AnimationGroup;
  101602. /**
  101603. * Reset all animations to initial state
  101604. * @returns the animation group
  101605. */
  101606. reset(): AnimationGroup;
  101607. /**
  101608. * Restart animations from key 0
  101609. * @returns the animation group
  101610. */
  101611. restart(): AnimationGroup;
  101612. /**
  101613. * Stop all animations
  101614. * @returns the animation group
  101615. */
  101616. stop(): AnimationGroup;
  101617. /**
  101618. * Set animation weight for all animatables
  101619. * @param weight defines the weight to use
  101620. * @return the animationGroup
  101621. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  101622. */
  101623. setWeightForAllAnimatables(weight: number): AnimationGroup;
  101624. /**
  101625. * Synchronize and normalize all animatables with a source animatable
  101626. * @param root defines the root animatable to synchronize with
  101627. * @return the animationGroup
  101628. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  101629. */
  101630. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  101631. /**
  101632. * Goes to a specific frame in this animation group
  101633. * @param frame the frame number to go to
  101634. * @return the animationGroup
  101635. */
  101636. goToFrame(frame: number): AnimationGroup;
  101637. /**
  101638. * Dispose all associated resources
  101639. */
  101640. dispose(): void;
  101641. private _checkAnimationGroupEnded;
  101642. /**
  101643. * Clone the current animation group and returns a copy
  101644. * @param newName defines the name of the new group
  101645. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  101646. * @returns the new aniamtion group
  101647. */
  101648. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  101649. /**
  101650. * Serializes the animationGroup to an object
  101651. * @returns Serialized object
  101652. */
  101653. serialize(): any;
  101654. /**
  101655. * Returns a new AnimationGroup object parsed from the source provided.
  101656. * @param parsedAnimationGroup defines the source
  101657. * @param scene defines the scene that will receive the animationGroup
  101658. * @returns a new AnimationGroup
  101659. */
  101660. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  101661. /**
  101662. * Returns the string "AnimationGroup"
  101663. * @returns "AnimationGroup"
  101664. */
  101665. getClassName(): string;
  101666. /**
  101667. * Creates a detailled string about the object
  101668. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  101669. * @returns a string representing the object
  101670. */
  101671. toString(fullDetails?: boolean): string;
  101672. }
  101673. }
  101674. declare module BABYLON {
  101675. /**
  101676. * Define an interface for all classes that will hold resources
  101677. */
  101678. export interface IDisposable {
  101679. /**
  101680. * Releases all held resources
  101681. */
  101682. dispose(): void;
  101683. }
  101684. /** Interface defining initialization parameters for Scene class */
  101685. export interface SceneOptions {
  101686. /**
  101687. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  101688. * It will improve performance when the number of geometries becomes important.
  101689. */
  101690. useGeometryUniqueIdsMap?: boolean;
  101691. /**
  101692. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  101693. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101694. */
  101695. useMaterialMeshMap?: boolean;
  101696. /**
  101697. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  101698. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101699. */
  101700. useClonedMeshhMap?: boolean;
  101701. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  101702. virtual?: boolean;
  101703. }
  101704. /**
  101705. * Represents a scene to be rendered by the engine.
  101706. * @see http://doc.babylonjs.com/features/scene
  101707. */
  101708. export class Scene extends AbstractScene implements IAnimatable {
  101709. /** The fog is deactivated */
  101710. static readonly FOGMODE_NONE: number;
  101711. /** The fog density is following an exponential function */
  101712. static readonly FOGMODE_EXP: number;
  101713. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  101714. static readonly FOGMODE_EXP2: number;
  101715. /** The fog density is following a linear function. */
  101716. static readonly FOGMODE_LINEAR: number;
  101717. /**
  101718. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  101719. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101720. */
  101721. static MinDeltaTime: number;
  101722. /**
  101723. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  101724. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101725. */
  101726. static MaxDeltaTime: number;
  101727. /**
  101728. * Factory used to create the default material.
  101729. * @param name The name of the material to create
  101730. * @param scene The scene to create the material for
  101731. * @returns The default material
  101732. */
  101733. static DefaultMaterialFactory(scene: Scene): Material;
  101734. /**
  101735. * Factory used to create the a collision coordinator.
  101736. * @returns The collision coordinator
  101737. */
  101738. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  101739. /** @hidden */
  101740. _inputManager: InputManager;
  101741. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  101742. cameraToUseForPointers: Nullable<Camera>;
  101743. /** @hidden */
  101744. readonly _isScene: boolean;
  101745. /**
  101746. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  101747. */
  101748. autoClear: boolean;
  101749. /**
  101750. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  101751. */
  101752. autoClearDepthAndStencil: boolean;
  101753. /**
  101754. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  101755. */
  101756. clearColor: Color4;
  101757. /**
  101758. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  101759. */
  101760. ambientColor: Color3;
  101761. /**
  101762. * This is use to store the default BRDF lookup for PBR materials in your scene.
  101763. * It should only be one of the following (if not the default embedded one):
  101764. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101765. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  101766. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101767. * The material properties need to be setup according to the type of texture in use.
  101768. */
  101769. environmentBRDFTexture: BaseTexture;
  101770. /** @hidden */
  101771. protected _environmentTexture: Nullable<BaseTexture>;
  101772. /**
  101773. * Texture used in all pbr material as the reflection texture.
  101774. * As in the majority of the scene they are the same (exception for multi room and so on),
  101775. * this is easier to reference from here than from all the materials.
  101776. */
  101777. /**
  101778. * Texture used in all pbr material as the reflection texture.
  101779. * As in the majority of the scene they are the same (exception for multi room and so on),
  101780. * this is easier to set here than in all the materials.
  101781. */
  101782. environmentTexture: Nullable<BaseTexture>;
  101783. /** @hidden */
  101784. protected _environmentIntensity: number;
  101785. /**
  101786. * Intensity of the environment in all pbr material.
  101787. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  101788. * As in the majority of the scene they are the same (exception for multi room and so on),
  101789. * this is easier to reference from here than from all the materials.
  101790. */
  101791. /**
  101792. * Intensity of the environment in all pbr material.
  101793. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  101794. * As in the majority of the scene they are the same (exception for multi room and so on),
  101795. * this is easier to set here than in all the materials.
  101796. */
  101797. environmentIntensity: number;
  101798. /** @hidden */
  101799. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101800. /**
  101801. * Default image processing configuration used either in the rendering
  101802. * Forward main pass or through the imageProcessingPostProcess if present.
  101803. * As in the majority of the scene they are the same (exception for multi camera),
  101804. * this is easier to reference from here than from all the materials and post process.
  101805. *
  101806. * No setter as we it is a shared configuration, you can set the values instead.
  101807. */
  101808. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  101809. private _forceWireframe;
  101810. /**
  101811. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  101812. */
  101813. forceWireframe: boolean;
  101814. private _forcePointsCloud;
  101815. /**
  101816. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  101817. */
  101818. forcePointsCloud: boolean;
  101819. /**
  101820. * Gets or sets the active clipplane 1
  101821. */
  101822. clipPlane: Nullable<Plane>;
  101823. /**
  101824. * Gets or sets the active clipplane 2
  101825. */
  101826. clipPlane2: Nullable<Plane>;
  101827. /**
  101828. * Gets or sets the active clipplane 3
  101829. */
  101830. clipPlane3: Nullable<Plane>;
  101831. /**
  101832. * Gets or sets the active clipplane 4
  101833. */
  101834. clipPlane4: Nullable<Plane>;
  101835. /**
  101836. * Gets or sets a boolean indicating if animations are enabled
  101837. */
  101838. animationsEnabled: boolean;
  101839. private _animationPropertiesOverride;
  101840. /**
  101841. * Gets or sets the animation properties override
  101842. */
  101843. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  101844. /**
  101845. * Gets or sets a boolean indicating if a constant deltatime has to be used
  101846. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  101847. */
  101848. useConstantAnimationDeltaTime: boolean;
  101849. /**
  101850. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  101851. * Please note that it requires to run a ray cast through the scene on every frame
  101852. */
  101853. constantlyUpdateMeshUnderPointer: boolean;
  101854. /**
  101855. * Defines the HTML cursor to use when hovering over interactive elements
  101856. */
  101857. hoverCursor: string;
  101858. /**
  101859. * Defines the HTML default cursor to use (empty by default)
  101860. */
  101861. defaultCursor: string;
  101862. /**
  101863. * Defines wether cursors are handled by the scene.
  101864. */
  101865. doNotHandleCursors: boolean;
  101866. /**
  101867. * This is used to call preventDefault() on pointer down
  101868. * in order to block unwanted artifacts like system double clicks
  101869. */
  101870. preventDefaultOnPointerDown: boolean;
  101871. /**
  101872. * This is used to call preventDefault() on pointer up
  101873. * in order to block unwanted artifacts like system double clicks
  101874. */
  101875. preventDefaultOnPointerUp: boolean;
  101876. /**
  101877. * Gets or sets user defined metadata
  101878. */
  101879. metadata: any;
  101880. /**
  101881. * For internal use only. Please do not use.
  101882. */
  101883. reservedDataStore: any;
  101884. /**
  101885. * Gets the name of the plugin used to load this scene (null by default)
  101886. */
  101887. loadingPluginName: string;
  101888. /**
  101889. * Use this array to add regular expressions used to disable offline support for specific urls
  101890. */
  101891. disableOfflineSupportExceptionRules: RegExp[];
  101892. /**
  101893. * An event triggered when the scene is disposed.
  101894. */
  101895. onDisposeObservable: Observable<Scene>;
  101896. private _onDisposeObserver;
  101897. /** Sets a function to be executed when this scene is disposed. */
  101898. onDispose: () => void;
  101899. /**
  101900. * An event triggered before rendering the scene (right after animations and physics)
  101901. */
  101902. onBeforeRenderObservable: Observable<Scene>;
  101903. private _onBeforeRenderObserver;
  101904. /** Sets a function to be executed before rendering this scene */
  101905. beforeRender: Nullable<() => void>;
  101906. /**
  101907. * An event triggered after rendering the scene
  101908. */
  101909. onAfterRenderObservable: Observable<Scene>;
  101910. /**
  101911. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  101912. */
  101913. onAfterRenderCameraObservable: Observable<Camera>;
  101914. private _onAfterRenderObserver;
  101915. /** Sets a function to be executed after rendering this scene */
  101916. afterRender: Nullable<() => void>;
  101917. /**
  101918. * An event triggered before animating the scene
  101919. */
  101920. onBeforeAnimationsObservable: Observable<Scene>;
  101921. /**
  101922. * An event triggered after animations processing
  101923. */
  101924. onAfterAnimationsObservable: Observable<Scene>;
  101925. /**
  101926. * An event triggered before draw calls are ready to be sent
  101927. */
  101928. onBeforeDrawPhaseObservable: Observable<Scene>;
  101929. /**
  101930. * An event triggered after draw calls have been sent
  101931. */
  101932. onAfterDrawPhaseObservable: Observable<Scene>;
  101933. /**
  101934. * An event triggered when the scene is ready
  101935. */
  101936. onReadyObservable: Observable<Scene>;
  101937. /**
  101938. * An event triggered before rendering a camera
  101939. */
  101940. onBeforeCameraRenderObservable: Observable<Camera>;
  101941. private _onBeforeCameraRenderObserver;
  101942. /** Sets a function to be executed before rendering a camera*/
  101943. beforeCameraRender: () => void;
  101944. /**
  101945. * An event triggered after rendering a camera
  101946. */
  101947. onAfterCameraRenderObservable: Observable<Camera>;
  101948. private _onAfterCameraRenderObserver;
  101949. /** Sets a function to be executed after rendering a camera*/
  101950. afterCameraRender: () => void;
  101951. /**
  101952. * An event triggered when active meshes evaluation is about to start
  101953. */
  101954. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  101955. /**
  101956. * An event triggered when active meshes evaluation is done
  101957. */
  101958. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  101959. /**
  101960. * An event triggered when particles rendering is about to start
  101961. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  101962. */
  101963. onBeforeParticlesRenderingObservable: Observable<Scene>;
  101964. /**
  101965. * An event triggered when particles rendering is done
  101966. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  101967. */
  101968. onAfterParticlesRenderingObservable: Observable<Scene>;
  101969. /**
  101970. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  101971. */
  101972. onDataLoadedObservable: Observable<Scene>;
  101973. /**
  101974. * An event triggered when a camera is created
  101975. */
  101976. onNewCameraAddedObservable: Observable<Camera>;
  101977. /**
  101978. * An event triggered when a camera is removed
  101979. */
  101980. onCameraRemovedObservable: Observable<Camera>;
  101981. /**
  101982. * An event triggered when a light is created
  101983. */
  101984. onNewLightAddedObservable: Observable<Light>;
  101985. /**
  101986. * An event triggered when a light is removed
  101987. */
  101988. onLightRemovedObservable: Observable<Light>;
  101989. /**
  101990. * An event triggered when a geometry is created
  101991. */
  101992. onNewGeometryAddedObservable: Observable<Geometry>;
  101993. /**
  101994. * An event triggered when a geometry is removed
  101995. */
  101996. onGeometryRemovedObservable: Observable<Geometry>;
  101997. /**
  101998. * An event triggered when a transform node is created
  101999. */
  102000. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  102001. /**
  102002. * An event triggered when a transform node is removed
  102003. */
  102004. onTransformNodeRemovedObservable: Observable<TransformNode>;
  102005. /**
  102006. * An event triggered when a mesh is created
  102007. */
  102008. onNewMeshAddedObservable: Observable<AbstractMesh>;
  102009. /**
  102010. * An event triggered when a mesh is removed
  102011. */
  102012. onMeshRemovedObservable: Observable<AbstractMesh>;
  102013. /**
  102014. * An event triggered when a skeleton is created
  102015. */
  102016. onNewSkeletonAddedObservable: Observable<Skeleton>;
  102017. /**
  102018. * An event triggered when a skeleton is removed
  102019. */
  102020. onSkeletonRemovedObservable: Observable<Skeleton>;
  102021. /**
  102022. * An event triggered when a material is created
  102023. */
  102024. onNewMaterialAddedObservable: Observable<Material>;
  102025. /**
  102026. * An event triggered when a material is removed
  102027. */
  102028. onMaterialRemovedObservable: Observable<Material>;
  102029. /**
  102030. * An event triggered when a texture is created
  102031. */
  102032. onNewTextureAddedObservable: Observable<BaseTexture>;
  102033. /**
  102034. * An event triggered when a texture is removed
  102035. */
  102036. onTextureRemovedObservable: Observable<BaseTexture>;
  102037. /**
  102038. * An event triggered when render targets are about to be rendered
  102039. * Can happen multiple times per frame.
  102040. */
  102041. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  102042. /**
  102043. * An event triggered when render targets were rendered.
  102044. * Can happen multiple times per frame.
  102045. */
  102046. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  102047. /**
  102048. * An event triggered before calculating deterministic simulation step
  102049. */
  102050. onBeforeStepObservable: Observable<Scene>;
  102051. /**
  102052. * An event triggered after calculating deterministic simulation step
  102053. */
  102054. onAfterStepObservable: Observable<Scene>;
  102055. /**
  102056. * An event triggered when the activeCamera property is updated
  102057. */
  102058. onActiveCameraChanged: Observable<Scene>;
  102059. /**
  102060. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  102061. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  102062. * 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)
  102063. */
  102064. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  102065. /**
  102066. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  102067. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  102068. * 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)
  102069. */
  102070. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  102071. /**
  102072. * This Observable will when a mesh has been imported into the scene.
  102073. */
  102074. onMeshImportedObservable: Observable<AbstractMesh>;
  102075. /**
  102076. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  102077. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  102078. */
  102079. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  102080. /** @hidden */
  102081. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  102082. /**
  102083. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  102084. */
  102085. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  102086. /**
  102087. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  102088. */
  102089. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  102090. /**
  102091. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  102092. */
  102093. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  102094. /** Callback called when a pointer move is detected */
  102095. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  102096. /** Callback called when a pointer down is detected */
  102097. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  102098. /** Callback called when a pointer up is detected */
  102099. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  102100. /** Callback called when a pointer pick is detected */
  102101. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  102102. /**
  102103. * 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).
  102104. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  102105. */
  102106. onPrePointerObservable: Observable<PointerInfoPre>;
  102107. /**
  102108. * Observable event triggered each time an input event is received from the rendering canvas
  102109. */
  102110. onPointerObservable: Observable<PointerInfo>;
  102111. /**
  102112. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  102113. */
  102114. readonly unTranslatedPointer: Vector2;
  102115. /**
  102116. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  102117. */
  102118. static DragMovementThreshold: number;
  102119. /**
  102120. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  102121. */
  102122. static LongPressDelay: number;
  102123. /**
  102124. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  102125. */
  102126. static DoubleClickDelay: number;
  102127. /** If you need to check double click without raising a single click at first click, enable this flag */
  102128. static ExclusiveDoubleClickMode: boolean;
  102129. /** @hidden */
  102130. _mirroredCameraPosition: Nullable<Vector3>;
  102131. /**
  102132. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  102133. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  102134. */
  102135. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  102136. /**
  102137. * Observable event triggered each time an keyboard event is received from the hosting window
  102138. */
  102139. onKeyboardObservable: Observable<KeyboardInfo>;
  102140. private _useRightHandedSystem;
  102141. /**
  102142. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  102143. */
  102144. useRightHandedSystem: boolean;
  102145. private _timeAccumulator;
  102146. private _currentStepId;
  102147. private _currentInternalStep;
  102148. /**
  102149. * Sets the step Id used by deterministic lock step
  102150. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102151. * @param newStepId defines the step Id
  102152. */
  102153. setStepId(newStepId: number): void;
  102154. /**
  102155. * Gets the step Id used by deterministic lock step
  102156. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102157. * @returns the step Id
  102158. */
  102159. getStepId(): number;
  102160. /**
  102161. * Gets the internal step used by deterministic lock step
  102162. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102163. * @returns the internal step
  102164. */
  102165. getInternalStep(): number;
  102166. private _fogEnabled;
  102167. /**
  102168. * Gets or sets a boolean indicating if fog is enabled on this scene
  102169. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102170. * (Default is true)
  102171. */
  102172. fogEnabled: boolean;
  102173. private _fogMode;
  102174. /**
  102175. * Gets or sets the fog mode to use
  102176. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102177. * | mode | value |
  102178. * | --- | --- |
  102179. * | FOGMODE_NONE | 0 |
  102180. * | FOGMODE_EXP | 1 |
  102181. * | FOGMODE_EXP2 | 2 |
  102182. * | FOGMODE_LINEAR | 3 |
  102183. */
  102184. fogMode: number;
  102185. /**
  102186. * Gets or sets the fog color to use
  102187. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102188. * (Default is Color3(0.2, 0.2, 0.3))
  102189. */
  102190. fogColor: Color3;
  102191. /**
  102192. * Gets or sets the fog density to use
  102193. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102194. * (Default is 0.1)
  102195. */
  102196. fogDensity: number;
  102197. /**
  102198. * Gets or sets the fog start distance to use
  102199. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102200. * (Default is 0)
  102201. */
  102202. fogStart: number;
  102203. /**
  102204. * Gets or sets the fog end distance to use
  102205. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102206. * (Default is 1000)
  102207. */
  102208. fogEnd: number;
  102209. private _shadowsEnabled;
  102210. /**
  102211. * Gets or sets a boolean indicating if shadows are enabled on this scene
  102212. */
  102213. shadowsEnabled: boolean;
  102214. private _lightsEnabled;
  102215. /**
  102216. * Gets or sets a boolean indicating if lights are enabled on this scene
  102217. */
  102218. lightsEnabled: boolean;
  102219. /** All of the active cameras added to this scene. */
  102220. activeCameras: Camera[];
  102221. /** @hidden */
  102222. _activeCamera: Nullable<Camera>;
  102223. /** Gets or sets the current active camera */
  102224. activeCamera: Nullable<Camera>;
  102225. private _defaultMaterial;
  102226. /** The default material used on meshes when no material is affected */
  102227. /** The default material used on meshes when no material is affected */
  102228. defaultMaterial: Material;
  102229. private _texturesEnabled;
  102230. /**
  102231. * Gets or sets a boolean indicating if textures are enabled on this scene
  102232. */
  102233. texturesEnabled: boolean;
  102234. /**
  102235. * Gets or sets a boolean indicating if particles are enabled on this scene
  102236. */
  102237. particlesEnabled: boolean;
  102238. /**
  102239. * Gets or sets a boolean indicating if sprites are enabled on this scene
  102240. */
  102241. spritesEnabled: boolean;
  102242. private _skeletonsEnabled;
  102243. /**
  102244. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  102245. */
  102246. skeletonsEnabled: boolean;
  102247. /**
  102248. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  102249. */
  102250. lensFlaresEnabled: boolean;
  102251. /**
  102252. * Gets or sets a boolean indicating if collisions are enabled on this scene
  102253. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102254. */
  102255. collisionsEnabled: boolean;
  102256. private _collisionCoordinator;
  102257. /** @hidden */
  102258. readonly collisionCoordinator: ICollisionCoordinator;
  102259. /**
  102260. * Defines the gravity applied to this scene (used only for collisions)
  102261. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102262. */
  102263. gravity: Vector3;
  102264. /**
  102265. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  102266. */
  102267. postProcessesEnabled: boolean;
  102268. /**
  102269. * The list of postprocesses added to the scene
  102270. */
  102271. postProcesses: PostProcess[];
  102272. /**
  102273. * Gets the current postprocess manager
  102274. */
  102275. postProcessManager: PostProcessManager;
  102276. /**
  102277. * Gets or sets a boolean indicating if render targets are enabled on this scene
  102278. */
  102279. renderTargetsEnabled: boolean;
  102280. /**
  102281. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  102282. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  102283. */
  102284. dumpNextRenderTargets: boolean;
  102285. /**
  102286. * The list of user defined render targets added to the scene
  102287. */
  102288. customRenderTargets: RenderTargetTexture[];
  102289. /**
  102290. * Defines if texture loading must be delayed
  102291. * If true, textures will only be loaded when they need to be rendered
  102292. */
  102293. useDelayedTextureLoading: boolean;
  102294. /**
  102295. * Gets the list of meshes imported to the scene through SceneLoader
  102296. */
  102297. importedMeshesFiles: String[];
  102298. /**
  102299. * Gets or sets a boolean indicating if probes are enabled on this scene
  102300. */
  102301. probesEnabled: boolean;
  102302. /**
  102303. * Gets or sets the current offline provider to use to store scene data
  102304. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  102305. */
  102306. offlineProvider: IOfflineProvider;
  102307. /**
  102308. * Gets or sets the action manager associated with the scene
  102309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102310. */
  102311. actionManager: AbstractActionManager;
  102312. private _meshesForIntersections;
  102313. /**
  102314. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  102315. */
  102316. proceduralTexturesEnabled: boolean;
  102317. private _engine;
  102318. private _totalVertices;
  102319. /** @hidden */
  102320. _activeIndices: PerfCounter;
  102321. /** @hidden */
  102322. _activeParticles: PerfCounter;
  102323. /** @hidden */
  102324. _activeBones: PerfCounter;
  102325. private _animationRatio;
  102326. /** @hidden */
  102327. _animationTimeLast: number;
  102328. /** @hidden */
  102329. _animationTime: number;
  102330. /**
  102331. * Gets or sets a general scale for animation speed
  102332. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  102333. */
  102334. animationTimeScale: number;
  102335. /** @hidden */
  102336. _cachedMaterial: Nullable<Material>;
  102337. /** @hidden */
  102338. _cachedEffect: Nullable<Effect>;
  102339. /** @hidden */
  102340. _cachedVisibility: Nullable<number>;
  102341. private _renderId;
  102342. private _frameId;
  102343. private _executeWhenReadyTimeoutId;
  102344. private _intermediateRendering;
  102345. private _viewUpdateFlag;
  102346. private _projectionUpdateFlag;
  102347. /** @hidden */
  102348. _toBeDisposed: Nullable<IDisposable>[];
  102349. private _activeRequests;
  102350. /** @hidden */
  102351. _pendingData: any[];
  102352. private _isDisposed;
  102353. /**
  102354. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  102355. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  102356. */
  102357. dispatchAllSubMeshesOfActiveMeshes: boolean;
  102358. private _activeMeshes;
  102359. private _processedMaterials;
  102360. private _renderTargets;
  102361. /** @hidden */
  102362. _activeParticleSystems: SmartArray<IParticleSystem>;
  102363. private _activeSkeletons;
  102364. private _softwareSkinnedMeshes;
  102365. private _renderingManager;
  102366. /** @hidden */
  102367. _activeAnimatables: Animatable[];
  102368. private _transformMatrix;
  102369. private _sceneUbo;
  102370. /** @hidden */
  102371. _viewMatrix: Matrix;
  102372. private _projectionMatrix;
  102373. /** @hidden */
  102374. _forcedViewPosition: Nullable<Vector3>;
  102375. /** @hidden */
  102376. _frustumPlanes: Plane[];
  102377. /**
  102378. * Gets the list of frustum planes (built from the active camera)
  102379. */
  102380. readonly frustumPlanes: Plane[];
  102381. /**
  102382. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  102383. * This is useful if there are more lights that the maximum simulteanous authorized
  102384. */
  102385. requireLightSorting: boolean;
  102386. /** @hidden */
  102387. readonly useMaterialMeshMap: boolean;
  102388. /** @hidden */
  102389. readonly useClonedMeshhMap: boolean;
  102390. private _externalData;
  102391. private _uid;
  102392. /**
  102393. * @hidden
  102394. * Backing store of defined scene components.
  102395. */
  102396. _components: ISceneComponent[];
  102397. /**
  102398. * @hidden
  102399. * Backing store of defined scene components.
  102400. */
  102401. _serializableComponents: ISceneSerializableComponent[];
  102402. /**
  102403. * List of components to register on the next registration step.
  102404. */
  102405. private _transientComponents;
  102406. /**
  102407. * Registers the transient components if needed.
  102408. */
  102409. private _registerTransientComponents;
  102410. /**
  102411. * @hidden
  102412. * Add a component to the scene.
  102413. * Note that the ccomponent could be registered on th next frame if this is called after
  102414. * the register component stage.
  102415. * @param component Defines the component to add to the scene
  102416. */
  102417. _addComponent(component: ISceneComponent): void;
  102418. /**
  102419. * @hidden
  102420. * Gets a component from the scene.
  102421. * @param name defines the name of the component to retrieve
  102422. * @returns the component or null if not present
  102423. */
  102424. _getComponent(name: string): Nullable<ISceneComponent>;
  102425. /**
  102426. * @hidden
  102427. * Defines the actions happening before camera updates.
  102428. */
  102429. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  102430. /**
  102431. * @hidden
  102432. * Defines the actions happening before clear the canvas.
  102433. */
  102434. _beforeClearStage: Stage<SimpleStageAction>;
  102435. /**
  102436. * @hidden
  102437. * Defines the actions when collecting render targets for the frame.
  102438. */
  102439. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102440. /**
  102441. * @hidden
  102442. * Defines the actions happening for one camera in the frame.
  102443. */
  102444. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102445. /**
  102446. * @hidden
  102447. * Defines the actions happening during the per mesh ready checks.
  102448. */
  102449. _isReadyForMeshStage: Stage<MeshStageAction>;
  102450. /**
  102451. * @hidden
  102452. * Defines the actions happening before evaluate active mesh checks.
  102453. */
  102454. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  102455. /**
  102456. * @hidden
  102457. * Defines the actions happening during the evaluate sub mesh checks.
  102458. */
  102459. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  102460. /**
  102461. * @hidden
  102462. * Defines the actions happening during the active mesh stage.
  102463. */
  102464. _activeMeshStage: Stage<ActiveMeshStageAction>;
  102465. /**
  102466. * @hidden
  102467. * Defines the actions happening during the per camera render target step.
  102468. */
  102469. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  102470. /**
  102471. * @hidden
  102472. * Defines the actions happening just before the active camera is drawing.
  102473. */
  102474. _beforeCameraDrawStage: Stage<CameraStageAction>;
  102475. /**
  102476. * @hidden
  102477. * Defines the actions happening just before a render target is drawing.
  102478. */
  102479. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102480. /**
  102481. * @hidden
  102482. * Defines the actions happening just before a rendering group is drawing.
  102483. */
  102484. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102485. /**
  102486. * @hidden
  102487. * Defines the actions happening just before a mesh is drawing.
  102488. */
  102489. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102490. /**
  102491. * @hidden
  102492. * Defines the actions happening just after a mesh has been drawn.
  102493. */
  102494. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102495. /**
  102496. * @hidden
  102497. * Defines the actions happening just after a rendering group has been drawn.
  102498. */
  102499. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102500. /**
  102501. * @hidden
  102502. * Defines the actions happening just after the active camera has been drawn.
  102503. */
  102504. _afterCameraDrawStage: Stage<CameraStageAction>;
  102505. /**
  102506. * @hidden
  102507. * Defines the actions happening just after a render target has been drawn.
  102508. */
  102509. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102510. /**
  102511. * @hidden
  102512. * Defines the actions happening just after rendering all cameras and computing intersections.
  102513. */
  102514. _afterRenderStage: Stage<SimpleStageAction>;
  102515. /**
  102516. * @hidden
  102517. * Defines the actions happening when a pointer move event happens.
  102518. */
  102519. _pointerMoveStage: Stage<PointerMoveStageAction>;
  102520. /**
  102521. * @hidden
  102522. * Defines the actions happening when a pointer down event happens.
  102523. */
  102524. _pointerDownStage: Stage<PointerUpDownStageAction>;
  102525. /**
  102526. * @hidden
  102527. * Defines the actions happening when a pointer up event happens.
  102528. */
  102529. _pointerUpStage: Stage<PointerUpDownStageAction>;
  102530. /**
  102531. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  102532. */
  102533. private geometriesByUniqueId;
  102534. /**
  102535. * Creates a new Scene
  102536. * @param engine defines the engine to use to render this scene
  102537. * @param options defines the scene options
  102538. */
  102539. constructor(engine: Engine, options?: SceneOptions);
  102540. /**
  102541. * Gets a string idenfifying the name of the class
  102542. * @returns "Scene" string
  102543. */
  102544. getClassName(): string;
  102545. private _defaultMeshCandidates;
  102546. /**
  102547. * @hidden
  102548. */
  102549. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  102550. private _defaultSubMeshCandidates;
  102551. /**
  102552. * @hidden
  102553. */
  102554. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  102555. /**
  102556. * Sets the default candidate providers for the scene.
  102557. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  102558. * and getCollidingSubMeshCandidates to their default function
  102559. */
  102560. setDefaultCandidateProviders(): void;
  102561. /**
  102562. * Gets the mesh that is currently under the pointer
  102563. */
  102564. readonly meshUnderPointer: Nullable<AbstractMesh>;
  102565. /**
  102566. * Gets or sets the current on-screen X position of the pointer
  102567. */
  102568. pointerX: number;
  102569. /**
  102570. * Gets or sets the current on-screen Y position of the pointer
  102571. */
  102572. pointerY: number;
  102573. /**
  102574. * Gets the cached material (ie. the latest rendered one)
  102575. * @returns the cached material
  102576. */
  102577. getCachedMaterial(): Nullable<Material>;
  102578. /**
  102579. * Gets the cached effect (ie. the latest rendered one)
  102580. * @returns the cached effect
  102581. */
  102582. getCachedEffect(): Nullable<Effect>;
  102583. /**
  102584. * Gets the cached visibility state (ie. the latest rendered one)
  102585. * @returns the cached visibility state
  102586. */
  102587. getCachedVisibility(): Nullable<number>;
  102588. /**
  102589. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  102590. * @param material defines the current material
  102591. * @param effect defines the current effect
  102592. * @param visibility defines the current visibility state
  102593. * @returns true if one parameter is not cached
  102594. */
  102595. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  102596. /**
  102597. * Gets the engine associated with the scene
  102598. * @returns an Engine
  102599. */
  102600. getEngine(): Engine;
  102601. /**
  102602. * Gets the total number of vertices rendered per frame
  102603. * @returns the total number of vertices rendered per frame
  102604. */
  102605. getTotalVertices(): number;
  102606. /**
  102607. * Gets the performance counter for total vertices
  102608. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102609. */
  102610. readonly totalVerticesPerfCounter: PerfCounter;
  102611. /**
  102612. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  102613. * @returns the total number of active indices rendered per frame
  102614. */
  102615. getActiveIndices(): number;
  102616. /**
  102617. * Gets the performance counter for active indices
  102618. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102619. */
  102620. readonly totalActiveIndicesPerfCounter: PerfCounter;
  102621. /**
  102622. * Gets the total number of active particles rendered per frame
  102623. * @returns the total number of active particles rendered per frame
  102624. */
  102625. getActiveParticles(): number;
  102626. /**
  102627. * Gets the performance counter for active particles
  102628. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102629. */
  102630. readonly activeParticlesPerfCounter: PerfCounter;
  102631. /**
  102632. * Gets the total number of active bones rendered per frame
  102633. * @returns the total number of active bones rendered per frame
  102634. */
  102635. getActiveBones(): number;
  102636. /**
  102637. * Gets the performance counter for active bones
  102638. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102639. */
  102640. readonly activeBonesPerfCounter: PerfCounter;
  102641. /**
  102642. * Gets the array of active meshes
  102643. * @returns an array of AbstractMesh
  102644. */
  102645. getActiveMeshes(): SmartArray<AbstractMesh>;
  102646. /**
  102647. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  102648. * @returns a number
  102649. */
  102650. getAnimationRatio(): number;
  102651. /**
  102652. * Gets an unique Id for the current render phase
  102653. * @returns a number
  102654. */
  102655. getRenderId(): number;
  102656. /**
  102657. * Gets an unique Id for the current frame
  102658. * @returns a number
  102659. */
  102660. getFrameId(): number;
  102661. /** Call this function if you want to manually increment the render Id*/
  102662. incrementRenderId(): void;
  102663. private _createUbo;
  102664. /**
  102665. * Use this method to simulate a pointer move on a mesh
  102666. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102667. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102668. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102669. * @returns the current scene
  102670. */
  102671. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102672. /**
  102673. * Use this method to simulate a pointer down on a mesh
  102674. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102675. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102676. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102677. * @returns the current scene
  102678. */
  102679. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102680. /**
  102681. * Use this method to simulate a pointer up on a mesh
  102682. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102683. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102684. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102685. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  102686. * @returns the current scene
  102687. */
  102688. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  102689. /**
  102690. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  102691. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  102692. * @returns true if the pointer was captured
  102693. */
  102694. isPointerCaptured(pointerId?: number): boolean;
  102695. /**
  102696. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  102697. * @param attachUp defines if you want to attach events to pointerup
  102698. * @param attachDown defines if you want to attach events to pointerdown
  102699. * @param attachMove defines if you want to attach events to pointermove
  102700. */
  102701. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  102702. /** Detaches all event handlers*/
  102703. detachControl(): void;
  102704. /**
  102705. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  102706. * Delay loaded resources are not taking in account
  102707. * @return true if all required resources are ready
  102708. */
  102709. isReady(): boolean;
  102710. /** Resets all cached information relative to material (including effect and visibility) */
  102711. resetCachedMaterial(): void;
  102712. /**
  102713. * Registers a function to be called before every frame render
  102714. * @param func defines the function to register
  102715. */
  102716. registerBeforeRender(func: () => void): void;
  102717. /**
  102718. * Unregisters a function called before every frame render
  102719. * @param func defines the function to unregister
  102720. */
  102721. unregisterBeforeRender(func: () => void): void;
  102722. /**
  102723. * Registers a function to be called after every frame render
  102724. * @param func defines the function to register
  102725. */
  102726. registerAfterRender(func: () => void): void;
  102727. /**
  102728. * Unregisters a function called after every frame render
  102729. * @param func defines the function to unregister
  102730. */
  102731. unregisterAfterRender(func: () => void): void;
  102732. private _executeOnceBeforeRender;
  102733. /**
  102734. * The provided function will run before render once and will be disposed afterwards.
  102735. * A timeout delay can be provided so that the function will be executed in N ms.
  102736. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  102737. * @param func The function to be executed.
  102738. * @param timeout optional delay in ms
  102739. */
  102740. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  102741. /** @hidden */
  102742. _addPendingData(data: any): void;
  102743. /** @hidden */
  102744. _removePendingData(data: any): void;
  102745. /**
  102746. * Returns the number of items waiting to be loaded
  102747. * @returns the number of items waiting to be loaded
  102748. */
  102749. getWaitingItemsCount(): number;
  102750. /**
  102751. * Returns a boolean indicating if the scene is still loading data
  102752. */
  102753. readonly isLoading: boolean;
  102754. /**
  102755. * Registers a function to be executed when the scene is ready
  102756. * @param {Function} func - the function to be executed
  102757. */
  102758. executeWhenReady(func: () => void): void;
  102759. /**
  102760. * Returns a promise that resolves when the scene is ready
  102761. * @returns A promise that resolves when the scene is ready
  102762. */
  102763. whenReadyAsync(): Promise<void>;
  102764. /** @hidden */
  102765. _checkIsReady(): void;
  102766. /**
  102767. * Gets all animatable attached to the scene
  102768. */
  102769. readonly animatables: Animatable[];
  102770. /**
  102771. * Resets the last animation time frame.
  102772. * Useful to override when animations start running when loading a scene for the first time.
  102773. */
  102774. resetLastAnimationTimeFrame(): void;
  102775. /**
  102776. * Gets the current view matrix
  102777. * @returns a Matrix
  102778. */
  102779. getViewMatrix(): Matrix;
  102780. /**
  102781. * Gets the current projection matrix
  102782. * @returns a Matrix
  102783. */
  102784. getProjectionMatrix(): Matrix;
  102785. /**
  102786. * Gets the current transform matrix
  102787. * @returns a Matrix made of View * Projection
  102788. */
  102789. getTransformMatrix(): Matrix;
  102790. /**
  102791. * Sets the current transform matrix
  102792. * @param viewL defines the View matrix to use
  102793. * @param projectionL defines the Projection matrix to use
  102794. * @param viewR defines the right View matrix to use (if provided)
  102795. * @param projectionR defines the right Projection matrix to use (if provided)
  102796. */
  102797. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  102798. /**
  102799. * Gets the uniform buffer used to store scene data
  102800. * @returns a UniformBuffer
  102801. */
  102802. getSceneUniformBuffer(): UniformBuffer;
  102803. /**
  102804. * Gets an unique (relatively to the current scene) Id
  102805. * @returns an unique number for the scene
  102806. */
  102807. getUniqueId(): number;
  102808. /**
  102809. * Add a mesh to the list of scene's meshes
  102810. * @param newMesh defines the mesh to add
  102811. * @param recursive if all child meshes should also be added to the scene
  102812. */
  102813. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  102814. /**
  102815. * Remove a mesh for the list of scene's meshes
  102816. * @param toRemove defines the mesh to remove
  102817. * @param recursive if all child meshes should also be removed from the scene
  102818. * @returns the index where the mesh was in the mesh list
  102819. */
  102820. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  102821. /**
  102822. * Add a transform node to the list of scene's transform nodes
  102823. * @param newTransformNode defines the transform node to add
  102824. */
  102825. addTransformNode(newTransformNode: TransformNode): void;
  102826. /**
  102827. * Remove a transform node for the list of scene's transform nodes
  102828. * @param toRemove defines the transform node to remove
  102829. * @returns the index where the transform node was in the transform node list
  102830. */
  102831. removeTransformNode(toRemove: TransformNode): number;
  102832. /**
  102833. * Remove a skeleton for the list of scene's skeletons
  102834. * @param toRemove defines the skeleton to remove
  102835. * @returns the index where the skeleton was in the skeleton list
  102836. */
  102837. removeSkeleton(toRemove: Skeleton): number;
  102838. /**
  102839. * Remove a morph target for the list of scene's morph targets
  102840. * @param toRemove defines the morph target to remove
  102841. * @returns the index where the morph target was in the morph target list
  102842. */
  102843. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  102844. /**
  102845. * Remove a light for the list of scene's lights
  102846. * @param toRemove defines the light to remove
  102847. * @returns the index where the light was in the light list
  102848. */
  102849. removeLight(toRemove: Light): number;
  102850. /**
  102851. * Remove a camera for the list of scene's cameras
  102852. * @param toRemove defines the camera to remove
  102853. * @returns the index where the camera was in the camera list
  102854. */
  102855. removeCamera(toRemove: Camera): number;
  102856. /**
  102857. * Remove a particle system for the list of scene's particle systems
  102858. * @param toRemove defines the particle system to remove
  102859. * @returns the index where the particle system was in the particle system list
  102860. */
  102861. removeParticleSystem(toRemove: IParticleSystem): number;
  102862. /**
  102863. * Remove a animation for the list of scene's animations
  102864. * @param toRemove defines the animation to remove
  102865. * @returns the index where the animation was in the animation list
  102866. */
  102867. removeAnimation(toRemove: Animation): number;
  102868. /**
  102869. * Will stop the animation of the given target
  102870. * @param target - the target
  102871. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  102872. * @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)
  102873. */
  102874. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  102875. /**
  102876. * Removes the given animation group from this scene.
  102877. * @param toRemove The animation group to remove
  102878. * @returns The index of the removed animation group
  102879. */
  102880. removeAnimationGroup(toRemove: AnimationGroup): number;
  102881. /**
  102882. * Removes the given multi-material from this scene.
  102883. * @param toRemove The multi-material to remove
  102884. * @returns The index of the removed multi-material
  102885. */
  102886. removeMultiMaterial(toRemove: MultiMaterial): number;
  102887. /**
  102888. * Removes the given material from this scene.
  102889. * @param toRemove The material to remove
  102890. * @returns The index of the removed material
  102891. */
  102892. removeMaterial(toRemove: Material): number;
  102893. /**
  102894. * Removes the given action manager from this scene.
  102895. * @param toRemove The action manager to remove
  102896. * @returns The index of the removed action manager
  102897. */
  102898. removeActionManager(toRemove: AbstractActionManager): number;
  102899. /**
  102900. * Removes the given texture from this scene.
  102901. * @param toRemove The texture to remove
  102902. * @returns The index of the removed texture
  102903. */
  102904. removeTexture(toRemove: BaseTexture): number;
  102905. /**
  102906. * Adds the given light to this scene
  102907. * @param newLight The light to add
  102908. */
  102909. addLight(newLight: Light): void;
  102910. /**
  102911. * Sorts the list list based on light priorities
  102912. */
  102913. sortLightsByPriority(): void;
  102914. /**
  102915. * Adds the given camera to this scene
  102916. * @param newCamera The camera to add
  102917. */
  102918. addCamera(newCamera: Camera): void;
  102919. /**
  102920. * Adds the given skeleton to this scene
  102921. * @param newSkeleton The skeleton to add
  102922. */
  102923. addSkeleton(newSkeleton: Skeleton): void;
  102924. /**
  102925. * Adds the given particle system to this scene
  102926. * @param newParticleSystem The particle system to add
  102927. */
  102928. addParticleSystem(newParticleSystem: IParticleSystem): void;
  102929. /**
  102930. * Adds the given animation to this scene
  102931. * @param newAnimation The animation to add
  102932. */
  102933. addAnimation(newAnimation: Animation): void;
  102934. /**
  102935. * Adds the given animation group to this scene.
  102936. * @param newAnimationGroup The animation group to add
  102937. */
  102938. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  102939. /**
  102940. * Adds the given multi-material to this scene
  102941. * @param newMultiMaterial The multi-material to add
  102942. */
  102943. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  102944. /**
  102945. * Adds the given material to this scene
  102946. * @param newMaterial The material to add
  102947. */
  102948. addMaterial(newMaterial: Material): void;
  102949. /**
  102950. * Adds the given morph target to this scene
  102951. * @param newMorphTargetManager The morph target to add
  102952. */
  102953. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  102954. /**
  102955. * Adds the given geometry to this scene
  102956. * @param newGeometry The geometry to add
  102957. */
  102958. addGeometry(newGeometry: Geometry): void;
  102959. /**
  102960. * Adds the given action manager to this scene
  102961. * @param newActionManager The action manager to add
  102962. */
  102963. addActionManager(newActionManager: AbstractActionManager): void;
  102964. /**
  102965. * Adds the given texture to this scene.
  102966. * @param newTexture The texture to add
  102967. */
  102968. addTexture(newTexture: BaseTexture): void;
  102969. /**
  102970. * Switch active camera
  102971. * @param newCamera defines the new active camera
  102972. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  102973. */
  102974. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  102975. /**
  102976. * sets the active camera of the scene using its ID
  102977. * @param id defines the camera's ID
  102978. * @return the new active camera or null if none found.
  102979. */
  102980. setActiveCameraByID(id: string): Nullable<Camera>;
  102981. /**
  102982. * sets the active camera of the scene using its name
  102983. * @param name defines the camera's name
  102984. * @returns the new active camera or null if none found.
  102985. */
  102986. setActiveCameraByName(name: string): Nullable<Camera>;
  102987. /**
  102988. * get an animation group using its name
  102989. * @param name defines the material's name
  102990. * @return the animation group or null if none found.
  102991. */
  102992. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  102993. /**
  102994. * Get a material using its unique id
  102995. * @param uniqueId defines the material's unique id
  102996. * @return the material or null if none found.
  102997. */
  102998. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  102999. /**
  103000. * get a material using its id
  103001. * @param id defines the material's ID
  103002. * @return the material or null if none found.
  103003. */
  103004. getMaterialByID(id: string): Nullable<Material>;
  103005. /**
  103006. * Gets a the last added material using a given id
  103007. * @param id defines the material's ID
  103008. * @return the last material with the given id or null if none found.
  103009. */
  103010. getLastMaterialByID(id: string): Nullable<Material>;
  103011. /**
  103012. * Gets a material using its name
  103013. * @param name defines the material's name
  103014. * @return the material or null if none found.
  103015. */
  103016. getMaterialByName(name: string): Nullable<Material>;
  103017. /**
  103018. * Get a texture using its unique id
  103019. * @param uniqueId defines the texture's unique id
  103020. * @return the texture or null if none found.
  103021. */
  103022. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  103023. /**
  103024. * Gets a camera using its id
  103025. * @param id defines the id to look for
  103026. * @returns the camera or null if not found
  103027. */
  103028. getCameraByID(id: string): Nullable<Camera>;
  103029. /**
  103030. * Gets a camera using its unique id
  103031. * @param uniqueId defines the unique id to look for
  103032. * @returns the camera or null if not found
  103033. */
  103034. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  103035. /**
  103036. * Gets a camera using its name
  103037. * @param name defines the camera's name
  103038. * @return the camera or null if none found.
  103039. */
  103040. getCameraByName(name: string): Nullable<Camera>;
  103041. /**
  103042. * Gets a bone using its id
  103043. * @param id defines the bone's id
  103044. * @return the bone or null if not found
  103045. */
  103046. getBoneByID(id: string): Nullable<Bone>;
  103047. /**
  103048. * Gets a bone using its id
  103049. * @param name defines the bone's name
  103050. * @return the bone or null if not found
  103051. */
  103052. getBoneByName(name: string): Nullable<Bone>;
  103053. /**
  103054. * Gets a light node using its name
  103055. * @param name defines the the light's name
  103056. * @return the light or null if none found.
  103057. */
  103058. getLightByName(name: string): Nullable<Light>;
  103059. /**
  103060. * Gets a light node using its id
  103061. * @param id defines the light's id
  103062. * @return the light or null if none found.
  103063. */
  103064. getLightByID(id: string): Nullable<Light>;
  103065. /**
  103066. * Gets a light node using its scene-generated unique ID
  103067. * @param uniqueId defines the light's unique id
  103068. * @return the light or null if none found.
  103069. */
  103070. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  103071. /**
  103072. * Gets a particle system by id
  103073. * @param id defines the particle system id
  103074. * @return the corresponding system or null if none found
  103075. */
  103076. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  103077. /**
  103078. * Gets a geometry using its ID
  103079. * @param id defines the geometry's id
  103080. * @return the geometry or null if none found.
  103081. */
  103082. getGeometryByID(id: string): Nullable<Geometry>;
  103083. private _getGeometryByUniqueID;
  103084. /**
  103085. * Add a new geometry to this scene
  103086. * @param geometry defines the geometry to be added to the scene.
  103087. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  103088. * @return a boolean defining if the geometry was added or not
  103089. */
  103090. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  103091. /**
  103092. * Removes an existing geometry
  103093. * @param geometry defines the geometry to be removed from the scene
  103094. * @return a boolean defining if the geometry was removed or not
  103095. */
  103096. removeGeometry(geometry: Geometry): boolean;
  103097. /**
  103098. * Gets the list of geometries attached to the scene
  103099. * @returns an array of Geometry
  103100. */
  103101. getGeometries(): Geometry[];
  103102. /**
  103103. * Gets the first added mesh found of a given ID
  103104. * @param id defines the id to search for
  103105. * @return the mesh found or null if not found at all
  103106. */
  103107. getMeshByID(id: string): Nullable<AbstractMesh>;
  103108. /**
  103109. * Gets a list of meshes using their id
  103110. * @param id defines the id to search for
  103111. * @returns a list of meshes
  103112. */
  103113. getMeshesByID(id: string): Array<AbstractMesh>;
  103114. /**
  103115. * Gets the first added transform node found of a given ID
  103116. * @param id defines the id to search for
  103117. * @return the found transform node or null if not found at all.
  103118. */
  103119. getTransformNodeByID(id: string): Nullable<TransformNode>;
  103120. /**
  103121. * Gets a transform node with its auto-generated unique id
  103122. * @param uniqueId efines the unique id to search for
  103123. * @return the found transform node or null if not found at all.
  103124. */
  103125. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  103126. /**
  103127. * Gets a list of transform nodes using their id
  103128. * @param id defines the id to search for
  103129. * @returns a list of transform nodes
  103130. */
  103131. getTransformNodesByID(id: string): Array<TransformNode>;
  103132. /**
  103133. * Gets a mesh with its auto-generated unique id
  103134. * @param uniqueId defines the unique id to search for
  103135. * @return the found mesh or null if not found at all.
  103136. */
  103137. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  103138. /**
  103139. * Gets a the last added mesh using a given id
  103140. * @param id defines the id to search for
  103141. * @return the found mesh or null if not found at all.
  103142. */
  103143. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  103144. /**
  103145. * Gets a the last added node (Mesh, Camera, Light) using a given id
  103146. * @param id defines the id to search for
  103147. * @return the found node or null if not found at all
  103148. */
  103149. getLastEntryByID(id: string): Nullable<Node>;
  103150. /**
  103151. * Gets a node (Mesh, Camera, Light) using a given id
  103152. * @param id defines the id to search for
  103153. * @return the found node or null if not found at all
  103154. */
  103155. getNodeByID(id: string): Nullable<Node>;
  103156. /**
  103157. * Gets a node (Mesh, Camera, Light) using a given name
  103158. * @param name defines the name to search for
  103159. * @return the found node or null if not found at all.
  103160. */
  103161. getNodeByName(name: string): Nullable<Node>;
  103162. /**
  103163. * Gets a mesh using a given name
  103164. * @param name defines the name to search for
  103165. * @return the found mesh or null if not found at all.
  103166. */
  103167. getMeshByName(name: string): Nullable<AbstractMesh>;
  103168. /**
  103169. * Gets a transform node using a given name
  103170. * @param name defines the name to search for
  103171. * @return the found transform node or null if not found at all.
  103172. */
  103173. getTransformNodeByName(name: string): Nullable<TransformNode>;
  103174. /**
  103175. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  103176. * @param id defines the id to search for
  103177. * @return the found skeleton or null if not found at all.
  103178. */
  103179. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  103180. /**
  103181. * Gets a skeleton using a given auto generated unique id
  103182. * @param uniqueId defines the unique id to search for
  103183. * @return the found skeleton or null if not found at all.
  103184. */
  103185. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  103186. /**
  103187. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  103188. * @param id defines the id to search for
  103189. * @return the found skeleton or null if not found at all.
  103190. */
  103191. getSkeletonById(id: string): Nullable<Skeleton>;
  103192. /**
  103193. * Gets a skeleton using a given name
  103194. * @param name defines the name to search for
  103195. * @return the found skeleton or null if not found at all.
  103196. */
  103197. getSkeletonByName(name: string): Nullable<Skeleton>;
  103198. /**
  103199. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  103200. * @param id defines the id to search for
  103201. * @return the found morph target manager or null if not found at all.
  103202. */
  103203. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  103204. /**
  103205. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  103206. * @param id defines the id to search for
  103207. * @return the found morph target or null if not found at all.
  103208. */
  103209. getMorphTargetById(id: string): Nullable<MorphTarget>;
  103210. /**
  103211. * Gets a boolean indicating if the given mesh is active
  103212. * @param mesh defines the mesh to look for
  103213. * @returns true if the mesh is in the active list
  103214. */
  103215. isActiveMesh(mesh: AbstractMesh): boolean;
  103216. /**
  103217. * Return a unique id as a string which can serve as an identifier for the scene
  103218. */
  103219. readonly uid: string;
  103220. /**
  103221. * Add an externaly attached data from its key.
  103222. * This method call will fail and return false, if such key already exists.
  103223. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  103224. * @param key the unique key that identifies the data
  103225. * @param data the data object to associate to the key for this Engine instance
  103226. * @return true if no such key were already present and the data was added successfully, false otherwise
  103227. */
  103228. addExternalData<T>(key: string, data: T): boolean;
  103229. /**
  103230. * Get an externaly attached data from its key
  103231. * @param key the unique key that identifies the data
  103232. * @return the associated data, if present (can be null), or undefined if not present
  103233. */
  103234. getExternalData<T>(key: string): Nullable<T>;
  103235. /**
  103236. * Get an externaly attached data from its key, create it using a factory if it's not already present
  103237. * @param key the unique key that identifies the data
  103238. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  103239. * @return the associated data, can be null if the factory returned null.
  103240. */
  103241. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  103242. /**
  103243. * Remove an externaly attached data from the Engine instance
  103244. * @param key the unique key that identifies the data
  103245. * @return true if the data was successfully removed, false if it doesn't exist
  103246. */
  103247. removeExternalData(key: string): boolean;
  103248. private _evaluateSubMesh;
  103249. /**
  103250. * Clear the processed materials smart array preventing retention point in material dispose.
  103251. */
  103252. freeProcessedMaterials(): void;
  103253. private _preventFreeActiveMeshesAndRenderingGroups;
  103254. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  103255. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  103256. * when disposing several meshes in a row or a hierarchy of meshes.
  103257. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  103258. */
  103259. blockfreeActiveMeshesAndRenderingGroups: boolean;
  103260. /**
  103261. * Clear the active meshes smart array preventing retention point in mesh dispose.
  103262. */
  103263. freeActiveMeshes(): void;
  103264. /**
  103265. * Clear the info related to rendering groups preventing retention points during dispose.
  103266. */
  103267. freeRenderingGroups(): void;
  103268. /** @hidden */
  103269. _isInIntermediateRendering(): boolean;
  103270. /**
  103271. * Lambda returning the list of potentially active meshes.
  103272. */
  103273. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  103274. /**
  103275. * Lambda returning the list of potentially active sub meshes.
  103276. */
  103277. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  103278. /**
  103279. * Lambda returning the list of potentially intersecting sub meshes.
  103280. */
  103281. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  103282. /**
  103283. * Lambda returning the list of potentially colliding sub meshes.
  103284. */
  103285. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  103286. private _activeMeshesFrozen;
  103287. private _skipEvaluateActiveMeshesCompletely;
  103288. /**
  103289. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  103290. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  103291. * @returns the current scene
  103292. */
  103293. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  103294. /**
  103295. * Use this function to restart evaluating active meshes on every frame
  103296. * @returns the current scene
  103297. */
  103298. unfreezeActiveMeshes(): Scene;
  103299. private _evaluateActiveMeshes;
  103300. private _activeMesh;
  103301. /**
  103302. * Update the transform matrix to update from the current active camera
  103303. * @param force defines a boolean used to force the update even if cache is up to date
  103304. */
  103305. updateTransformMatrix(force?: boolean): void;
  103306. private _bindFrameBuffer;
  103307. /** @hidden */
  103308. _allowPostProcessClearColor: boolean;
  103309. /** @hidden */
  103310. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  103311. private _processSubCameras;
  103312. private _checkIntersections;
  103313. /** @hidden */
  103314. _advancePhysicsEngineStep(step: number): void;
  103315. /**
  103316. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  103317. */
  103318. getDeterministicFrameTime: () => number;
  103319. /** @hidden */
  103320. _animate(): void;
  103321. /** Execute all animations (for a frame) */
  103322. animate(): void;
  103323. /**
  103324. * Render the scene
  103325. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  103326. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  103327. */
  103328. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  103329. /**
  103330. * Freeze all materials
  103331. * A frozen material will not be updatable but should be faster to render
  103332. */
  103333. freezeMaterials(): void;
  103334. /**
  103335. * Unfreeze all materials
  103336. * A frozen material will not be updatable but should be faster to render
  103337. */
  103338. unfreezeMaterials(): void;
  103339. /**
  103340. * Releases all held ressources
  103341. */
  103342. dispose(): void;
  103343. /**
  103344. * Gets if the scene is already disposed
  103345. */
  103346. readonly isDisposed: boolean;
  103347. /**
  103348. * Call this function to reduce memory footprint of the scene.
  103349. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  103350. */
  103351. clearCachedVertexData(): void;
  103352. /**
  103353. * This function will remove the local cached buffer data from texture.
  103354. * It will save memory but will prevent the texture from being rebuilt
  103355. */
  103356. cleanCachedTextureBuffer(): void;
  103357. /**
  103358. * Get the world extend vectors with an optional filter
  103359. *
  103360. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  103361. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  103362. */
  103363. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  103364. min: Vector3;
  103365. max: Vector3;
  103366. };
  103367. /**
  103368. * Creates a ray that can be used to pick in the scene
  103369. * @param x defines the x coordinate of the origin (on-screen)
  103370. * @param y defines the y coordinate of the origin (on-screen)
  103371. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  103372. * @param camera defines the camera to use for the picking
  103373. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  103374. * @returns a Ray
  103375. */
  103376. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  103377. /**
  103378. * Creates a ray that can be used to pick in the scene
  103379. * @param x defines the x coordinate of the origin (on-screen)
  103380. * @param y defines the y coordinate of the origin (on-screen)
  103381. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  103382. * @param result defines the ray where to store the picking ray
  103383. * @param camera defines the camera to use for the picking
  103384. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  103385. * @returns the current scene
  103386. */
  103387. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  103388. /**
  103389. * Creates a ray that can be used to pick in the scene
  103390. * @param x defines the x coordinate of the origin (on-screen)
  103391. * @param y defines the y coordinate of the origin (on-screen)
  103392. * @param camera defines the camera to use for the picking
  103393. * @returns a Ray
  103394. */
  103395. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  103396. /**
  103397. * Creates a ray that can be used to pick in the scene
  103398. * @param x defines the x coordinate of the origin (on-screen)
  103399. * @param y defines the y coordinate of the origin (on-screen)
  103400. * @param result defines the ray where to store the picking ray
  103401. * @param camera defines the camera to use for the picking
  103402. * @returns the current scene
  103403. */
  103404. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  103405. /** Launch a ray to try to pick a mesh in the scene
  103406. * @param x position on screen
  103407. * @param y position on screen
  103408. * @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
  103409. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  103410. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103411. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103412. * @returns a PickingInfo
  103413. */
  103414. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103415. /** Use the given ray to pick a mesh in the scene
  103416. * @param ray The ray to use to pick meshes
  103417. * @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
  103418. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  103419. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103420. * @returns a PickingInfo
  103421. */
  103422. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103423. /**
  103424. * Launch a ray to try to pick a mesh in the scene
  103425. * @param x X position on screen
  103426. * @param y Y position on screen
  103427. * @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
  103428. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103429. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103430. * @returns an array of PickingInfo
  103431. */
  103432. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103433. /**
  103434. * Launch a ray to try to pick a mesh in the scene
  103435. * @param ray Ray to use
  103436. * @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
  103437. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103438. * @returns an array of PickingInfo
  103439. */
  103440. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103441. /**
  103442. * Force the value of meshUnderPointer
  103443. * @param mesh defines the mesh to use
  103444. */
  103445. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  103446. /**
  103447. * Gets the mesh under the pointer
  103448. * @returns a Mesh or null if no mesh is under the pointer
  103449. */
  103450. getPointerOverMesh(): Nullable<AbstractMesh>;
  103451. /** @hidden */
  103452. _rebuildGeometries(): void;
  103453. /** @hidden */
  103454. _rebuildTextures(): void;
  103455. private _getByTags;
  103456. /**
  103457. * Get a list of meshes by tags
  103458. * @param tagsQuery defines the tags query to use
  103459. * @param forEach defines a predicate used to filter results
  103460. * @returns an array of Mesh
  103461. */
  103462. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  103463. /**
  103464. * Get a list of cameras by tags
  103465. * @param tagsQuery defines the tags query to use
  103466. * @param forEach defines a predicate used to filter results
  103467. * @returns an array of Camera
  103468. */
  103469. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  103470. /**
  103471. * Get a list of lights by tags
  103472. * @param tagsQuery defines the tags query to use
  103473. * @param forEach defines a predicate used to filter results
  103474. * @returns an array of Light
  103475. */
  103476. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  103477. /**
  103478. * Get a list of materials by tags
  103479. * @param tagsQuery defines the tags query to use
  103480. * @param forEach defines a predicate used to filter results
  103481. * @returns an array of Material
  103482. */
  103483. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  103484. /**
  103485. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  103486. * This allowed control for front to back rendering or reversly depending of the special needs.
  103487. *
  103488. * @param renderingGroupId The rendering group id corresponding to its index
  103489. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  103490. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  103491. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  103492. */
  103493. 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;
  103494. /**
  103495. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  103496. *
  103497. * @param renderingGroupId The rendering group id corresponding to its index
  103498. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103499. * @param depth Automatically clears depth between groups if true and autoClear is true.
  103500. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  103501. */
  103502. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  103503. /**
  103504. * Gets the current auto clear configuration for one rendering group of the rendering
  103505. * manager.
  103506. * @param index the rendering group index to get the information for
  103507. * @returns The auto clear setup for the requested rendering group
  103508. */
  103509. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  103510. private _blockMaterialDirtyMechanism;
  103511. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  103512. blockMaterialDirtyMechanism: boolean;
  103513. /**
  103514. * Will flag all materials as dirty to trigger new shader compilation
  103515. * @param flag defines the flag used to specify which material part must be marked as dirty
  103516. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  103517. */
  103518. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  103519. /** @hidden */
  103520. _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;
  103521. /** @hidden */
  103522. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103523. /** @hidden */
  103524. _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;
  103525. /** @hidden */
  103526. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  103527. /** @hidden */
  103528. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  103529. /** @hidden */
  103530. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103531. }
  103532. }
  103533. declare module BABYLON {
  103534. /**
  103535. * Set of assets to keep when moving a scene into an asset container.
  103536. */
  103537. export class KeepAssets extends AbstractScene {
  103538. }
  103539. /**
  103540. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  103541. */
  103542. export class InstantiatedEntries {
  103543. /**
  103544. * List of new root nodes (eg. nodes with no parent)
  103545. */
  103546. rootNodes: TransformNode[];
  103547. /**
  103548. * List of new skeletons
  103549. */
  103550. skeletons: Skeleton[];
  103551. /**
  103552. * List of new animation groups
  103553. */
  103554. animationGroups: AnimationGroup[];
  103555. }
  103556. /**
  103557. * Container with a set of assets that can be added or removed from a scene.
  103558. */
  103559. export class AssetContainer extends AbstractScene {
  103560. /**
  103561. * The scene the AssetContainer belongs to.
  103562. */
  103563. scene: Scene;
  103564. /**
  103565. * Instantiates an AssetContainer.
  103566. * @param scene The scene the AssetContainer belongs to.
  103567. */
  103568. constructor(scene: Scene);
  103569. /**
  103570. * Instantiate or clone all meshes and add the new ones to the scene.
  103571. * Skeletons and animation groups will all be cloned
  103572. * @param nameFunction defines an optional function used to get new names for clones
  103573. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  103574. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  103575. */
  103576. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  103577. /**
  103578. * Adds all the assets from the container to the scene.
  103579. */
  103580. addAllToScene(): void;
  103581. /**
  103582. * Removes all the assets in the container from the scene
  103583. */
  103584. removeAllFromScene(): void;
  103585. /**
  103586. * Disposes all the assets in the container
  103587. */
  103588. dispose(): void;
  103589. private _moveAssets;
  103590. /**
  103591. * Removes all the assets contained in the scene and adds them to the container.
  103592. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  103593. */
  103594. moveAllFromScene(keepAssets?: KeepAssets): void;
  103595. /**
  103596. * 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.
  103597. * @returns the root mesh
  103598. */
  103599. createRootMesh(): Mesh;
  103600. }
  103601. }
  103602. declare module BABYLON {
  103603. /**
  103604. * Defines how the parser contract is defined.
  103605. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  103606. */
  103607. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  103608. /**
  103609. * Defines how the individual parser contract is defined.
  103610. * These parser can parse an individual asset
  103611. */
  103612. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  103613. /**
  103614. * Base class of the scene acting as a container for the different elements composing a scene.
  103615. * This class is dynamically extended by the different components of the scene increasing
  103616. * flexibility and reducing coupling
  103617. */
  103618. export abstract class AbstractScene {
  103619. /**
  103620. * Stores the list of available parsers in the application.
  103621. */
  103622. private static _BabylonFileParsers;
  103623. /**
  103624. * Stores the list of available individual parsers in the application.
  103625. */
  103626. private static _IndividualBabylonFileParsers;
  103627. /**
  103628. * Adds a parser in the list of available ones
  103629. * @param name Defines the name of the parser
  103630. * @param parser Defines the parser to add
  103631. */
  103632. static AddParser(name: string, parser: BabylonFileParser): void;
  103633. /**
  103634. * Gets a general parser from the list of avaialble ones
  103635. * @param name Defines the name of the parser
  103636. * @returns the requested parser or null
  103637. */
  103638. static GetParser(name: string): Nullable<BabylonFileParser>;
  103639. /**
  103640. * Adds n individual parser in the list of available ones
  103641. * @param name Defines the name of the parser
  103642. * @param parser Defines the parser to add
  103643. */
  103644. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  103645. /**
  103646. * Gets an individual parser from the list of avaialble ones
  103647. * @param name Defines the name of the parser
  103648. * @returns the requested parser or null
  103649. */
  103650. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  103651. /**
  103652. * Parser json data and populate both a scene and its associated container object
  103653. * @param jsonData Defines the data to parse
  103654. * @param scene Defines the scene to parse the data for
  103655. * @param container Defines the container attached to the parsing sequence
  103656. * @param rootUrl Defines the root url of the data
  103657. */
  103658. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  103659. /**
  103660. * Gets the list of root nodes (ie. nodes with no parent)
  103661. */
  103662. rootNodes: Node[];
  103663. /** All of the cameras added to this scene
  103664. * @see http://doc.babylonjs.com/babylon101/cameras
  103665. */
  103666. cameras: Camera[];
  103667. /**
  103668. * All of the lights added to this scene
  103669. * @see http://doc.babylonjs.com/babylon101/lights
  103670. */
  103671. lights: Light[];
  103672. /**
  103673. * All of the (abstract) meshes added to this scene
  103674. */
  103675. meshes: AbstractMesh[];
  103676. /**
  103677. * The list of skeletons added to the scene
  103678. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  103679. */
  103680. skeletons: Skeleton[];
  103681. /**
  103682. * All of the particle systems added to this scene
  103683. * @see http://doc.babylonjs.com/babylon101/particles
  103684. */
  103685. particleSystems: IParticleSystem[];
  103686. /**
  103687. * Gets a list of Animations associated with the scene
  103688. */
  103689. animations: Animation[];
  103690. /**
  103691. * All of the animation groups added to this scene
  103692. * @see http://doc.babylonjs.com/how_to/group
  103693. */
  103694. animationGroups: AnimationGroup[];
  103695. /**
  103696. * All of the multi-materials added to this scene
  103697. * @see http://doc.babylonjs.com/how_to/multi_materials
  103698. */
  103699. multiMaterials: MultiMaterial[];
  103700. /**
  103701. * All of the materials added to this scene
  103702. * In the context of a Scene, it is not supposed to be modified manually.
  103703. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  103704. * Note also that the order of the Material within the array is not significant and might change.
  103705. * @see http://doc.babylonjs.com/babylon101/materials
  103706. */
  103707. materials: Material[];
  103708. /**
  103709. * The list of morph target managers added to the scene
  103710. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  103711. */
  103712. morphTargetManagers: MorphTargetManager[];
  103713. /**
  103714. * The list of geometries used in the scene.
  103715. */
  103716. geometries: Geometry[];
  103717. /**
  103718. * All of the tranform nodes added to this scene
  103719. * In the context of a Scene, it is not supposed to be modified manually.
  103720. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  103721. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  103722. * @see http://doc.babylonjs.com/how_to/transformnode
  103723. */
  103724. transformNodes: TransformNode[];
  103725. /**
  103726. * ActionManagers available on the scene.
  103727. */
  103728. actionManagers: AbstractActionManager[];
  103729. /**
  103730. * Textures to keep.
  103731. */
  103732. textures: BaseTexture[];
  103733. /**
  103734. * Environment texture for the scene
  103735. */
  103736. environmentTexture: Nullable<BaseTexture>;
  103737. }
  103738. }
  103739. declare module BABYLON {
  103740. /**
  103741. * Interface used to define options for Sound class
  103742. */
  103743. export interface ISoundOptions {
  103744. /**
  103745. * Does the sound autoplay once loaded.
  103746. */
  103747. autoplay?: boolean;
  103748. /**
  103749. * Does the sound loop after it finishes playing once.
  103750. */
  103751. loop?: boolean;
  103752. /**
  103753. * Sound's volume
  103754. */
  103755. volume?: number;
  103756. /**
  103757. * Is it a spatial sound?
  103758. */
  103759. spatialSound?: boolean;
  103760. /**
  103761. * Maximum distance to hear that sound
  103762. */
  103763. maxDistance?: number;
  103764. /**
  103765. * Uses user defined attenuation function
  103766. */
  103767. useCustomAttenuation?: boolean;
  103768. /**
  103769. * Define the roll off factor of spatial sounds.
  103770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103771. */
  103772. rolloffFactor?: number;
  103773. /**
  103774. * Define the reference distance the sound should be heard perfectly.
  103775. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103776. */
  103777. refDistance?: number;
  103778. /**
  103779. * Define the distance attenuation model the sound will follow.
  103780. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103781. */
  103782. distanceModel?: string;
  103783. /**
  103784. * Defines the playback speed (1 by default)
  103785. */
  103786. playbackRate?: number;
  103787. /**
  103788. * Defines if the sound is from a streaming source
  103789. */
  103790. streaming?: boolean;
  103791. /**
  103792. * Defines an optional length (in seconds) inside the sound file
  103793. */
  103794. length?: number;
  103795. /**
  103796. * Defines an optional offset (in seconds) inside the sound file
  103797. */
  103798. offset?: number;
  103799. /**
  103800. * If true, URLs will not be required to state the audio file codec to use.
  103801. */
  103802. skipCodecCheck?: boolean;
  103803. }
  103804. /**
  103805. * Defines a sound that can be played in the application.
  103806. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  103807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103808. */
  103809. export class Sound {
  103810. /**
  103811. * The name of the sound in the scene.
  103812. */
  103813. name: string;
  103814. /**
  103815. * Does the sound autoplay once loaded.
  103816. */
  103817. autoplay: boolean;
  103818. /**
  103819. * Does the sound loop after it finishes playing once.
  103820. */
  103821. loop: boolean;
  103822. /**
  103823. * Does the sound use a custom attenuation curve to simulate the falloff
  103824. * happening when the source gets further away from the camera.
  103825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103826. */
  103827. useCustomAttenuation: boolean;
  103828. /**
  103829. * The sound track id this sound belongs to.
  103830. */
  103831. soundTrackId: number;
  103832. /**
  103833. * Is this sound currently played.
  103834. */
  103835. isPlaying: boolean;
  103836. /**
  103837. * Is this sound currently paused.
  103838. */
  103839. isPaused: boolean;
  103840. /**
  103841. * Does this sound enables spatial sound.
  103842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103843. */
  103844. spatialSound: boolean;
  103845. /**
  103846. * Define the reference distance the sound should be heard perfectly.
  103847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103848. */
  103849. refDistance: number;
  103850. /**
  103851. * Define the roll off factor of spatial sounds.
  103852. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103853. */
  103854. rolloffFactor: number;
  103855. /**
  103856. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  103857. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103858. */
  103859. maxDistance: number;
  103860. /**
  103861. * Define the distance attenuation model the sound will follow.
  103862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103863. */
  103864. distanceModel: string;
  103865. /**
  103866. * @hidden
  103867. * Back Compat
  103868. **/
  103869. onended: () => any;
  103870. /**
  103871. * Observable event when the current playing sound finishes.
  103872. */
  103873. onEndedObservable: Observable<Sound>;
  103874. private _panningModel;
  103875. private _playbackRate;
  103876. private _streaming;
  103877. private _startTime;
  103878. private _startOffset;
  103879. private _position;
  103880. /** @hidden */
  103881. _positionInEmitterSpace: boolean;
  103882. private _localDirection;
  103883. private _volume;
  103884. private _isReadyToPlay;
  103885. private _isDirectional;
  103886. private _readyToPlayCallback;
  103887. private _audioBuffer;
  103888. private _soundSource;
  103889. private _streamingSource;
  103890. private _soundPanner;
  103891. private _soundGain;
  103892. private _inputAudioNode;
  103893. private _outputAudioNode;
  103894. private _coneInnerAngle;
  103895. private _coneOuterAngle;
  103896. private _coneOuterGain;
  103897. private _scene;
  103898. private _connectedTransformNode;
  103899. private _customAttenuationFunction;
  103900. private _registerFunc;
  103901. private _isOutputConnected;
  103902. private _htmlAudioElement;
  103903. private _urlType;
  103904. private _length?;
  103905. private _offset?;
  103906. /** @hidden */
  103907. static _SceneComponentInitialization: (scene: Scene) => void;
  103908. /**
  103909. * Create a sound and attach it to a scene
  103910. * @param name Name of your sound
  103911. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  103912. * @param scene defines the scene the sound belongs to
  103913. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  103914. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  103915. */
  103916. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  103917. /**
  103918. * Release the sound and its associated resources
  103919. */
  103920. dispose(): void;
  103921. /**
  103922. * Gets if the sounds is ready to be played or not.
  103923. * @returns true if ready, otherwise false
  103924. */
  103925. isReady(): boolean;
  103926. private _soundLoaded;
  103927. /**
  103928. * Sets the data of the sound from an audiobuffer
  103929. * @param audioBuffer The audioBuffer containing the data
  103930. */
  103931. setAudioBuffer(audioBuffer: AudioBuffer): void;
  103932. /**
  103933. * Updates the current sounds options such as maxdistance, loop...
  103934. * @param options A JSON object containing values named as the object properties
  103935. */
  103936. updateOptions(options: ISoundOptions): void;
  103937. private _createSpatialParameters;
  103938. private _updateSpatialParameters;
  103939. /**
  103940. * Switch the panning model to HRTF:
  103941. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  103942. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103943. */
  103944. switchPanningModelToHRTF(): void;
  103945. /**
  103946. * Switch the panning model to Equal Power:
  103947. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  103948. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103949. */
  103950. switchPanningModelToEqualPower(): void;
  103951. private _switchPanningModel;
  103952. /**
  103953. * Connect this sound to a sound track audio node like gain...
  103954. * @param soundTrackAudioNode the sound track audio node to connect to
  103955. */
  103956. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  103957. /**
  103958. * Transform this sound into a directional source
  103959. * @param coneInnerAngle Size of the inner cone in degree
  103960. * @param coneOuterAngle Size of the outer cone in degree
  103961. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  103962. */
  103963. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  103964. /**
  103965. * Gets or sets the inner angle for the directional cone.
  103966. */
  103967. /**
  103968. * Gets or sets the inner angle for the directional cone.
  103969. */
  103970. directionalConeInnerAngle: number;
  103971. /**
  103972. * Gets or sets the outer angle for the directional cone.
  103973. */
  103974. /**
  103975. * Gets or sets the outer angle for the directional cone.
  103976. */
  103977. directionalConeOuterAngle: number;
  103978. /**
  103979. * Sets the position of the emitter if spatial sound is enabled
  103980. * @param newPosition Defines the new posisiton
  103981. */
  103982. setPosition(newPosition: Vector3): void;
  103983. /**
  103984. * Sets the local direction of the emitter if spatial sound is enabled
  103985. * @param newLocalDirection Defines the new local direction
  103986. */
  103987. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  103988. private _updateDirection;
  103989. /** @hidden */
  103990. updateDistanceFromListener(): void;
  103991. /**
  103992. * Sets a new custom attenuation function for the sound.
  103993. * @param callback Defines the function used for the attenuation
  103994. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103995. */
  103996. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  103997. /**
  103998. * Play the sound
  103999. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  104000. * @param offset (optional) Start the sound at a specific time in seconds
  104001. * @param length (optional) Sound duration (in seconds)
  104002. */
  104003. play(time?: number, offset?: number, length?: number): void;
  104004. private _onended;
  104005. /**
  104006. * Stop the sound
  104007. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  104008. */
  104009. stop(time?: number): void;
  104010. /**
  104011. * Put the sound in pause
  104012. */
  104013. pause(): void;
  104014. /**
  104015. * Sets a dedicated volume for this sounds
  104016. * @param newVolume Define the new volume of the sound
  104017. * @param time Define time for gradual change to new volume
  104018. */
  104019. setVolume(newVolume: number, time?: number): void;
  104020. /**
  104021. * Set the sound play back rate
  104022. * @param newPlaybackRate Define the playback rate the sound should be played at
  104023. */
  104024. setPlaybackRate(newPlaybackRate: number): void;
  104025. /**
  104026. * Gets the volume of the sound.
  104027. * @returns the volume of the sound
  104028. */
  104029. getVolume(): number;
  104030. /**
  104031. * Attach the sound to a dedicated mesh
  104032. * @param transformNode The transform node to connect the sound with
  104033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  104034. */
  104035. attachToMesh(transformNode: TransformNode): void;
  104036. /**
  104037. * Detach the sound from the previously attached mesh
  104038. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  104039. */
  104040. detachFromMesh(): void;
  104041. private _onRegisterAfterWorldMatrixUpdate;
  104042. /**
  104043. * Clone the current sound in the scene.
  104044. * @returns the new sound clone
  104045. */
  104046. clone(): Nullable<Sound>;
  104047. /**
  104048. * Gets the current underlying audio buffer containing the data
  104049. * @returns the audio buffer
  104050. */
  104051. getAudioBuffer(): Nullable<AudioBuffer>;
  104052. /**
  104053. * Serializes the Sound in a JSON representation
  104054. * @returns the JSON representation of the sound
  104055. */
  104056. serialize(): any;
  104057. /**
  104058. * Parse a JSON representation of a sound to innstantiate in a given scene
  104059. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  104060. * @param scene Define the scene the new parsed sound should be created in
  104061. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  104062. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  104063. * @returns the newly parsed sound
  104064. */
  104065. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  104066. }
  104067. }
  104068. declare module BABYLON {
  104069. /**
  104070. * This defines an action helpful to play a defined sound on a triggered action.
  104071. */
  104072. export class PlaySoundAction extends Action {
  104073. private _sound;
  104074. /**
  104075. * Instantiate the action
  104076. * @param triggerOptions defines the trigger options
  104077. * @param sound defines the sound to play
  104078. * @param condition defines the trigger related conditions
  104079. */
  104080. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  104081. /** @hidden */
  104082. _prepare(): void;
  104083. /**
  104084. * Execute the action and play the sound.
  104085. */
  104086. execute(): void;
  104087. /**
  104088. * Serializes the actions and its related information.
  104089. * @param parent defines the object to serialize in
  104090. * @returns the serialized object
  104091. */
  104092. serialize(parent: any): any;
  104093. }
  104094. /**
  104095. * This defines an action helpful to stop a defined sound on a triggered action.
  104096. */
  104097. export class StopSoundAction extends Action {
  104098. private _sound;
  104099. /**
  104100. * Instantiate the action
  104101. * @param triggerOptions defines the trigger options
  104102. * @param sound defines the sound to stop
  104103. * @param condition defines the trigger related conditions
  104104. */
  104105. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  104106. /** @hidden */
  104107. _prepare(): void;
  104108. /**
  104109. * Execute the action and stop the sound.
  104110. */
  104111. execute(): void;
  104112. /**
  104113. * Serializes the actions and its related information.
  104114. * @param parent defines the object to serialize in
  104115. * @returns the serialized object
  104116. */
  104117. serialize(parent: any): any;
  104118. }
  104119. }
  104120. declare module BABYLON {
  104121. /**
  104122. * This defines an action responsible to change the value of a property
  104123. * by interpolating between its current value and the newly set one once triggered.
  104124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  104125. */
  104126. export class InterpolateValueAction extends Action {
  104127. /**
  104128. * Defines the path of the property where the value should be interpolated
  104129. */
  104130. propertyPath: string;
  104131. /**
  104132. * Defines the target value at the end of the interpolation.
  104133. */
  104134. value: any;
  104135. /**
  104136. * Defines the time it will take for the property to interpolate to the value.
  104137. */
  104138. duration: number;
  104139. /**
  104140. * Defines if the other scene animations should be stopped when the action has been triggered
  104141. */
  104142. stopOtherAnimations?: boolean;
  104143. /**
  104144. * Defines a callback raised once the interpolation animation has been done.
  104145. */
  104146. onInterpolationDone?: () => void;
  104147. /**
  104148. * Observable triggered once the interpolation animation has been done.
  104149. */
  104150. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  104151. private _target;
  104152. private _effectiveTarget;
  104153. private _property;
  104154. /**
  104155. * Instantiate the action
  104156. * @param triggerOptions defines the trigger options
  104157. * @param target defines the object containing the value to interpolate
  104158. * @param propertyPath defines the path to the property in the target object
  104159. * @param value defines the target value at the end of the interpolation
  104160. * @param duration deines the time it will take for the property to interpolate to the value.
  104161. * @param condition defines the trigger related conditions
  104162. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  104163. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  104164. */
  104165. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  104166. /** @hidden */
  104167. _prepare(): void;
  104168. /**
  104169. * Execute the action starts the value interpolation.
  104170. */
  104171. execute(): void;
  104172. /**
  104173. * Serializes the actions and its related information.
  104174. * @param parent defines the object to serialize in
  104175. * @returns the serialized object
  104176. */
  104177. serialize(parent: any): any;
  104178. }
  104179. }
  104180. declare module BABYLON {
  104181. /**
  104182. * Options allowed during the creation of a sound track.
  104183. */
  104184. export interface ISoundTrackOptions {
  104185. /**
  104186. * The volume the sound track should take during creation
  104187. */
  104188. volume?: number;
  104189. /**
  104190. * Define if the sound track is the main sound track of the scene
  104191. */
  104192. mainTrack?: boolean;
  104193. }
  104194. /**
  104195. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  104196. * It will be also used in a future release to apply effects on a specific track.
  104197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  104198. */
  104199. export class SoundTrack {
  104200. /**
  104201. * The unique identifier of the sound track in the scene.
  104202. */
  104203. id: number;
  104204. /**
  104205. * The list of sounds included in the sound track.
  104206. */
  104207. soundCollection: Array<Sound>;
  104208. private _outputAudioNode;
  104209. private _scene;
  104210. private _connectedAnalyser;
  104211. private _options;
  104212. private _isInitialized;
  104213. /**
  104214. * Creates a new sound track.
  104215. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  104216. * @param scene Define the scene the sound track belongs to
  104217. * @param options
  104218. */
  104219. constructor(scene: Scene, options?: ISoundTrackOptions);
  104220. private _initializeSoundTrackAudioGraph;
  104221. /**
  104222. * Release the sound track and its associated resources
  104223. */
  104224. dispose(): void;
  104225. /**
  104226. * Adds a sound to this sound track
  104227. * @param sound define the cound to add
  104228. * @ignoreNaming
  104229. */
  104230. AddSound(sound: Sound): void;
  104231. /**
  104232. * Removes a sound to this sound track
  104233. * @param sound define the cound to remove
  104234. * @ignoreNaming
  104235. */
  104236. RemoveSound(sound: Sound): void;
  104237. /**
  104238. * Set a global volume for the full sound track.
  104239. * @param newVolume Define the new volume of the sound track
  104240. */
  104241. setVolume(newVolume: number): void;
  104242. /**
  104243. * Switch the panning model to HRTF:
  104244. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  104245. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104246. */
  104247. switchPanningModelToHRTF(): void;
  104248. /**
  104249. * Switch the panning model to Equal Power:
  104250. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  104251. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104252. */
  104253. switchPanningModelToEqualPower(): void;
  104254. /**
  104255. * Connect the sound track to an audio analyser allowing some amazing
  104256. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  104257. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  104258. * @param analyser The analyser to connect to the engine
  104259. */
  104260. connectToAnalyser(analyser: Analyser): void;
  104261. }
  104262. }
  104263. declare module BABYLON {
  104264. interface AbstractScene {
  104265. /**
  104266. * The list of sounds used in the scene.
  104267. */
  104268. sounds: Nullable<Array<Sound>>;
  104269. }
  104270. interface Scene {
  104271. /**
  104272. * @hidden
  104273. * Backing field
  104274. */
  104275. _mainSoundTrack: SoundTrack;
  104276. /**
  104277. * The main sound track played by the scene.
  104278. * It cotains your primary collection of sounds.
  104279. */
  104280. mainSoundTrack: SoundTrack;
  104281. /**
  104282. * The list of sound tracks added to the scene
  104283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104284. */
  104285. soundTracks: Nullable<Array<SoundTrack>>;
  104286. /**
  104287. * Gets a sound using a given name
  104288. * @param name defines the name to search for
  104289. * @return the found sound or null if not found at all.
  104290. */
  104291. getSoundByName(name: string): Nullable<Sound>;
  104292. /**
  104293. * Gets or sets if audio support is enabled
  104294. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104295. */
  104296. audioEnabled: boolean;
  104297. /**
  104298. * Gets or sets if audio will be output to headphones
  104299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104300. */
  104301. headphone: boolean;
  104302. /**
  104303. * Gets or sets custom audio listener position provider
  104304. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104305. */
  104306. audioListenerPositionProvider: Nullable<() => Vector3>;
  104307. /**
  104308. * Gets or sets a refresh rate when using 3D audio positioning
  104309. */
  104310. audioPositioningRefreshRate: number;
  104311. }
  104312. /**
  104313. * Defines the sound scene component responsible to manage any sounds
  104314. * in a given scene.
  104315. */
  104316. export class AudioSceneComponent implements ISceneSerializableComponent {
  104317. /**
  104318. * The component name helpfull to identify the component in the list of scene components.
  104319. */
  104320. readonly name: string;
  104321. /**
  104322. * The scene the component belongs to.
  104323. */
  104324. scene: Scene;
  104325. private _audioEnabled;
  104326. /**
  104327. * Gets whether audio is enabled or not.
  104328. * Please use related enable/disable method to switch state.
  104329. */
  104330. readonly audioEnabled: boolean;
  104331. private _headphone;
  104332. /**
  104333. * Gets whether audio is outputing to headphone or not.
  104334. * Please use the according Switch methods to change output.
  104335. */
  104336. readonly headphone: boolean;
  104337. /**
  104338. * Gets or sets a refresh rate when using 3D audio positioning
  104339. */
  104340. audioPositioningRefreshRate: number;
  104341. private _audioListenerPositionProvider;
  104342. /**
  104343. * Gets the current audio listener position provider
  104344. */
  104345. /**
  104346. * Sets a custom listener position for all sounds in the scene
  104347. * By default, this is the position of the first active camera
  104348. */
  104349. audioListenerPositionProvider: Nullable<() => Vector3>;
  104350. /**
  104351. * Creates a new instance of the component for the given scene
  104352. * @param scene Defines the scene to register the component in
  104353. */
  104354. constructor(scene: Scene);
  104355. /**
  104356. * Registers the component in a given scene
  104357. */
  104358. register(): void;
  104359. /**
  104360. * Rebuilds the elements related to this component in case of
  104361. * context lost for instance.
  104362. */
  104363. rebuild(): void;
  104364. /**
  104365. * Serializes the component data to the specified json object
  104366. * @param serializationObject The object to serialize to
  104367. */
  104368. serialize(serializationObject: any): void;
  104369. /**
  104370. * Adds all the elements from the container to the scene
  104371. * @param container the container holding the elements
  104372. */
  104373. addFromContainer(container: AbstractScene): void;
  104374. /**
  104375. * Removes all the elements in the container from the scene
  104376. * @param container contains the elements to remove
  104377. * @param dispose if the removed element should be disposed (default: false)
  104378. */
  104379. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  104380. /**
  104381. * Disposes the component and the associated ressources.
  104382. */
  104383. dispose(): void;
  104384. /**
  104385. * Disables audio in the associated scene.
  104386. */
  104387. disableAudio(): void;
  104388. /**
  104389. * Enables audio in the associated scene.
  104390. */
  104391. enableAudio(): void;
  104392. /**
  104393. * Switch audio to headphone output.
  104394. */
  104395. switchAudioModeForHeadphones(): void;
  104396. /**
  104397. * Switch audio to normal speakers.
  104398. */
  104399. switchAudioModeForNormalSpeakers(): void;
  104400. private _cachedCameraDirection;
  104401. private _cachedCameraPosition;
  104402. private _lastCheck;
  104403. private _afterRender;
  104404. }
  104405. }
  104406. declare module BABYLON {
  104407. /**
  104408. * Wraps one or more Sound objects and selects one with random weight for playback.
  104409. */
  104410. export class WeightedSound {
  104411. /** When true a Sound will be selected and played when the current playing Sound completes. */
  104412. loop: boolean;
  104413. private _coneInnerAngle;
  104414. private _coneOuterAngle;
  104415. private _volume;
  104416. /** A Sound is currently playing. */
  104417. isPlaying: boolean;
  104418. /** A Sound is currently paused. */
  104419. isPaused: boolean;
  104420. private _sounds;
  104421. private _weights;
  104422. private _currentIndex?;
  104423. /**
  104424. * Creates a new WeightedSound from the list of sounds given.
  104425. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  104426. * @param sounds Array of Sounds that will be selected from.
  104427. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  104428. */
  104429. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  104430. /**
  104431. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  104432. */
  104433. /**
  104434. * The size of cone in degress for a directional sound in which there will be no attenuation.
  104435. */
  104436. directionalConeInnerAngle: number;
  104437. /**
  104438. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104439. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104440. */
  104441. /**
  104442. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104443. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104444. */
  104445. directionalConeOuterAngle: number;
  104446. /**
  104447. * Playback volume.
  104448. */
  104449. /**
  104450. * Playback volume.
  104451. */
  104452. volume: number;
  104453. private _onended;
  104454. /**
  104455. * Suspend playback
  104456. */
  104457. pause(): void;
  104458. /**
  104459. * Stop playback
  104460. */
  104461. stop(): void;
  104462. /**
  104463. * Start playback.
  104464. * @param startOffset Position the clip head at a specific time in seconds.
  104465. */
  104466. play(startOffset?: number): void;
  104467. }
  104468. }
  104469. declare module BABYLON {
  104470. /**
  104471. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  104472. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104473. */
  104474. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  104475. /**
  104476. * Gets the name of the behavior.
  104477. */
  104478. readonly name: string;
  104479. /**
  104480. * The easing function used by animations
  104481. */
  104482. static EasingFunction: BackEase;
  104483. /**
  104484. * The easing mode used by animations
  104485. */
  104486. static EasingMode: number;
  104487. /**
  104488. * The duration of the animation, in milliseconds
  104489. */
  104490. transitionDuration: number;
  104491. /**
  104492. * Length of the distance animated by the transition when lower radius is reached
  104493. */
  104494. lowerRadiusTransitionRange: number;
  104495. /**
  104496. * Length of the distance animated by the transition when upper radius is reached
  104497. */
  104498. upperRadiusTransitionRange: number;
  104499. private _autoTransitionRange;
  104500. /**
  104501. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104502. */
  104503. /**
  104504. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104505. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  104506. */
  104507. autoTransitionRange: boolean;
  104508. private _attachedCamera;
  104509. private _onAfterCheckInputsObserver;
  104510. private _onMeshTargetChangedObserver;
  104511. /**
  104512. * Initializes the behavior.
  104513. */
  104514. init(): void;
  104515. /**
  104516. * Attaches the behavior to its arc rotate camera.
  104517. * @param camera Defines the camera to attach the behavior to
  104518. */
  104519. attach(camera: ArcRotateCamera): void;
  104520. /**
  104521. * Detaches the behavior from its current arc rotate camera.
  104522. */
  104523. detach(): void;
  104524. private _radiusIsAnimating;
  104525. private _radiusBounceTransition;
  104526. private _animatables;
  104527. private _cachedWheelPrecision;
  104528. /**
  104529. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  104530. * @param radiusLimit The limit to check against.
  104531. * @return Bool to indicate if at limit.
  104532. */
  104533. private _isRadiusAtLimit;
  104534. /**
  104535. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  104536. * @param radiusDelta The delta by which to animate to. Can be negative.
  104537. */
  104538. private _applyBoundRadiusAnimation;
  104539. /**
  104540. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  104541. */
  104542. protected _clearAnimationLocks(): void;
  104543. /**
  104544. * Stops and removes all animations that have been applied to the camera
  104545. */
  104546. stopAllAnimations(): void;
  104547. }
  104548. }
  104549. declare module BABYLON {
  104550. /**
  104551. * 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.
  104552. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104553. */
  104554. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  104555. /**
  104556. * Gets the name of the behavior.
  104557. */
  104558. readonly name: string;
  104559. private _mode;
  104560. private _radiusScale;
  104561. private _positionScale;
  104562. private _defaultElevation;
  104563. private _elevationReturnTime;
  104564. private _elevationReturnWaitTime;
  104565. private _zoomStopsAnimation;
  104566. private _framingTime;
  104567. /**
  104568. * The easing function used by animations
  104569. */
  104570. static EasingFunction: ExponentialEase;
  104571. /**
  104572. * The easing mode used by animations
  104573. */
  104574. static EasingMode: number;
  104575. /**
  104576. * Sets the current mode used by the behavior
  104577. */
  104578. /**
  104579. * Gets current mode used by the behavior.
  104580. */
  104581. mode: number;
  104582. /**
  104583. * Sets the scale applied to the radius (1 by default)
  104584. */
  104585. /**
  104586. * Gets the scale applied to the radius
  104587. */
  104588. radiusScale: number;
  104589. /**
  104590. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  104591. */
  104592. /**
  104593. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  104594. */
  104595. positionScale: number;
  104596. /**
  104597. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  104598. * behaviour is triggered, in radians.
  104599. */
  104600. /**
  104601. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  104602. * behaviour is triggered, in radians.
  104603. */
  104604. defaultElevation: number;
  104605. /**
  104606. * Sets the time (in milliseconds) taken to return to the default beta position.
  104607. * Negative value indicates camera should not return to default.
  104608. */
  104609. /**
  104610. * Gets the time (in milliseconds) taken to return to the default beta position.
  104611. * Negative value indicates camera should not return to default.
  104612. */
  104613. elevationReturnTime: number;
  104614. /**
  104615. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  104616. */
  104617. /**
  104618. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  104619. */
  104620. elevationReturnWaitTime: number;
  104621. /**
  104622. * Sets the flag that indicates if user zooming should stop animation.
  104623. */
  104624. /**
  104625. * Gets the flag that indicates if user zooming should stop animation.
  104626. */
  104627. zoomStopsAnimation: boolean;
  104628. /**
  104629. * Sets the transition time when framing the mesh, in milliseconds
  104630. */
  104631. /**
  104632. * Gets the transition time when framing the mesh, in milliseconds
  104633. */
  104634. framingTime: number;
  104635. /**
  104636. * Define if the behavior should automatically change the configured
  104637. * camera limits and sensibilities.
  104638. */
  104639. autoCorrectCameraLimitsAndSensibility: boolean;
  104640. private _onPrePointerObservableObserver;
  104641. private _onAfterCheckInputsObserver;
  104642. private _onMeshTargetChangedObserver;
  104643. private _attachedCamera;
  104644. private _isPointerDown;
  104645. private _lastInteractionTime;
  104646. /**
  104647. * Initializes the behavior.
  104648. */
  104649. init(): void;
  104650. /**
  104651. * Attaches the behavior to its arc rotate camera.
  104652. * @param camera Defines the camera to attach the behavior to
  104653. */
  104654. attach(camera: ArcRotateCamera): void;
  104655. /**
  104656. * Detaches the behavior from its current arc rotate camera.
  104657. */
  104658. detach(): void;
  104659. private _animatables;
  104660. private _betaIsAnimating;
  104661. private _betaTransition;
  104662. private _radiusTransition;
  104663. private _vectorTransition;
  104664. /**
  104665. * Targets the given mesh and updates zoom level accordingly.
  104666. * @param mesh The mesh to target.
  104667. * @param radius Optional. If a cached radius position already exists, overrides default.
  104668. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104669. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104670. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104671. */
  104672. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104673. /**
  104674. * Targets the given mesh with its children and updates zoom level accordingly.
  104675. * @param mesh The mesh to target.
  104676. * @param radius Optional. If a cached radius position already exists, overrides default.
  104677. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104678. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104679. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104680. */
  104681. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104682. /**
  104683. * Targets the given meshes with their children and updates zoom level accordingly.
  104684. * @param meshes The mesh to target.
  104685. * @param radius Optional. If a cached radius position already exists, overrides default.
  104686. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104687. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104688. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104689. */
  104690. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104691. /**
  104692. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  104693. * @param minimumWorld Determines the smaller position of the bounding box extend
  104694. * @param maximumWorld Determines the bigger position of the bounding box extend
  104695. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104696. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104697. */
  104698. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104699. /**
  104700. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  104701. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  104702. * frustum width.
  104703. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  104704. * to fully enclose the mesh in the viewing frustum.
  104705. */
  104706. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  104707. /**
  104708. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  104709. * is automatically returned to its default position (expected to be above ground plane).
  104710. */
  104711. private _maintainCameraAboveGround;
  104712. /**
  104713. * Returns the frustum slope based on the canvas ratio and camera FOV
  104714. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  104715. */
  104716. private _getFrustumSlope;
  104717. /**
  104718. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  104719. */
  104720. private _clearAnimationLocks;
  104721. /**
  104722. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  104723. */
  104724. private _applyUserInteraction;
  104725. /**
  104726. * Stops and removes all animations that have been applied to the camera
  104727. */
  104728. stopAllAnimations(): void;
  104729. /**
  104730. * Gets a value indicating if the user is moving the camera
  104731. */
  104732. readonly isUserIsMoving: boolean;
  104733. /**
  104734. * The camera can move all the way towards the mesh.
  104735. */
  104736. static IgnoreBoundsSizeMode: number;
  104737. /**
  104738. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  104739. */
  104740. static FitFrustumSidesMode: number;
  104741. }
  104742. }
  104743. declare module BABYLON {
  104744. /**
  104745. * Base class for Camera Pointer Inputs.
  104746. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  104747. * for example usage.
  104748. */
  104749. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  104750. /**
  104751. * Defines the camera the input is attached to.
  104752. */
  104753. abstract camera: Camera;
  104754. /**
  104755. * Whether keyboard modifier keys are pressed at time of last mouse event.
  104756. */
  104757. protected _altKey: boolean;
  104758. protected _ctrlKey: boolean;
  104759. protected _metaKey: boolean;
  104760. protected _shiftKey: boolean;
  104761. /**
  104762. * Which mouse buttons were pressed at time of last mouse event.
  104763. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  104764. */
  104765. protected _buttonsPressed: number;
  104766. /**
  104767. * Defines the buttons associated with the input to handle camera move.
  104768. */
  104769. buttons: number[];
  104770. /**
  104771. * Attach the input controls to a specific dom element to get the input from.
  104772. * @param element Defines the element the controls should be listened from
  104773. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104774. */
  104775. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104776. /**
  104777. * Detach the current controls from the specified dom element.
  104778. * @param element Defines the element to stop listening the inputs from
  104779. */
  104780. detachControl(element: Nullable<HTMLElement>): void;
  104781. /**
  104782. * Gets the class name of the current input.
  104783. * @returns the class name
  104784. */
  104785. getClassName(): string;
  104786. /**
  104787. * Get the friendly name associated with the input class.
  104788. * @returns the input friendly name
  104789. */
  104790. getSimpleName(): string;
  104791. /**
  104792. * Called on pointer POINTERDOUBLETAP event.
  104793. * Override this method to provide functionality on POINTERDOUBLETAP event.
  104794. */
  104795. protected onDoubleTap(type: string): void;
  104796. /**
  104797. * Called on pointer POINTERMOVE event if only a single touch is active.
  104798. * Override this method to provide functionality.
  104799. */
  104800. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104801. /**
  104802. * Called on pointer POINTERMOVE event if multiple touches are active.
  104803. * Override this method to provide functionality.
  104804. */
  104805. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104806. /**
  104807. * Called on JS contextmenu event.
  104808. * Override this method to provide functionality.
  104809. */
  104810. protected onContextMenu(evt: PointerEvent): void;
  104811. /**
  104812. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  104813. * press.
  104814. * Override this method to provide functionality.
  104815. */
  104816. protected onButtonDown(evt: PointerEvent): void;
  104817. /**
  104818. * Called each time a new POINTERUP event occurs. Ie, for each button
  104819. * release.
  104820. * Override this method to provide functionality.
  104821. */
  104822. protected onButtonUp(evt: PointerEvent): void;
  104823. /**
  104824. * Called when window becomes inactive.
  104825. * Override this method to provide functionality.
  104826. */
  104827. protected onLostFocus(): void;
  104828. private _pointerInput;
  104829. private _observer;
  104830. private _onLostFocus;
  104831. private pointA;
  104832. private pointB;
  104833. }
  104834. }
  104835. declare module BABYLON {
  104836. /**
  104837. * Manage the pointers inputs to control an arc rotate camera.
  104838. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104839. */
  104840. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  104841. /**
  104842. * Defines the camera the input is attached to.
  104843. */
  104844. camera: ArcRotateCamera;
  104845. /**
  104846. * Gets the class name of the current input.
  104847. * @returns the class name
  104848. */
  104849. getClassName(): string;
  104850. /**
  104851. * Defines the buttons associated with the input to handle camera move.
  104852. */
  104853. buttons: number[];
  104854. /**
  104855. * Defines the pointer angular sensibility along the X axis or how fast is
  104856. * the camera rotating.
  104857. */
  104858. angularSensibilityX: number;
  104859. /**
  104860. * Defines the pointer angular sensibility along the Y axis or how fast is
  104861. * the camera rotating.
  104862. */
  104863. angularSensibilityY: number;
  104864. /**
  104865. * Defines the pointer pinch precision or how fast is the camera zooming.
  104866. */
  104867. pinchPrecision: number;
  104868. /**
  104869. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104870. * from 0.
  104871. * It defines the percentage of current camera.radius to use as delta when
  104872. * pinch zoom is used.
  104873. */
  104874. pinchDeltaPercentage: number;
  104875. /**
  104876. * Defines the pointer panning sensibility or how fast is the camera moving.
  104877. */
  104878. panningSensibility: number;
  104879. /**
  104880. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  104881. */
  104882. multiTouchPanning: boolean;
  104883. /**
  104884. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  104885. * zoom (pinch) through multitouch.
  104886. */
  104887. multiTouchPanAndZoom: boolean;
  104888. /**
  104889. * Revers pinch action direction.
  104890. */
  104891. pinchInwards: boolean;
  104892. private _isPanClick;
  104893. private _twoFingerActivityCount;
  104894. private _isPinching;
  104895. /**
  104896. * Called on pointer POINTERMOVE event if only a single touch is active.
  104897. */
  104898. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104899. /**
  104900. * Called on pointer POINTERDOUBLETAP event.
  104901. */
  104902. protected onDoubleTap(type: string): void;
  104903. /**
  104904. * Called on pointer POINTERMOVE event if multiple touches are active.
  104905. */
  104906. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104907. /**
  104908. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  104909. * press.
  104910. */
  104911. protected onButtonDown(evt: PointerEvent): void;
  104912. /**
  104913. * Called each time a new POINTERUP event occurs. Ie, for each button
  104914. * release.
  104915. */
  104916. protected onButtonUp(evt: PointerEvent): void;
  104917. /**
  104918. * Called when window becomes inactive.
  104919. */
  104920. protected onLostFocus(): void;
  104921. }
  104922. }
  104923. declare module BABYLON {
  104924. /**
  104925. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  104926. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104927. */
  104928. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  104929. /**
  104930. * Defines the camera the input is attached to.
  104931. */
  104932. camera: ArcRotateCamera;
  104933. /**
  104934. * Defines the list of key codes associated with the up action (increase alpha)
  104935. */
  104936. keysUp: number[];
  104937. /**
  104938. * Defines the list of key codes associated with the down action (decrease alpha)
  104939. */
  104940. keysDown: number[];
  104941. /**
  104942. * Defines the list of key codes associated with the left action (increase beta)
  104943. */
  104944. keysLeft: number[];
  104945. /**
  104946. * Defines the list of key codes associated with the right action (decrease beta)
  104947. */
  104948. keysRight: number[];
  104949. /**
  104950. * Defines the list of key codes associated with the reset action.
  104951. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  104952. */
  104953. keysReset: number[];
  104954. /**
  104955. * Defines the panning sensibility of the inputs.
  104956. * (How fast is the camera paning)
  104957. */
  104958. panningSensibility: number;
  104959. /**
  104960. * Defines the zooming sensibility of the inputs.
  104961. * (How fast is the camera zooming)
  104962. */
  104963. zoomingSensibility: number;
  104964. /**
  104965. * Defines wether maintaining the alt key down switch the movement mode from
  104966. * orientation to zoom.
  104967. */
  104968. useAltToZoom: boolean;
  104969. /**
  104970. * Rotation speed of the camera
  104971. */
  104972. angularSpeed: number;
  104973. private _keys;
  104974. private _ctrlPressed;
  104975. private _altPressed;
  104976. private _onCanvasBlurObserver;
  104977. private _onKeyboardObserver;
  104978. private _engine;
  104979. private _scene;
  104980. /**
  104981. * Attach the input controls to a specific dom element to get the input from.
  104982. * @param element Defines the element the controls should be listened from
  104983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104984. */
  104985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104986. /**
  104987. * Detach the current controls from the specified dom element.
  104988. * @param element Defines the element to stop listening the inputs from
  104989. */
  104990. detachControl(element: Nullable<HTMLElement>): void;
  104991. /**
  104992. * Update the current camera state depending on the inputs that have been used this frame.
  104993. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104994. */
  104995. checkInputs(): void;
  104996. /**
  104997. * Gets the class name of the current intput.
  104998. * @returns the class name
  104999. */
  105000. getClassName(): string;
  105001. /**
  105002. * Get the friendly name associated with the input class.
  105003. * @returns the input friendly name
  105004. */
  105005. getSimpleName(): string;
  105006. }
  105007. }
  105008. declare module BABYLON {
  105009. /**
  105010. * Manage the mouse wheel inputs to control an arc rotate camera.
  105011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105012. */
  105013. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  105014. /**
  105015. * Defines the camera the input is attached to.
  105016. */
  105017. camera: ArcRotateCamera;
  105018. /**
  105019. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  105020. */
  105021. wheelPrecision: number;
  105022. /**
  105023. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  105024. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  105025. */
  105026. wheelDeltaPercentage: number;
  105027. private _wheel;
  105028. private _observer;
  105029. private computeDeltaFromMouseWheelLegacyEvent;
  105030. /**
  105031. * Attach the input controls to a specific dom element to get the input from.
  105032. * @param element Defines the element the controls should be listened from
  105033. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105034. */
  105035. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105036. /**
  105037. * Detach the current controls from the specified dom element.
  105038. * @param element Defines the element to stop listening the inputs from
  105039. */
  105040. detachControl(element: Nullable<HTMLElement>): void;
  105041. /**
  105042. * Gets the class name of the current intput.
  105043. * @returns the class name
  105044. */
  105045. getClassName(): string;
  105046. /**
  105047. * Get the friendly name associated with the input class.
  105048. * @returns the input friendly name
  105049. */
  105050. getSimpleName(): string;
  105051. }
  105052. }
  105053. declare module BABYLON {
  105054. /**
  105055. * Default Inputs manager for the ArcRotateCamera.
  105056. * It groups all the default supported inputs for ease of use.
  105057. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105058. */
  105059. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  105060. /**
  105061. * Instantiates a new ArcRotateCameraInputsManager.
  105062. * @param camera Defines the camera the inputs belong to
  105063. */
  105064. constructor(camera: ArcRotateCamera);
  105065. /**
  105066. * Add mouse wheel input support to the input manager.
  105067. * @returns the current input manager
  105068. */
  105069. addMouseWheel(): ArcRotateCameraInputsManager;
  105070. /**
  105071. * Add pointers input support to the input manager.
  105072. * @returns the current input manager
  105073. */
  105074. addPointers(): ArcRotateCameraInputsManager;
  105075. /**
  105076. * Add keyboard input support to the input manager.
  105077. * @returns the current input manager
  105078. */
  105079. addKeyboard(): ArcRotateCameraInputsManager;
  105080. }
  105081. }
  105082. declare module BABYLON {
  105083. /**
  105084. * This represents an orbital type of camera.
  105085. *
  105086. * 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.
  105087. * 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.
  105088. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  105089. */
  105090. export class ArcRotateCamera extends TargetCamera {
  105091. /**
  105092. * Defines the rotation angle of the camera along the longitudinal axis.
  105093. */
  105094. alpha: number;
  105095. /**
  105096. * Defines the rotation angle of the camera along the latitudinal axis.
  105097. */
  105098. beta: number;
  105099. /**
  105100. * Defines the radius of the camera from it s target point.
  105101. */
  105102. radius: number;
  105103. protected _target: Vector3;
  105104. protected _targetHost: Nullable<AbstractMesh>;
  105105. /**
  105106. * Defines the target point of the camera.
  105107. * The camera looks towards it form the radius distance.
  105108. */
  105109. target: Vector3;
  105110. /**
  105111. * Define the current local position of the camera in the scene
  105112. */
  105113. position: Vector3;
  105114. protected _upVector: Vector3;
  105115. protected _upToYMatrix: Matrix;
  105116. protected _YToUpMatrix: Matrix;
  105117. /**
  105118. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  105119. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  105120. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  105121. */
  105122. upVector: Vector3;
  105123. /**
  105124. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  105125. */
  105126. setMatUp(): void;
  105127. /**
  105128. * Current inertia value on the longitudinal axis.
  105129. * The bigger this number the longer it will take for the camera to stop.
  105130. */
  105131. inertialAlphaOffset: number;
  105132. /**
  105133. * Current inertia value on the latitudinal axis.
  105134. * The bigger this number the longer it will take for the camera to stop.
  105135. */
  105136. inertialBetaOffset: number;
  105137. /**
  105138. * Current inertia value on the radius axis.
  105139. * The bigger this number the longer it will take for the camera to stop.
  105140. */
  105141. inertialRadiusOffset: number;
  105142. /**
  105143. * Minimum allowed angle on the longitudinal axis.
  105144. * This can help limiting how the Camera is able to move in the scene.
  105145. */
  105146. lowerAlphaLimit: Nullable<number>;
  105147. /**
  105148. * Maximum allowed angle on the longitudinal axis.
  105149. * This can help limiting how the Camera is able to move in the scene.
  105150. */
  105151. upperAlphaLimit: Nullable<number>;
  105152. /**
  105153. * Minimum allowed angle on the latitudinal axis.
  105154. * This can help limiting how the Camera is able to move in the scene.
  105155. */
  105156. lowerBetaLimit: number;
  105157. /**
  105158. * Maximum allowed angle on the latitudinal axis.
  105159. * This can help limiting how the Camera is able to move in the scene.
  105160. */
  105161. upperBetaLimit: number;
  105162. /**
  105163. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  105164. * This can help limiting how the Camera is able to move in the scene.
  105165. */
  105166. lowerRadiusLimit: Nullable<number>;
  105167. /**
  105168. * Maximum allowed distance of the camera to the target (The camera can not get further).
  105169. * This can help limiting how the Camera is able to move in the scene.
  105170. */
  105171. upperRadiusLimit: Nullable<number>;
  105172. /**
  105173. * Defines the current inertia value used during panning of the camera along the X axis.
  105174. */
  105175. inertialPanningX: number;
  105176. /**
  105177. * Defines the current inertia value used during panning of the camera along the Y axis.
  105178. */
  105179. inertialPanningY: number;
  105180. /**
  105181. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  105182. * Basically if your fingers moves away from more than this distance you will be considered
  105183. * in pinch mode.
  105184. */
  105185. pinchToPanMaxDistance: number;
  105186. /**
  105187. * Defines the maximum distance the camera can pan.
  105188. * This could help keeping the cammera always in your scene.
  105189. */
  105190. panningDistanceLimit: Nullable<number>;
  105191. /**
  105192. * Defines the target of the camera before paning.
  105193. */
  105194. panningOriginTarget: Vector3;
  105195. /**
  105196. * Defines the value of the inertia used during panning.
  105197. * 0 would mean stop inertia and one would mean no decelleration at all.
  105198. */
  105199. panningInertia: number;
  105200. /**
  105201. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  105202. */
  105203. angularSensibilityX: number;
  105204. /**
  105205. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  105206. */
  105207. angularSensibilityY: number;
  105208. /**
  105209. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  105210. */
  105211. pinchPrecision: number;
  105212. /**
  105213. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  105214. * It will be used instead of pinchDeltaPrecision if different from 0.
  105215. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  105216. */
  105217. pinchDeltaPercentage: number;
  105218. /**
  105219. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  105220. */
  105221. panningSensibility: number;
  105222. /**
  105223. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  105224. */
  105225. keysUp: number[];
  105226. /**
  105227. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  105228. */
  105229. keysDown: number[];
  105230. /**
  105231. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  105232. */
  105233. keysLeft: number[];
  105234. /**
  105235. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  105236. */
  105237. keysRight: number[];
  105238. /**
  105239. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  105240. */
  105241. wheelPrecision: number;
  105242. /**
  105243. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  105244. * It will be used instead of pinchDeltaPrecision if different from 0.
  105245. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  105246. */
  105247. wheelDeltaPercentage: number;
  105248. /**
  105249. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  105250. */
  105251. zoomOnFactor: number;
  105252. /**
  105253. * Defines a screen offset for the camera position.
  105254. */
  105255. targetScreenOffset: Vector2;
  105256. /**
  105257. * Allows the camera to be completely reversed.
  105258. * If false the camera can not arrive upside down.
  105259. */
  105260. allowUpsideDown: boolean;
  105261. /**
  105262. * Define if double tap/click is used to restore the previously saved state of the camera.
  105263. */
  105264. useInputToRestoreState: boolean;
  105265. /** @hidden */
  105266. _viewMatrix: Matrix;
  105267. /** @hidden */
  105268. _useCtrlForPanning: boolean;
  105269. /** @hidden */
  105270. _panningMouseButton: number;
  105271. /**
  105272. * Defines the input associated to the camera.
  105273. */
  105274. inputs: ArcRotateCameraInputsManager;
  105275. /** @hidden */
  105276. _reset: () => void;
  105277. /**
  105278. * Defines the allowed panning axis.
  105279. */
  105280. panningAxis: Vector3;
  105281. protected _localDirection: Vector3;
  105282. protected _transformedDirection: Vector3;
  105283. private _bouncingBehavior;
  105284. /**
  105285. * Gets the bouncing behavior of the camera if it has been enabled.
  105286. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  105287. */
  105288. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  105289. /**
  105290. * Defines if the bouncing behavior of the camera is enabled on the camera.
  105291. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  105292. */
  105293. useBouncingBehavior: boolean;
  105294. private _framingBehavior;
  105295. /**
  105296. * Gets the framing behavior of the camera if it has been enabled.
  105297. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  105298. */
  105299. readonly framingBehavior: Nullable<FramingBehavior>;
  105300. /**
  105301. * Defines if the framing behavior of the camera is enabled on the camera.
  105302. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  105303. */
  105304. useFramingBehavior: boolean;
  105305. private _autoRotationBehavior;
  105306. /**
  105307. * Gets the auto rotation behavior of the camera if it has been enabled.
  105308. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105309. */
  105310. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  105311. /**
  105312. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  105313. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105314. */
  105315. useAutoRotationBehavior: boolean;
  105316. /**
  105317. * Observable triggered when the mesh target has been changed on the camera.
  105318. */
  105319. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  105320. /**
  105321. * Event raised when the camera is colliding with a mesh.
  105322. */
  105323. onCollide: (collidedMesh: AbstractMesh) => void;
  105324. /**
  105325. * Defines whether the camera should check collision with the objects oh the scene.
  105326. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  105327. */
  105328. checkCollisions: boolean;
  105329. /**
  105330. * Defines the collision radius of the camera.
  105331. * This simulates a sphere around the camera.
  105332. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105333. */
  105334. collisionRadius: Vector3;
  105335. protected _collider: Collider;
  105336. protected _previousPosition: Vector3;
  105337. protected _collisionVelocity: Vector3;
  105338. protected _newPosition: Vector3;
  105339. protected _previousAlpha: number;
  105340. protected _previousBeta: number;
  105341. protected _previousRadius: number;
  105342. protected _collisionTriggered: boolean;
  105343. protected _targetBoundingCenter: Nullable<Vector3>;
  105344. private _computationVector;
  105345. /**
  105346. * Instantiates a new ArcRotateCamera in a given scene
  105347. * @param name Defines the name of the camera
  105348. * @param alpha Defines the camera rotation along the logitudinal axis
  105349. * @param beta Defines the camera rotation along the latitudinal axis
  105350. * @param radius Defines the camera distance from its target
  105351. * @param target Defines the camera target
  105352. * @param scene Defines the scene the camera belongs to
  105353. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  105354. */
  105355. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105356. /** @hidden */
  105357. _initCache(): void;
  105358. /** @hidden */
  105359. _updateCache(ignoreParentClass?: boolean): void;
  105360. protected _getTargetPosition(): Vector3;
  105361. private _storedAlpha;
  105362. private _storedBeta;
  105363. private _storedRadius;
  105364. private _storedTarget;
  105365. private _storedTargetScreenOffset;
  105366. /**
  105367. * Stores the current state of the camera (alpha, beta, radius and target)
  105368. * @returns the camera itself
  105369. */
  105370. storeState(): Camera;
  105371. /**
  105372. * @hidden
  105373. * Restored camera state. You must call storeState() first
  105374. */
  105375. _restoreStateValues(): boolean;
  105376. /** @hidden */
  105377. _isSynchronizedViewMatrix(): boolean;
  105378. /**
  105379. * Attached controls to the current camera.
  105380. * @param element Defines the element the controls should be listened from
  105381. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105382. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  105383. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  105384. */
  105385. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  105386. /**
  105387. * Detach the current controls from the camera.
  105388. * The camera will stop reacting to inputs.
  105389. * @param element Defines the element to stop listening the inputs from
  105390. */
  105391. detachControl(element: HTMLElement): void;
  105392. /** @hidden */
  105393. _checkInputs(): void;
  105394. protected _checkLimits(): void;
  105395. /**
  105396. * Rebuilds angles (alpha, beta) and radius from the give position and target
  105397. */
  105398. rebuildAnglesAndRadius(): void;
  105399. /**
  105400. * Use a position to define the current camera related information like alpha, beta and radius
  105401. * @param position Defines the position to set the camera at
  105402. */
  105403. setPosition(position: Vector3): void;
  105404. /**
  105405. * Defines the target the camera should look at.
  105406. * This will automatically adapt alpha beta and radius to fit within the new target.
  105407. * @param target Defines the new target as a Vector or a mesh
  105408. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  105409. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  105410. */
  105411. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  105412. /** @hidden */
  105413. _getViewMatrix(): Matrix;
  105414. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  105415. /**
  105416. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  105417. * @param meshes Defines the mesh to zoom on
  105418. * @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)
  105419. */
  105420. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  105421. /**
  105422. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  105423. * The target will be changed but the radius
  105424. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  105425. * @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)
  105426. */
  105427. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  105428. min: Vector3;
  105429. max: Vector3;
  105430. distance: number;
  105431. }, doNotUpdateMaxZ?: boolean): void;
  105432. /**
  105433. * @override
  105434. * Override Camera.createRigCamera
  105435. */
  105436. createRigCamera(name: string, cameraIndex: number): Camera;
  105437. /**
  105438. * @hidden
  105439. * @override
  105440. * Override Camera._updateRigCameras
  105441. */
  105442. _updateRigCameras(): void;
  105443. /**
  105444. * Destroy the camera and release the current resources hold by it.
  105445. */
  105446. dispose(): void;
  105447. /**
  105448. * Gets the current object class name.
  105449. * @return the class name
  105450. */
  105451. getClassName(): string;
  105452. }
  105453. }
  105454. declare module BABYLON {
  105455. /**
  105456. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  105457. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105458. */
  105459. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  105460. /**
  105461. * Gets the name of the behavior.
  105462. */
  105463. readonly name: string;
  105464. private _zoomStopsAnimation;
  105465. private _idleRotationSpeed;
  105466. private _idleRotationWaitTime;
  105467. private _idleRotationSpinupTime;
  105468. /**
  105469. * Sets the flag that indicates if user zooming should stop animation.
  105470. */
  105471. /**
  105472. * Gets the flag that indicates if user zooming should stop animation.
  105473. */
  105474. zoomStopsAnimation: boolean;
  105475. /**
  105476. * Sets the default speed at which the camera rotates around the model.
  105477. */
  105478. /**
  105479. * Gets the default speed at which the camera rotates around the model.
  105480. */
  105481. idleRotationSpeed: number;
  105482. /**
  105483. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  105484. */
  105485. /**
  105486. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  105487. */
  105488. idleRotationWaitTime: number;
  105489. /**
  105490. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105491. */
  105492. /**
  105493. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105494. */
  105495. idleRotationSpinupTime: number;
  105496. /**
  105497. * Gets a value indicating if the camera is currently rotating because of this behavior
  105498. */
  105499. readonly rotationInProgress: boolean;
  105500. private _onPrePointerObservableObserver;
  105501. private _onAfterCheckInputsObserver;
  105502. private _attachedCamera;
  105503. private _isPointerDown;
  105504. private _lastFrameTime;
  105505. private _lastInteractionTime;
  105506. private _cameraRotationSpeed;
  105507. /**
  105508. * Initializes the behavior.
  105509. */
  105510. init(): void;
  105511. /**
  105512. * Attaches the behavior to its arc rotate camera.
  105513. * @param camera Defines the camera to attach the behavior to
  105514. */
  105515. attach(camera: ArcRotateCamera): void;
  105516. /**
  105517. * Detaches the behavior from its current arc rotate camera.
  105518. */
  105519. detach(): void;
  105520. /**
  105521. * Returns true if user is scrolling.
  105522. * @return true if user is scrolling.
  105523. */
  105524. private _userIsZooming;
  105525. private _lastFrameRadius;
  105526. private _shouldAnimationStopForInteraction;
  105527. /**
  105528. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  105529. */
  105530. private _applyUserInteraction;
  105531. private _userIsMoving;
  105532. }
  105533. }
  105534. declare module BABYLON {
  105535. /**
  105536. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  105537. */
  105538. export class AttachToBoxBehavior implements Behavior<Mesh> {
  105539. private ui;
  105540. /**
  105541. * The name of the behavior
  105542. */
  105543. name: string;
  105544. /**
  105545. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  105546. */
  105547. distanceAwayFromFace: number;
  105548. /**
  105549. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  105550. */
  105551. distanceAwayFromBottomOfFace: number;
  105552. private _faceVectors;
  105553. private _target;
  105554. private _scene;
  105555. private _onRenderObserver;
  105556. private _tmpMatrix;
  105557. private _tmpVector;
  105558. /**
  105559. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  105560. * @param ui The transform node that should be attched to the mesh
  105561. */
  105562. constructor(ui: TransformNode);
  105563. /**
  105564. * Initializes the behavior
  105565. */
  105566. init(): void;
  105567. private _closestFace;
  105568. private _zeroVector;
  105569. private _lookAtTmpMatrix;
  105570. private _lookAtToRef;
  105571. /**
  105572. * Attaches the AttachToBoxBehavior to the passed in mesh
  105573. * @param target The mesh that the specified node will be attached to
  105574. */
  105575. attach(target: Mesh): void;
  105576. /**
  105577. * Detaches the behavior from the mesh
  105578. */
  105579. detach(): void;
  105580. }
  105581. }
  105582. declare module BABYLON {
  105583. /**
  105584. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  105585. */
  105586. export class FadeInOutBehavior implements Behavior<Mesh> {
  105587. /**
  105588. * Time in milliseconds to delay before fading in (Default: 0)
  105589. */
  105590. delay: number;
  105591. /**
  105592. * Time in milliseconds for the mesh to fade in (Default: 300)
  105593. */
  105594. fadeInTime: number;
  105595. private _millisecondsPerFrame;
  105596. private _hovered;
  105597. private _hoverValue;
  105598. private _ownerNode;
  105599. /**
  105600. * Instatiates the FadeInOutBehavior
  105601. */
  105602. constructor();
  105603. /**
  105604. * The name of the behavior
  105605. */
  105606. readonly name: string;
  105607. /**
  105608. * Initializes the behavior
  105609. */
  105610. init(): void;
  105611. /**
  105612. * Attaches the fade behavior on the passed in mesh
  105613. * @param ownerNode The mesh that will be faded in/out once attached
  105614. */
  105615. attach(ownerNode: Mesh): void;
  105616. /**
  105617. * Detaches the behavior from the mesh
  105618. */
  105619. detach(): void;
  105620. /**
  105621. * Triggers the mesh to begin fading in or out
  105622. * @param value if the object should fade in or out (true to fade in)
  105623. */
  105624. fadeIn(value: boolean): void;
  105625. private _update;
  105626. private _setAllVisibility;
  105627. }
  105628. }
  105629. declare module BABYLON {
  105630. /**
  105631. * Class containing a set of static utilities functions for managing Pivots
  105632. * @hidden
  105633. */
  105634. export class PivotTools {
  105635. private static _PivotCached;
  105636. private static _OldPivotPoint;
  105637. private static _PivotTranslation;
  105638. private static _PivotTmpVector;
  105639. /** @hidden */
  105640. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  105641. /** @hidden */
  105642. static _RestorePivotPoint(mesh: AbstractMesh): void;
  105643. }
  105644. }
  105645. declare module BABYLON {
  105646. /**
  105647. * Class containing static functions to help procedurally build meshes
  105648. */
  105649. export class PlaneBuilder {
  105650. /**
  105651. * Creates a plane mesh
  105652. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  105653. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  105654. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  105655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105656. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105658. * @param name defines the name of the mesh
  105659. * @param options defines the options used to create the mesh
  105660. * @param scene defines the hosting scene
  105661. * @returns the plane mesh
  105662. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  105663. */
  105664. static CreatePlane(name: string, options: {
  105665. size?: number;
  105666. width?: number;
  105667. height?: number;
  105668. sideOrientation?: number;
  105669. frontUVs?: Vector4;
  105670. backUVs?: Vector4;
  105671. updatable?: boolean;
  105672. sourcePlane?: Plane;
  105673. }, scene?: Nullable<Scene>): Mesh;
  105674. }
  105675. }
  105676. declare module BABYLON {
  105677. /**
  105678. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  105679. */
  105680. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  105681. private static _AnyMouseID;
  105682. /**
  105683. * Abstract mesh the behavior is set on
  105684. */
  105685. attachedNode: AbstractMesh;
  105686. private _dragPlane;
  105687. private _scene;
  105688. private _pointerObserver;
  105689. private _beforeRenderObserver;
  105690. private static _planeScene;
  105691. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  105692. /**
  105693. * 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)
  105694. */
  105695. maxDragAngle: number;
  105696. /**
  105697. * @hidden
  105698. */
  105699. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  105700. /**
  105701. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105702. */
  105703. currentDraggingPointerID: number;
  105704. /**
  105705. * The last position where the pointer hit the drag plane in world space
  105706. */
  105707. lastDragPosition: Vector3;
  105708. /**
  105709. * If the behavior is currently in a dragging state
  105710. */
  105711. dragging: boolean;
  105712. /**
  105713. * 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)
  105714. */
  105715. dragDeltaRatio: number;
  105716. /**
  105717. * If the drag plane orientation should be updated during the dragging (Default: true)
  105718. */
  105719. updateDragPlane: boolean;
  105720. private _debugMode;
  105721. private _moving;
  105722. /**
  105723. * Fires each time the attached mesh is dragged with the pointer
  105724. * * delta between last drag position and current drag position in world space
  105725. * * dragDistance along the drag axis
  105726. * * dragPlaneNormal normal of the current drag plane used during the drag
  105727. * * dragPlanePoint in world space where the drag intersects the drag plane
  105728. */
  105729. onDragObservable: Observable<{
  105730. delta: Vector3;
  105731. dragPlanePoint: Vector3;
  105732. dragPlaneNormal: Vector3;
  105733. dragDistance: number;
  105734. pointerId: number;
  105735. }>;
  105736. /**
  105737. * Fires each time a drag begins (eg. mouse down on mesh)
  105738. */
  105739. onDragStartObservable: Observable<{
  105740. dragPlanePoint: Vector3;
  105741. pointerId: number;
  105742. }>;
  105743. /**
  105744. * Fires each time a drag ends (eg. mouse release after drag)
  105745. */
  105746. onDragEndObservable: Observable<{
  105747. dragPlanePoint: Vector3;
  105748. pointerId: number;
  105749. }>;
  105750. /**
  105751. * If the attached mesh should be moved when dragged
  105752. */
  105753. moveAttached: boolean;
  105754. /**
  105755. * If the drag behavior will react to drag events (Default: true)
  105756. */
  105757. enabled: boolean;
  105758. /**
  105759. * If pointer events should start and release the drag (Default: true)
  105760. */
  105761. startAndReleaseDragOnPointerEvents: boolean;
  105762. /**
  105763. * If camera controls should be detached during the drag
  105764. */
  105765. detachCameraControls: boolean;
  105766. /**
  105767. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  105768. */
  105769. useObjectOrienationForDragging: boolean;
  105770. private _options;
  105771. /**
  105772. * Creates a pointer drag behavior that can be attached to a mesh
  105773. * @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)
  105774. */
  105775. constructor(options?: {
  105776. dragAxis?: Vector3;
  105777. dragPlaneNormal?: Vector3;
  105778. });
  105779. /**
  105780. * Predicate to determine if it is valid to move the object to a new position when it is moved
  105781. */
  105782. validateDrag: (targetPosition: Vector3) => boolean;
  105783. /**
  105784. * The name of the behavior
  105785. */
  105786. readonly name: string;
  105787. /**
  105788. * Initializes the behavior
  105789. */
  105790. init(): void;
  105791. private _tmpVector;
  105792. private _alternatePickedPoint;
  105793. private _worldDragAxis;
  105794. private _targetPosition;
  105795. private _attachedElement;
  105796. /**
  105797. * Attaches the drag behavior the passed in mesh
  105798. * @param ownerNode The mesh that will be dragged around once attached
  105799. * @param predicate Predicate to use for pick filtering
  105800. */
  105801. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  105802. /**
  105803. * Force relase the drag action by code.
  105804. */
  105805. releaseDrag(): void;
  105806. private _startDragRay;
  105807. private _lastPointerRay;
  105808. /**
  105809. * Simulates the start of a pointer drag event on the behavior
  105810. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  105811. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  105812. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  105813. */
  105814. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  105815. private _startDrag;
  105816. private _dragDelta;
  105817. private _moveDrag;
  105818. private _pickWithRayOnDragPlane;
  105819. private _pointA;
  105820. private _pointB;
  105821. private _pointC;
  105822. private _lineA;
  105823. private _lineB;
  105824. private _localAxis;
  105825. private _lookAt;
  105826. private _updateDragPlanePosition;
  105827. /**
  105828. * Detaches the behavior from the mesh
  105829. */
  105830. detach(): void;
  105831. }
  105832. }
  105833. declare module BABYLON {
  105834. /**
  105835. * A behavior that when attached to a mesh will allow the mesh to be scaled
  105836. */
  105837. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  105838. private _dragBehaviorA;
  105839. private _dragBehaviorB;
  105840. private _startDistance;
  105841. private _initialScale;
  105842. private _targetScale;
  105843. private _ownerNode;
  105844. private _sceneRenderObserver;
  105845. /**
  105846. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  105847. */
  105848. constructor();
  105849. /**
  105850. * The name of the behavior
  105851. */
  105852. readonly name: string;
  105853. /**
  105854. * Initializes the behavior
  105855. */
  105856. init(): void;
  105857. private _getCurrentDistance;
  105858. /**
  105859. * Attaches the scale behavior the passed in mesh
  105860. * @param ownerNode The mesh that will be scaled around once attached
  105861. */
  105862. attach(ownerNode: Mesh): void;
  105863. /**
  105864. * Detaches the behavior from the mesh
  105865. */
  105866. detach(): void;
  105867. }
  105868. }
  105869. declare module BABYLON {
  105870. /**
  105871. * 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
  105872. */
  105873. export class SixDofDragBehavior implements Behavior<Mesh> {
  105874. private static _virtualScene;
  105875. private _ownerNode;
  105876. private _sceneRenderObserver;
  105877. private _scene;
  105878. private _targetPosition;
  105879. private _virtualOriginMesh;
  105880. private _virtualDragMesh;
  105881. private _pointerObserver;
  105882. private _moving;
  105883. private _startingOrientation;
  105884. /**
  105885. * 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)
  105886. */
  105887. private zDragFactor;
  105888. /**
  105889. * If the object should rotate to face the drag origin
  105890. */
  105891. rotateDraggedObject: boolean;
  105892. /**
  105893. * If the behavior is currently in a dragging state
  105894. */
  105895. dragging: boolean;
  105896. /**
  105897. * 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)
  105898. */
  105899. dragDeltaRatio: number;
  105900. /**
  105901. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105902. */
  105903. currentDraggingPointerID: number;
  105904. /**
  105905. * If camera controls should be detached during the drag
  105906. */
  105907. detachCameraControls: boolean;
  105908. /**
  105909. * Fires each time a drag starts
  105910. */
  105911. onDragStartObservable: Observable<{}>;
  105912. /**
  105913. * Fires each time a drag ends (eg. mouse release after drag)
  105914. */
  105915. onDragEndObservable: Observable<{}>;
  105916. /**
  105917. * 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
  105918. */
  105919. constructor();
  105920. /**
  105921. * The name of the behavior
  105922. */
  105923. readonly name: string;
  105924. /**
  105925. * Initializes the behavior
  105926. */
  105927. init(): void;
  105928. /**
  105929. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  105930. */
  105931. private readonly _pointerCamera;
  105932. /**
  105933. * Attaches the scale behavior the passed in mesh
  105934. * @param ownerNode The mesh that will be scaled around once attached
  105935. */
  105936. attach(ownerNode: Mesh): void;
  105937. /**
  105938. * Detaches the behavior from the mesh
  105939. */
  105940. detach(): void;
  105941. }
  105942. }
  105943. declare module BABYLON {
  105944. /**
  105945. * Class used to apply inverse kinematics to bones
  105946. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  105947. */
  105948. export class BoneIKController {
  105949. private static _tmpVecs;
  105950. private static _tmpQuat;
  105951. private static _tmpMats;
  105952. /**
  105953. * Gets or sets the target mesh
  105954. */
  105955. targetMesh: AbstractMesh;
  105956. /** Gets or sets the mesh used as pole */
  105957. poleTargetMesh: AbstractMesh;
  105958. /**
  105959. * Gets or sets the bone used as pole
  105960. */
  105961. poleTargetBone: Nullable<Bone>;
  105962. /**
  105963. * Gets or sets the target position
  105964. */
  105965. targetPosition: Vector3;
  105966. /**
  105967. * Gets or sets the pole target position
  105968. */
  105969. poleTargetPosition: Vector3;
  105970. /**
  105971. * Gets or sets the pole target local offset
  105972. */
  105973. poleTargetLocalOffset: Vector3;
  105974. /**
  105975. * Gets or sets the pole angle
  105976. */
  105977. poleAngle: number;
  105978. /**
  105979. * Gets or sets the mesh associated with the controller
  105980. */
  105981. mesh: AbstractMesh;
  105982. /**
  105983. * 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)
  105984. */
  105985. slerpAmount: number;
  105986. private _bone1Quat;
  105987. private _bone1Mat;
  105988. private _bone2Ang;
  105989. private _bone1;
  105990. private _bone2;
  105991. private _bone1Length;
  105992. private _bone2Length;
  105993. private _maxAngle;
  105994. private _maxReach;
  105995. private _rightHandedSystem;
  105996. private _bendAxis;
  105997. private _slerping;
  105998. private _adjustRoll;
  105999. /**
  106000. * Gets or sets maximum allowed angle
  106001. */
  106002. maxAngle: number;
  106003. /**
  106004. * Creates a new BoneIKController
  106005. * @param mesh defines the mesh to control
  106006. * @param bone defines the bone to control
  106007. * @param options defines options to set up the controller
  106008. */
  106009. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  106010. targetMesh?: AbstractMesh;
  106011. poleTargetMesh?: AbstractMesh;
  106012. poleTargetBone?: Bone;
  106013. poleTargetLocalOffset?: Vector3;
  106014. poleAngle?: number;
  106015. bendAxis?: Vector3;
  106016. maxAngle?: number;
  106017. slerpAmount?: number;
  106018. });
  106019. private _setMaxAngle;
  106020. /**
  106021. * Force the controller to update the bones
  106022. */
  106023. update(): void;
  106024. }
  106025. }
  106026. declare module BABYLON {
  106027. /**
  106028. * Class used to make a bone look toward a point in space
  106029. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  106030. */
  106031. export class BoneLookController {
  106032. private static _tmpVecs;
  106033. private static _tmpQuat;
  106034. private static _tmpMats;
  106035. /**
  106036. * The target Vector3 that the bone will look at
  106037. */
  106038. target: Vector3;
  106039. /**
  106040. * The mesh that the bone is attached to
  106041. */
  106042. mesh: AbstractMesh;
  106043. /**
  106044. * The bone that will be looking to the target
  106045. */
  106046. bone: Bone;
  106047. /**
  106048. * The up axis of the coordinate system that is used when the bone is rotated
  106049. */
  106050. upAxis: Vector3;
  106051. /**
  106052. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  106053. */
  106054. upAxisSpace: Space;
  106055. /**
  106056. * Used to make an adjustment to the yaw of the bone
  106057. */
  106058. adjustYaw: number;
  106059. /**
  106060. * Used to make an adjustment to the pitch of the bone
  106061. */
  106062. adjustPitch: number;
  106063. /**
  106064. * Used to make an adjustment to the roll of the bone
  106065. */
  106066. adjustRoll: number;
  106067. /**
  106068. * 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)
  106069. */
  106070. slerpAmount: number;
  106071. private _minYaw;
  106072. private _maxYaw;
  106073. private _minPitch;
  106074. private _maxPitch;
  106075. private _minYawSin;
  106076. private _minYawCos;
  106077. private _maxYawSin;
  106078. private _maxYawCos;
  106079. private _midYawConstraint;
  106080. private _minPitchTan;
  106081. private _maxPitchTan;
  106082. private _boneQuat;
  106083. private _slerping;
  106084. private _transformYawPitch;
  106085. private _transformYawPitchInv;
  106086. private _firstFrameSkipped;
  106087. private _yawRange;
  106088. private _fowardAxis;
  106089. /**
  106090. * Gets or sets the minimum yaw angle that the bone can look to
  106091. */
  106092. minYaw: number;
  106093. /**
  106094. * Gets or sets the maximum yaw angle that the bone can look to
  106095. */
  106096. maxYaw: number;
  106097. /**
  106098. * Gets or sets the minimum pitch angle that the bone can look to
  106099. */
  106100. minPitch: number;
  106101. /**
  106102. * Gets or sets the maximum pitch angle that the bone can look to
  106103. */
  106104. maxPitch: number;
  106105. /**
  106106. * Create a BoneLookController
  106107. * @param mesh the mesh that the bone belongs to
  106108. * @param bone the bone that will be looking to the target
  106109. * @param target the target Vector3 to look at
  106110. * @param options optional settings:
  106111. * * maxYaw: the maximum angle the bone will yaw to
  106112. * * minYaw: the minimum angle the bone will yaw to
  106113. * * maxPitch: the maximum angle the bone will pitch to
  106114. * * minPitch: the minimum angle the bone will yaw to
  106115. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  106116. * * upAxis: the up axis of the coordinate system
  106117. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  106118. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  106119. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  106120. * * adjustYaw: used to make an adjustment to the yaw of the bone
  106121. * * adjustPitch: used to make an adjustment to the pitch of the bone
  106122. * * adjustRoll: used to make an adjustment to the roll of the bone
  106123. **/
  106124. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  106125. maxYaw?: number;
  106126. minYaw?: number;
  106127. maxPitch?: number;
  106128. minPitch?: number;
  106129. slerpAmount?: number;
  106130. upAxis?: Vector3;
  106131. upAxisSpace?: Space;
  106132. yawAxis?: Vector3;
  106133. pitchAxis?: Vector3;
  106134. adjustYaw?: number;
  106135. adjustPitch?: number;
  106136. adjustRoll?: number;
  106137. });
  106138. /**
  106139. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  106140. */
  106141. update(): void;
  106142. private _getAngleDiff;
  106143. private _getAngleBetween;
  106144. private _isAngleBetween;
  106145. }
  106146. }
  106147. declare module BABYLON {
  106148. /**
  106149. * Manage the gamepad inputs to control an arc rotate camera.
  106150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106151. */
  106152. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  106153. /**
  106154. * Defines the camera the input is attached to.
  106155. */
  106156. camera: ArcRotateCamera;
  106157. /**
  106158. * Defines the gamepad the input is gathering event from.
  106159. */
  106160. gamepad: Nullable<Gamepad>;
  106161. /**
  106162. * Defines the gamepad rotation sensiblity.
  106163. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106164. */
  106165. gamepadRotationSensibility: number;
  106166. /**
  106167. * Defines the gamepad move sensiblity.
  106168. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106169. */
  106170. gamepadMoveSensibility: number;
  106171. private _yAxisScale;
  106172. /**
  106173. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  106174. */
  106175. invertYAxis: boolean;
  106176. private _onGamepadConnectedObserver;
  106177. private _onGamepadDisconnectedObserver;
  106178. /**
  106179. * Attach the input controls to a specific dom element to get the input from.
  106180. * @param element Defines the element the controls should be listened from
  106181. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106182. */
  106183. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106184. /**
  106185. * Detach the current controls from the specified dom element.
  106186. * @param element Defines the element to stop listening the inputs from
  106187. */
  106188. detachControl(element: Nullable<HTMLElement>): void;
  106189. /**
  106190. * Update the current camera state depending on the inputs that have been used this frame.
  106191. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106192. */
  106193. checkInputs(): void;
  106194. /**
  106195. * Gets the class name of the current intput.
  106196. * @returns the class name
  106197. */
  106198. getClassName(): string;
  106199. /**
  106200. * Get the friendly name associated with the input class.
  106201. * @returns the input friendly name
  106202. */
  106203. getSimpleName(): string;
  106204. }
  106205. }
  106206. declare module BABYLON {
  106207. interface ArcRotateCameraInputsManager {
  106208. /**
  106209. * Add orientation input support to the input manager.
  106210. * @returns the current input manager
  106211. */
  106212. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  106213. }
  106214. /**
  106215. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  106216. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106217. */
  106218. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  106219. /**
  106220. * Defines the camera the input is attached to.
  106221. */
  106222. camera: ArcRotateCamera;
  106223. /**
  106224. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  106225. */
  106226. alphaCorrection: number;
  106227. /**
  106228. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  106229. */
  106230. gammaCorrection: number;
  106231. private _alpha;
  106232. private _gamma;
  106233. private _dirty;
  106234. private _deviceOrientationHandler;
  106235. /**
  106236. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  106237. */
  106238. constructor();
  106239. /**
  106240. * Attach the input controls to a specific dom element to get the input from.
  106241. * @param element Defines the element the controls should be listened from
  106242. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106243. */
  106244. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106245. /** @hidden */
  106246. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  106247. /**
  106248. * Update the current camera state depending on the inputs that have been used this frame.
  106249. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106250. */
  106251. checkInputs(): void;
  106252. /**
  106253. * Detach the current controls from the specified dom element.
  106254. * @param element Defines the element to stop listening the inputs from
  106255. */
  106256. detachControl(element: Nullable<HTMLElement>): void;
  106257. /**
  106258. * Gets the class name of the current intput.
  106259. * @returns the class name
  106260. */
  106261. getClassName(): string;
  106262. /**
  106263. * Get the friendly name associated with the input class.
  106264. * @returns the input friendly name
  106265. */
  106266. getSimpleName(): string;
  106267. }
  106268. }
  106269. declare module BABYLON {
  106270. /**
  106271. * Listen to mouse events to control the camera.
  106272. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106273. */
  106274. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  106275. /**
  106276. * Defines the camera the input is attached to.
  106277. */
  106278. camera: FlyCamera;
  106279. /**
  106280. * Defines if touch is enabled. (Default is true.)
  106281. */
  106282. touchEnabled: boolean;
  106283. /**
  106284. * Defines the buttons associated with the input to handle camera rotation.
  106285. */
  106286. buttons: number[];
  106287. /**
  106288. * Assign buttons for Yaw control.
  106289. */
  106290. buttonsYaw: number[];
  106291. /**
  106292. * Assign buttons for Pitch control.
  106293. */
  106294. buttonsPitch: number[];
  106295. /**
  106296. * Assign buttons for Roll control.
  106297. */
  106298. buttonsRoll: number[];
  106299. /**
  106300. * Detect if any button is being pressed while mouse is moved.
  106301. * -1 = Mouse locked.
  106302. * 0 = Left button.
  106303. * 1 = Middle Button.
  106304. * 2 = Right Button.
  106305. */
  106306. activeButton: number;
  106307. /**
  106308. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  106309. * Higher values reduce its sensitivity.
  106310. */
  106311. angularSensibility: number;
  106312. private _mousemoveCallback;
  106313. private _observer;
  106314. private _rollObserver;
  106315. private previousPosition;
  106316. private noPreventDefault;
  106317. private element;
  106318. /**
  106319. * Listen to mouse events to control the camera.
  106320. * @param touchEnabled Define if touch is enabled. (Default is true.)
  106321. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106322. */
  106323. constructor(touchEnabled?: boolean);
  106324. /**
  106325. * Attach the mouse control to the HTML DOM element.
  106326. * @param element Defines the element that listens to the input events.
  106327. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  106328. */
  106329. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106330. /**
  106331. * Detach the current controls from the specified dom element.
  106332. * @param element Defines the element to stop listening the inputs from
  106333. */
  106334. detachControl(element: Nullable<HTMLElement>): void;
  106335. /**
  106336. * Gets the class name of the current input.
  106337. * @returns the class name.
  106338. */
  106339. getClassName(): string;
  106340. /**
  106341. * Get the friendly name associated with the input class.
  106342. * @returns the input's friendly name.
  106343. */
  106344. getSimpleName(): string;
  106345. private _pointerInput;
  106346. private _onMouseMove;
  106347. /**
  106348. * Rotate camera by mouse offset.
  106349. */
  106350. private rotateCamera;
  106351. }
  106352. }
  106353. declare module BABYLON {
  106354. /**
  106355. * Default Inputs manager for the FlyCamera.
  106356. * It groups all the default supported inputs for ease of use.
  106357. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106358. */
  106359. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  106360. /**
  106361. * Instantiates a new FlyCameraInputsManager.
  106362. * @param camera Defines the camera the inputs belong to.
  106363. */
  106364. constructor(camera: FlyCamera);
  106365. /**
  106366. * Add keyboard input support to the input manager.
  106367. * @returns the new FlyCameraKeyboardMoveInput().
  106368. */
  106369. addKeyboard(): FlyCameraInputsManager;
  106370. /**
  106371. * Add mouse input support to the input manager.
  106372. * @param touchEnabled Enable touch screen support.
  106373. * @returns the new FlyCameraMouseInput().
  106374. */
  106375. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  106376. }
  106377. }
  106378. declare module BABYLON {
  106379. /**
  106380. * This is a flying camera, designed for 3D movement and rotation in all directions,
  106381. * such as in a 3D Space Shooter or a Flight Simulator.
  106382. */
  106383. export class FlyCamera extends TargetCamera {
  106384. /**
  106385. * Define the collision ellipsoid of the camera.
  106386. * This is helpful for simulating a camera body, like a player's body.
  106387. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  106388. */
  106389. ellipsoid: Vector3;
  106390. /**
  106391. * Define an offset for the position of the ellipsoid around the camera.
  106392. * This can be helpful if the camera is attached away from the player's body center,
  106393. * such as at its head.
  106394. */
  106395. ellipsoidOffset: Vector3;
  106396. /**
  106397. * Enable or disable collisions of the camera with the rest of the scene objects.
  106398. */
  106399. checkCollisions: boolean;
  106400. /**
  106401. * Enable or disable gravity on the camera.
  106402. */
  106403. applyGravity: boolean;
  106404. /**
  106405. * Define the current direction the camera is moving to.
  106406. */
  106407. cameraDirection: Vector3;
  106408. /**
  106409. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  106410. * This overrides and empties cameraRotation.
  106411. */
  106412. rotationQuaternion: Quaternion;
  106413. /**
  106414. * Track Roll to maintain the wanted Rolling when looking around.
  106415. */
  106416. _trackRoll: number;
  106417. /**
  106418. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  106419. */
  106420. rollCorrect: number;
  106421. /**
  106422. * Mimic a banked turn, Rolling the camera when Yawing.
  106423. * It's recommended to use rollCorrect = 10 for faster banking correction.
  106424. */
  106425. bankedTurn: boolean;
  106426. /**
  106427. * Limit in radians for how much Roll banking will add. (Default: 90°)
  106428. */
  106429. bankedTurnLimit: number;
  106430. /**
  106431. * Value of 0 disables the banked Roll.
  106432. * Value of 1 is equal to the Yaw angle in radians.
  106433. */
  106434. bankedTurnMultiplier: number;
  106435. /**
  106436. * The inputs manager loads all the input sources, such as keyboard and mouse.
  106437. */
  106438. inputs: FlyCameraInputsManager;
  106439. /**
  106440. * Gets the input sensibility for mouse input.
  106441. * Higher values reduce sensitivity.
  106442. */
  106443. /**
  106444. * Sets the input sensibility for a mouse input.
  106445. * Higher values reduce sensitivity.
  106446. */
  106447. angularSensibility: number;
  106448. /**
  106449. * Get the keys for camera movement forward.
  106450. */
  106451. /**
  106452. * Set the keys for camera movement forward.
  106453. */
  106454. keysForward: number[];
  106455. /**
  106456. * Get the keys for camera movement backward.
  106457. */
  106458. keysBackward: number[];
  106459. /**
  106460. * Get the keys for camera movement up.
  106461. */
  106462. /**
  106463. * Set the keys for camera movement up.
  106464. */
  106465. keysUp: number[];
  106466. /**
  106467. * Get the keys for camera movement down.
  106468. */
  106469. /**
  106470. * Set the keys for camera movement down.
  106471. */
  106472. keysDown: number[];
  106473. /**
  106474. * Get the keys for camera movement left.
  106475. */
  106476. /**
  106477. * Set the keys for camera movement left.
  106478. */
  106479. keysLeft: number[];
  106480. /**
  106481. * Set the keys for camera movement right.
  106482. */
  106483. /**
  106484. * Set the keys for camera movement right.
  106485. */
  106486. keysRight: number[];
  106487. /**
  106488. * Event raised when the camera collides with a mesh in the scene.
  106489. */
  106490. onCollide: (collidedMesh: AbstractMesh) => void;
  106491. private _collider;
  106492. private _needMoveForGravity;
  106493. private _oldPosition;
  106494. private _diffPosition;
  106495. private _newPosition;
  106496. /** @hidden */
  106497. _localDirection: Vector3;
  106498. /** @hidden */
  106499. _transformedDirection: Vector3;
  106500. /**
  106501. * Instantiates a FlyCamera.
  106502. * This is a flying camera, designed for 3D movement and rotation in all directions,
  106503. * such as in a 3D Space Shooter or a Flight Simulator.
  106504. * @param name Define the name of the camera in the scene.
  106505. * @param position Define the starting position of the camera in the scene.
  106506. * @param scene Define the scene the camera belongs to.
  106507. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  106508. */
  106509. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106510. /**
  106511. * Attach a control to the HTML DOM element.
  106512. * @param element Defines the element that listens to the input events.
  106513. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  106514. */
  106515. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106516. /**
  106517. * Detach a control from the HTML DOM element.
  106518. * The camera will stop reacting to that input.
  106519. * @param element Defines the element that listens to the input events.
  106520. */
  106521. detachControl(element: HTMLElement): void;
  106522. private _collisionMask;
  106523. /**
  106524. * Get the mask that the camera ignores in collision events.
  106525. */
  106526. /**
  106527. * Set the mask that the camera ignores in collision events.
  106528. */
  106529. collisionMask: number;
  106530. /** @hidden */
  106531. _collideWithWorld(displacement: Vector3): void;
  106532. /** @hidden */
  106533. private _onCollisionPositionChange;
  106534. /** @hidden */
  106535. _checkInputs(): void;
  106536. /** @hidden */
  106537. _decideIfNeedsToMove(): boolean;
  106538. /** @hidden */
  106539. _updatePosition(): void;
  106540. /**
  106541. * Restore the Roll to its target value at the rate specified.
  106542. * @param rate - Higher means slower restoring.
  106543. * @hidden
  106544. */
  106545. restoreRoll(rate: number): void;
  106546. /**
  106547. * Destroy the camera and release the current resources held by it.
  106548. */
  106549. dispose(): void;
  106550. /**
  106551. * Get the current object class name.
  106552. * @returns the class name.
  106553. */
  106554. getClassName(): string;
  106555. }
  106556. }
  106557. declare module BABYLON {
  106558. /**
  106559. * Listen to keyboard events to control the camera.
  106560. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106561. */
  106562. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  106563. /**
  106564. * Defines the camera the input is attached to.
  106565. */
  106566. camera: FlyCamera;
  106567. /**
  106568. * The list of keyboard keys used to control the forward move of the camera.
  106569. */
  106570. keysForward: number[];
  106571. /**
  106572. * The list of keyboard keys used to control the backward move of the camera.
  106573. */
  106574. keysBackward: number[];
  106575. /**
  106576. * The list of keyboard keys used to control the forward move of the camera.
  106577. */
  106578. keysUp: number[];
  106579. /**
  106580. * The list of keyboard keys used to control the backward move of the camera.
  106581. */
  106582. keysDown: number[];
  106583. /**
  106584. * The list of keyboard keys used to control the right strafe move of the camera.
  106585. */
  106586. keysRight: number[];
  106587. /**
  106588. * The list of keyboard keys used to control the left strafe move of the camera.
  106589. */
  106590. keysLeft: number[];
  106591. private _keys;
  106592. private _onCanvasBlurObserver;
  106593. private _onKeyboardObserver;
  106594. private _engine;
  106595. private _scene;
  106596. /**
  106597. * Attach the input controls to a specific dom element to get the input from.
  106598. * @param element Defines the element the controls should be listened from
  106599. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106600. */
  106601. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106602. /**
  106603. * Detach the current controls from the specified dom element.
  106604. * @param element Defines the element to stop listening the inputs from
  106605. */
  106606. detachControl(element: Nullable<HTMLElement>): void;
  106607. /**
  106608. * Gets the class name of the current intput.
  106609. * @returns the class name
  106610. */
  106611. getClassName(): string;
  106612. /** @hidden */
  106613. _onLostFocus(e: FocusEvent): void;
  106614. /**
  106615. * Get the friendly name associated with the input class.
  106616. * @returns the input friendly name
  106617. */
  106618. getSimpleName(): string;
  106619. /**
  106620. * Update the current camera state depending on the inputs that have been used this frame.
  106621. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106622. */
  106623. checkInputs(): void;
  106624. }
  106625. }
  106626. declare module BABYLON {
  106627. /**
  106628. * Manage the mouse wheel inputs to control a follow camera.
  106629. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106630. */
  106631. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  106632. /**
  106633. * Defines the camera the input is attached to.
  106634. */
  106635. camera: FollowCamera;
  106636. /**
  106637. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  106638. */
  106639. axisControlRadius: boolean;
  106640. /**
  106641. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  106642. */
  106643. axisControlHeight: boolean;
  106644. /**
  106645. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  106646. */
  106647. axisControlRotation: boolean;
  106648. /**
  106649. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  106650. * relation to mouseWheel events.
  106651. */
  106652. wheelPrecision: number;
  106653. /**
  106654. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  106655. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  106656. */
  106657. wheelDeltaPercentage: number;
  106658. private _wheel;
  106659. private _observer;
  106660. /**
  106661. * Attach the input controls to a specific dom element to get the input from.
  106662. * @param element Defines the element the controls should be listened from
  106663. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106664. */
  106665. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106666. /**
  106667. * Detach the current controls from the specified dom element.
  106668. * @param element Defines the element to stop listening the inputs from
  106669. */
  106670. detachControl(element: Nullable<HTMLElement>): void;
  106671. /**
  106672. * Gets the class name of the current intput.
  106673. * @returns the class name
  106674. */
  106675. getClassName(): string;
  106676. /**
  106677. * Get the friendly name associated with the input class.
  106678. * @returns the input friendly name
  106679. */
  106680. getSimpleName(): string;
  106681. }
  106682. }
  106683. declare module BABYLON {
  106684. /**
  106685. * Manage the pointers inputs to control an follow camera.
  106686. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106687. */
  106688. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  106689. /**
  106690. * Defines the camera the input is attached to.
  106691. */
  106692. camera: FollowCamera;
  106693. /**
  106694. * Gets the class name of the current input.
  106695. * @returns the class name
  106696. */
  106697. getClassName(): string;
  106698. /**
  106699. * Defines the pointer angular sensibility along the X axis or how fast is
  106700. * the camera rotating.
  106701. * A negative number will reverse the axis direction.
  106702. */
  106703. angularSensibilityX: number;
  106704. /**
  106705. * Defines the pointer angular sensibility along the Y axis or how fast is
  106706. * the camera rotating.
  106707. * A negative number will reverse the axis direction.
  106708. */
  106709. angularSensibilityY: number;
  106710. /**
  106711. * Defines the pointer pinch precision or how fast is the camera zooming.
  106712. * A negative number will reverse the axis direction.
  106713. */
  106714. pinchPrecision: number;
  106715. /**
  106716. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  106717. * from 0.
  106718. * It defines the percentage of current camera.radius to use as delta when
  106719. * pinch zoom is used.
  106720. */
  106721. pinchDeltaPercentage: number;
  106722. /**
  106723. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  106724. */
  106725. axisXControlRadius: boolean;
  106726. /**
  106727. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  106728. */
  106729. axisXControlHeight: boolean;
  106730. /**
  106731. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  106732. */
  106733. axisXControlRotation: boolean;
  106734. /**
  106735. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  106736. */
  106737. axisYControlRadius: boolean;
  106738. /**
  106739. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  106740. */
  106741. axisYControlHeight: boolean;
  106742. /**
  106743. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  106744. */
  106745. axisYControlRotation: boolean;
  106746. /**
  106747. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  106748. */
  106749. axisPinchControlRadius: boolean;
  106750. /**
  106751. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  106752. */
  106753. axisPinchControlHeight: boolean;
  106754. /**
  106755. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  106756. */
  106757. axisPinchControlRotation: boolean;
  106758. /**
  106759. * Log error messages if basic misconfiguration has occurred.
  106760. */
  106761. warningEnable: boolean;
  106762. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106763. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106764. private _warningCounter;
  106765. private _warning;
  106766. }
  106767. }
  106768. declare module BABYLON {
  106769. /**
  106770. * Default Inputs manager for the FollowCamera.
  106771. * It groups all the default supported inputs for ease of use.
  106772. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106773. */
  106774. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  106775. /**
  106776. * Instantiates a new FollowCameraInputsManager.
  106777. * @param camera Defines the camera the inputs belong to
  106778. */
  106779. constructor(camera: FollowCamera);
  106780. /**
  106781. * Add keyboard input support to the input manager.
  106782. * @returns the current input manager
  106783. */
  106784. addKeyboard(): FollowCameraInputsManager;
  106785. /**
  106786. * Add mouse wheel input support to the input manager.
  106787. * @returns the current input manager
  106788. */
  106789. addMouseWheel(): FollowCameraInputsManager;
  106790. /**
  106791. * Add pointers input support to the input manager.
  106792. * @returns the current input manager
  106793. */
  106794. addPointers(): FollowCameraInputsManager;
  106795. /**
  106796. * Add orientation input support to the input manager.
  106797. * @returns the current input manager
  106798. */
  106799. addVRDeviceOrientation(): FollowCameraInputsManager;
  106800. }
  106801. }
  106802. declare module BABYLON {
  106803. /**
  106804. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  106805. * an arc rotate version arcFollowCamera are available.
  106806. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106807. */
  106808. export class FollowCamera extends TargetCamera {
  106809. /**
  106810. * Distance the follow camera should follow an object at
  106811. */
  106812. radius: number;
  106813. /**
  106814. * Minimum allowed distance of the camera to the axis of rotation
  106815. * (The camera can not get closer).
  106816. * This can help limiting how the Camera is able to move in the scene.
  106817. */
  106818. lowerRadiusLimit: Nullable<number>;
  106819. /**
  106820. * Maximum allowed distance of the camera to the axis of rotation
  106821. * (The camera can not get further).
  106822. * This can help limiting how the Camera is able to move in the scene.
  106823. */
  106824. upperRadiusLimit: Nullable<number>;
  106825. /**
  106826. * Define a rotation offset between the camera and the object it follows
  106827. */
  106828. rotationOffset: number;
  106829. /**
  106830. * Minimum allowed angle to camera position relative to target object.
  106831. * This can help limiting how the Camera is able to move in the scene.
  106832. */
  106833. lowerRotationOffsetLimit: Nullable<number>;
  106834. /**
  106835. * Maximum allowed angle to camera position relative to target object.
  106836. * This can help limiting how the Camera is able to move in the scene.
  106837. */
  106838. upperRotationOffsetLimit: Nullable<number>;
  106839. /**
  106840. * Define a height offset between the camera and the object it follows.
  106841. * It can help following an object from the top (like a car chaing a plane)
  106842. */
  106843. heightOffset: number;
  106844. /**
  106845. * Minimum allowed height of camera position relative to target object.
  106846. * This can help limiting how the Camera is able to move in the scene.
  106847. */
  106848. lowerHeightOffsetLimit: Nullable<number>;
  106849. /**
  106850. * Maximum allowed height of camera position relative to target object.
  106851. * This can help limiting how the Camera is able to move in the scene.
  106852. */
  106853. upperHeightOffsetLimit: Nullable<number>;
  106854. /**
  106855. * Define how fast the camera can accelerate to follow it s target.
  106856. */
  106857. cameraAcceleration: number;
  106858. /**
  106859. * Define the speed limit of the camera following an object.
  106860. */
  106861. maxCameraSpeed: number;
  106862. /**
  106863. * Define the target of the camera.
  106864. */
  106865. lockedTarget: Nullable<AbstractMesh>;
  106866. /**
  106867. * Defines the input associated with the camera.
  106868. */
  106869. inputs: FollowCameraInputsManager;
  106870. /**
  106871. * Instantiates the follow camera.
  106872. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106873. * @param name Define the name of the camera in the scene
  106874. * @param position Define the position of the camera
  106875. * @param scene Define the scene the camera belong to
  106876. * @param lockedTarget Define the target of the camera
  106877. */
  106878. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  106879. private _follow;
  106880. /**
  106881. * Attached controls to the current camera.
  106882. * @param element Defines the element the controls should be listened from
  106883. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106884. */
  106885. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106886. /**
  106887. * Detach the current controls from the camera.
  106888. * The camera will stop reacting to inputs.
  106889. * @param element Defines the element to stop listening the inputs from
  106890. */
  106891. detachControl(element: HTMLElement): void;
  106892. /** @hidden */
  106893. _checkInputs(): void;
  106894. private _checkLimits;
  106895. /**
  106896. * Gets the camera class name.
  106897. * @returns the class name
  106898. */
  106899. getClassName(): string;
  106900. }
  106901. /**
  106902. * Arc Rotate version of the follow camera.
  106903. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  106904. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106905. */
  106906. export class ArcFollowCamera extends TargetCamera {
  106907. /** The longitudinal angle of the camera */
  106908. alpha: number;
  106909. /** The latitudinal angle of the camera */
  106910. beta: number;
  106911. /** The radius of the camera from its target */
  106912. radius: number;
  106913. /** Define the camera target (the messh it should follow) */
  106914. target: Nullable<AbstractMesh>;
  106915. private _cartesianCoordinates;
  106916. /**
  106917. * Instantiates a new ArcFollowCamera
  106918. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106919. * @param name Define the name of the camera
  106920. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  106921. * @param beta Define the rotation angle of the camera around the elevation axis
  106922. * @param radius Define the radius of the camera from its target point
  106923. * @param target Define the target of the camera
  106924. * @param scene Define the scene the camera belongs to
  106925. */
  106926. constructor(name: string,
  106927. /** The longitudinal angle of the camera */
  106928. alpha: number,
  106929. /** The latitudinal angle of the camera */
  106930. beta: number,
  106931. /** The radius of the camera from its target */
  106932. radius: number,
  106933. /** Define the camera target (the messh it should follow) */
  106934. target: Nullable<AbstractMesh>, scene: Scene);
  106935. private _follow;
  106936. /** @hidden */
  106937. _checkInputs(): void;
  106938. /**
  106939. * Returns the class name of the object.
  106940. * It is mostly used internally for serialization purposes.
  106941. */
  106942. getClassName(): string;
  106943. }
  106944. }
  106945. declare module BABYLON {
  106946. /**
  106947. * Manage the keyboard inputs to control the movement of a follow camera.
  106948. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106949. */
  106950. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  106951. /**
  106952. * Defines the camera the input is attached to.
  106953. */
  106954. camera: FollowCamera;
  106955. /**
  106956. * Defines the list of key codes associated with the up action (increase heightOffset)
  106957. */
  106958. keysHeightOffsetIncr: number[];
  106959. /**
  106960. * Defines the list of key codes associated with the down action (decrease heightOffset)
  106961. */
  106962. keysHeightOffsetDecr: number[];
  106963. /**
  106964. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  106965. */
  106966. keysHeightOffsetModifierAlt: boolean;
  106967. /**
  106968. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  106969. */
  106970. keysHeightOffsetModifierCtrl: boolean;
  106971. /**
  106972. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  106973. */
  106974. keysHeightOffsetModifierShift: boolean;
  106975. /**
  106976. * Defines the list of key codes associated with the left action (increase rotationOffset)
  106977. */
  106978. keysRotationOffsetIncr: number[];
  106979. /**
  106980. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  106981. */
  106982. keysRotationOffsetDecr: number[];
  106983. /**
  106984. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  106985. */
  106986. keysRotationOffsetModifierAlt: boolean;
  106987. /**
  106988. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  106989. */
  106990. keysRotationOffsetModifierCtrl: boolean;
  106991. /**
  106992. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  106993. */
  106994. keysRotationOffsetModifierShift: boolean;
  106995. /**
  106996. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  106997. */
  106998. keysRadiusIncr: number[];
  106999. /**
  107000. * Defines the list of key codes associated with the zoom-out action (increase radius)
  107001. */
  107002. keysRadiusDecr: number[];
  107003. /**
  107004. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  107005. */
  107006. keysRadiusModifierAlt: boolean;
  107007. /**
  107008. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  107009. */
  107010. keysRadiusModifierCtrl: boolean;
  107011. /**
  107012. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  107013. */
  107014. keysRadiusModifierShift: boolean;
  107015. /**
  107016. * Defines the rate of change of heightOffset.
  107017. */
  107018. heightSensibility: number;
  107019. /**
  107020. * Defines the rate of change of rotationOffset.
  107021. */
  107022. rotationSensibility: number;
  107023. /**
  107024. * Defines the rate of change of radius.
  107025. */
  107026. radiusSensibility: number;
  107027. private _keys;
  107028. private _ctrlPressed;
  107029. private _altPressed;
  107030. private _shiftPressed;
  107031. private _onCanvasBlurObserver;
  107032. private _onKeyboardObserver;
  107033. private _engine;
  107034. private _scene;
  107035. /**
  107036. * Attach the input controls to a specific dom element to get the input from.
  107037. * @param element Defines the element the controls should be listened from
  107038. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107039. */
  107040. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107041. /**
  107042. * Detach the current controls from the specified dom element.
  107043. * @param element Defines the element to stop listening the inputs from
  107044. */
  107045. detachControl(element: Nullable<HTMLElement>): void;
  107046. /**
  107047. * Update the current camera state depending on the inputs that have been used this frame.
  107048. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107049. */
  107050. checkInputs(): void;
  107051. /**
  107052. * Gets the class name of the current input.
  107053. * @returns the class name
  107054. */
  107055. getClassName(): string;
  107056. /**
  107057. * Get the friendly name associated with the input class.
  107058. * @returns the input friendly name
  107059. */
  107060. getSimpleName(): string;
  107061. /**
  107062. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  107063. * allow modification of the heightOffset value.
  107064. */
  107065. private _modifierHeightOffset;
  107066. /**
  107067. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  107068. * allow modification of the rotationOffset value.
  107069. */
  107070. private _modifierRotationOffset;
  107071. /**
  107072. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  107073. * allow modification of the radius value.
  107074. */
  107075. private _modifierRadius;
  107076. }
  107077. }
  107078. declare module BABYLON {
  107079. interface FreeCameraInputsManager {
  107080. /**
  107081. * @hidden
  107082. */
  107083. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  107084. /**
  107085. * Add orientation input support to the input manager.
  107086. * @returns the current input manager
  107087. */
  107088. addDeviceOrientation(): FreeCameraInputsManager;
  107089. }
  107090. /**
  107091. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  107092. * Screen rotation is taken into account.
  107093. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107094. */
  107095. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  107096. private _camera;
  107097. private _screenOrientationAngle;
  107098. private _constantTranform;
  107099. private _screenQuaternion;
  107100. private _alpha;
  107101. private _beta;
  107102. private _gamma;
  107103. /**
  107104. * Can be used to detect if a device orientation sensor is availible on a device
  107105. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  107106. * @returns a promise that will resolve on orientation change
  107107. */
  107108. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  107109. /**
  107110. * @hidden
  107111. */
  107112. _onDeviceOrientationChangedObservable: Observable<void>;
  107113. /**
  107114. * Instantiates a new input
  107115. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107116. */
  107117. constructor();
  107118. /**
  107119. * Define the camera controlled by the input.
  107120. */
  107121. camera: FreeCamera;
  107122. /**
  107123. * Attach the input controls to a specific dom element to get the input from.
  107124. * @param element Defines the element the controls should be listened from
  107125. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107126. */
  107127. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107128. private _orientationChanged;
  107129. private _deviceOrientation;
  107130. /**
  107131. * Detach the current controls from the specified dom element.
  107132. * @param element Defines the element to stop listening the inputs from
  107133. */
  107134. detachControl(element: Nullable<HTMLElement>): void;
  107135. /**
  107136. * Update the current camera state depending on the inputs that have been used this frame.
  107137. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107138. */
  107139. checkInputs(): void;
  107140. /**
  107141. * Gets the class name of the current intput.
  107142. * @returns the class name
  107143. */
  107144. getClassName(): string;
  107145. /**
  107146. * Get the friendly name associated with the input class.
  107147. * @returns the input friendly name
  107148. */
  107149. getSimpleName(): string;
  107150. }
  107151. }
  107152. declare module BABYLON {
  107153. /**
  107154. * Manage the gamepad inputs to control a free camera.
  107155. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107156. */
  107157. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  107158. /**
  107159. * Define the camera the input is attached to.
  107160. */
  107161. camera: FreeCamera;
  107162. /**
  107163. * Define the Gamepad controlling the input
  107164. */
  107165. gamepad: Nullable<Gamepad>;
  107166. /**
  107167. * Defines the gamepad rotation sensiblity.
  107168. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107169. */
  107170. gamepadAngularSensibility: number;
  107171. /**
  107172. * Defines the gamepad move sensiblity.
  107173. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107174. */
  107175. gamepadMoveSensibility: number;
  107176. private _yAxisScale;
  107177. /**
  107178. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  107179. */
  107180. invertYAxis: boolean;
  107181. private _onGamepadConnectedObserver;
  107182. private _onGamepadDisconnectedObserver;
  107183. private _cameraTransform;
  107184. private _deltaTransform;
  107185. private _vector3;
  107186. private _vector2;
  107187. /**
  107188. * Attach the input controls to a specific dom element to get the input from.
  107189. * @param element Defines the element the controls should be listened from
  107190. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107191. */
  107192. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107193. /**
  107194. * Detach the current controls from the specified dom element.
  107195. * @param element Defines the element to stop listening the inputs from
  107196. */
  107197. detachControl(element: Nullable<HTMLElement>): void;
  107198. /**
  107199. * Update the current camera state depending on the inputs that have been used this frame.
  107200. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107201. */
  107202. checkInputs(): void;
  107203. /**
  107204. * Gets the class name of the current intput.
  107205. * @returns the class name
  107206. */
  107207. getClassName(): string;
  107208. /**
  107209. * Get the friendly name associated with the input class.
  107210. * @returns the input friendly name
  107211. */
  107212. getSimpleName(): string;
  107213. }
  107214. }
  107215. declare module BABYLON {
  107216. /**
  107217. * Defines the potential axis of a Joystick
  107218. */
  107219. export enum JoystickAxis {
  107220. /** X axis */
  107221. X = 0,
  107222. /** Y axis */
  107223. Y = 1,
  107224. /** Z axis */
  107225. Z = 2
  107226. }
  107227. /**
  107228. * Class used to define virtual joystick (used in touch mode)
  107229. */
  107230. export class VirtualJoystick {
  107231. /**
  107232. * Gets or sets a boolean indicating that left and right values must be inverted
  107233. */
  107234. reverseLeftRight: boolean;
  107235. /**
  107236. * Gets or sets a boolean indicating that up and down values must be inverted
  107237. */
  107238. reverseUpDown: boolean;
  107239. /**
  107240. * Gets the offset value for the position (ie. the change of the position value)
  107241. */
  107242. deltaPosition: Vector3;
  107243. /**
  107244. * Gets a boolean indicating if the virtual joystick was pressed
  107245. */
  107246. pressed: boolean;
  107247. /**
  107248. * Canvas the virtual joystick will render onto, default z-index of this is 5
  107249. */
  107250. static Canvas: Nullable<HTMLCanvasElement>;
  107251. private static _globalJoystickIndex;
  107252. private static vjCanvasContext;
  107253. private static vjCanvasWidth;
  107254. private static vjCanvasHeight;
  107255. private static halfWidth;
  107256. private _action;
  107257. private _axisTargetedByLeftAndRight;
  107258. private _axisTargetedByUpAndDown;
  107259. private _joystickSensibility;
  107260. private _inversedSensibility;
  107261. private _joystickPointerID;
  107262. private _joystickColor;
  107263. private _joystickPointerPos;
  107264. private _joystickPreviousPointerPos;
  107265. private _joystickPointerStartPos;
  107266. private _deltaJoystickVector;
  107267. private _leftJoystick;
  107268. private _touches;
  107269. private _onPointerDownHandlerRef;
  107270. private _onPointerMoveHandlerRef;
  107271. private _onPointerUpHandlerRef;
  107272. private _onResize;
  107273. /**
  107274. * Creates a new virtual joystick
  107275. * @param leftJoystick defines that the joystick is for left hand (false by default)
  107276. */
  107277. constructor(leftJoystick?: boolean);
  107278. /**
  107279. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  107280. * @param newJoystickSensibility defines the new sensibility
  107281. */
  107282. setJoystickSensibility(newJoystickSensibility: number): void;
  107283. private _onPointerDown;
  107284. private _onPointerMove;
  107285. private _onPointerUp;
  107286. /**
  107287. * Change the color of the virtual joystick
  107288. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  107289. */
  107290. setJoystickColor(newColor: string): void;
  107291. /**
  107292. * Defines a callback to call when the joystick is touched
  107293. * @param action defines the callback
  107294. */
  107295. setActionOnTouch(action: () => any): void;
  107296. /**
  107297. * Defines which axis you'd like to control for left & right
  107298. * @param axis defines the axis to use
  107299. */
  107300. setAxisForLeftRight(axis: JoystickAxis): void;
  107301. /**
  107302. * Defines which axis you'd like to control for up & down
  107303. * @param axis defines the axis to use
  107304. */
  107305. setAxisForUpDown(axis: JoystickAxis): void;
  107306. private _drawVirtualJoystick;
  107307. /**
  107308. * Release internal HTML canvas
  107309. */
  107310. releaseCanvas(): void;
  107311. }
  107312. }
  107313. declare module BABYLON {
  107314. interface FreeCameraInputsManager {
  107315. /**
  107316. * Add virtual joystick input support to the input manager.
  107317. * @returns the current input manager
  107318. */
  107319. addVirtualJoystick(): FreeCameraInputsManager;
  107320. }
  107321. /**
  107322. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  107323. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107324. */
  107325. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  107326. /**
  107327. * Defines the camera the input is attached to.
  107328. */
  107329. camera: FreeCamera;
  107330. private _leftjoystick;
  107331. private _rightjoystick;
  107332. /**
  107333. * Gets the left stick of the virtual joystick.
  107334. * @returns The virtual Joystick
  107335. */
  107336. getLeftJoystick(): VirtualJoystick;
  107337. /**
  107338. * Gets the right stick of the virtual joystick.
  107339. * @returns The virtual Joystick
  107340. */
  107341. getRightJoystick(): VirtualJoystick;
  107342. /**
  107343. * Update the current camera state depending on the inputs that have been used this frame.
  107344. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107345. */
  107346. checkInputs(): void;
  107347. /**
  107348. * Attach the input controls to a specific dom element to get the input from.
  107349. * @param element Defines the element the controls should be listened from
  107350. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107351. */
  107352. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107353. /**
  107354. * Detach the current controls from the specified dom element.
  107355. * @param element Defines the element to stop listening the inputs from
  107356. */
  107357. detachControl(element: Nullable<HTMLElement>): void;
  107358. /**
  107359. * Gets the class name of the current intput.
  107360. * @returns the class name
  107361. */
  107362. getClassName(): string;
  107363. /**
  107364. * Get the friendly name associated with the input class.
  107365. * @returns the input friendly name
  107366. */
  107367. getSimpleName(): string;
  107368. }
  107369. }
  107370. declare module BABYLON {
  107371. /**
  107372. * This represents a FPS type of camera controlled by touch.
  107373. * This is like a universal camera minus the Gamepad controls.
  107374. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107375. */
  107376. export class TouchCamera extends FreeCamera {
  107377. /**
  107378. * Defines the touch sensibility for rotation.
  107379. * The higher the faster.
  107380. */
  107381. touchAngularSensibility: number;
  107382. /**
  107383. * Defines the touch sensibility for move.
  107384. * The higher the faster.
  107385. */
  107386. touchMoveSensibility: number;
  107387. /**
  107388. * Instantiates a new touch camera.
  107389. * This represents a FPS type of camera controlled by touch.
  107390. * This is like a universal camera minus the Gamepad controls.
  107391. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107392. * @param name Define the name of the camera in the scene
  107393. * @param position Define the start position of the camera in the scene
  107394. * @param scene Define the scene the camera belongs to
  107395. */
  107396. constructor(name: string, position: Vector3, scene: Scene);
  107397. /**
  107398. * Gets the current object class name.
  107399. * @return the class name
  107400. */
  107401. getClassName(): string;
  107402. /** @hidden */
  107403. _setupInputs(): void;
  107404. }
  107405. }
  107406. declare module BABYLON {
  107407. /**
  107408. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  107409. * being tilted forward or back and left or right.
  107410. */
  107411. export class DeviceOrientationCamera extends FreeCamera {
  107412. private _initialQuaternion;
  107413. private _quaternionCache;
  107414. private _tmpDragQuaternion;
  107415. private _disablePointerInputWhenUsingDeviceOrientation;
  107416. /**
  107417. * Creates a new device orientation camera
  107418. * @param name The name of the camera
  107419. * @param position The start position camera
  107420. * @param scene The scene the camera belongs to
  107421. */
  107422. constructor(name: string, position: Vector3, scene: Scene);
  107423. /**
  107424. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  107425. */
  107426. disablePointerInputWhenUsingDeviceOrientation: boolean;
  107427. private _dragFactor;
  107428. /**
  107429. * Enabled turning on the y axis when the orientation sensor is active
  107430. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  107431. */
  107432. enableHorizontalDragging(dragFactor?: number): void;
  107433. /**
  107434. * Gets the current instance class name ("DeviceOrientationCamera").
  107435. * This helps avoiding instanceof at run time.
  107436. * @returns the class name
  107437. */
  107438. getClassName(): string;
  107439. /**
  107440. * @hidden
  107441. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  107442. */
  107443. _checkInputs(): void;
  107444. /**
  107445. * Reset the camera to its default orientation on the specified axis only.
  107446. * @param axis The axis to reset
  107447. */
  107448. resetToCurrentRotation(axis?: Axis): void;
  107449. }
  107450. }
  107451. declare module BABYLON {
  107452. /**
  107453. * Defines supported buttons for XBox360 compatible gamepads
  107454. */
  107455. export enum Xbox360Button {
  107456. /** A */
  107457. A = 0,
  107458. /** B */
  107459. B = 1,
  107460. /** X */
  107461. X = 2,
  107462. /** Y */
  107463. Y = 3,
  107464. /** Start */
  107465. Start = 4,
  107466. /** Back */
  107467. Back = 5,
  107468. /** Left button */
  107469. LB = 6,
  107470. /** Right button */
  107471. RB = 7,
  107472. /** Left stick */
  107473. LeftStick = 8,
  107474. /** Right stick */
  107475. RightStick = 9
  107476. }
  107477. /** Defines values for XBox360 DPad */
  107478. export enum Xbox360Dpad {
  107479. /** Up */
  107480. Up = 0,
  107481. /** Down */
  107482. Down = 1,
  107483. /** Left */
  107484. Left = 2,
  107485. /** Right */
  107486. Right = 3
  107487. }
  107488. /**
  107489. * Defines a XBox360 gamepad
  107490. */
  107491. export class Xbox360Pad extends Gamepad {
  107492. private _leftTrigger;
  107493. private _rightTrigger;
  107494. private _onlefttriggerchanged;
  107495. private _onrighttriggerchanged;
  107496. private _onbuttondown;
  107497. private _onbuttonup;
  107498. private _ondpaddown;
  107499. private _ondpadup;
  107500. /** Observable raised when a button is pressed */
  107501. onButtonDownObservable: Observable<Xbox360Button>;
  107502. /** Observable raised when a button is released */
  107503. onButtonUpObservable: Observable<Xbox360Button>;
  107504. /** Observable raised when a pad is pressed */
  107505. onPadDownObservable: Observable<Xbox360Dpad>;
  107506. /** Observable raised when a pad is released */
  107507. onPadUpObservable: Observable<Xbox360Dpad>;
  107508. private _buttonA;
  107509. private _buttonB;
  107510. private _buttonX;
  107511. private _buttonY;
  107512. private _buttonBack;
  107513. private _buttonStart;
  107514. private _buttonLB;
  107515. private _buttonRB;
  107516. private _buttonLeftStick;
  107517. private _buttonRightStick;
  107518. private _dPadUp;
  107519. private _dPadDown;
  107520. private _dPadLeft;
  107521. private _dPadRight;
  107522. private _isXboxOnePad;
  107523. /**
  107524. * Creates a new XBox360 gamepad object
  107525. * @param id defines the id of this gamepad
  107526. * @param index defines its index
  107527. * @param gamepad defines the internal HTML gamepad object
  107528. * @param xboxOne defines if it is a XBox One gamepad
  107529. */
  107530. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  107531. /**
  107532. * Defines the callback to call when left trigger is pressed
  107533. * @param callback defines the callback to use
  107534. */
  107535. onlefttriggerchanged(callback: (value: number) => void): void;
  107536. /**
  107537. * Defines the callback to call when right trigger is pressed
  107538. * @param callback defines the callback to use
  107539. */
  107540. onrighttriggerchanged(callback: (value: number) => void): void;
  107541. /**
  107542. * Gets the left trigger value
  107543. */
  107544. /**
  107545. * Sets the left trigger value
  107546. */
  107547. leftTrigger: number;
  107548. /**
  107549. * Gets the right trigger value
  107550. */
  107551. /**
  107552. * Sets the right trigger value
  107553. */
  107554. rightTrigger: number;
  107555. /**
  107556. * Defines the callback to call when a button is pressed
  107557. * @param callback defines the callback to use
  107558. */
  107559. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  107560. /**
  107561. * Defines the callback to call when a button is released
  107562. * @param callback defines the callback to use
  107563. */
  107564. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  107565. /**
  107566. * Defines the callback to call when a pad is pressed
  107567. * @param callback defines the callback to use
  107568. */
  107569. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  107570. /**
  107571. * Defines the callback to call when a pad is released
  107572. * @param callback defines the callback to use
  107573. */
  107574. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  107575. private _setButtonValue;
  107576. private _setDPadValue;
  107577. /**
  107578. * Gets the value of the `A` button
  107579. */
  107580. /**
  107581. * Sets the value of the `A` button
  107582. */
  107583. buttonA: number;
  107584. /**
  107585. * Gets the value of the `B` button
  107586. */
  107587. /**
  107588. * Sets the value of the `B` button
  107589. */
  107590. buttonB: number;
  107591. /**
  107592. * Gets the value of the `X` button
  107593. */
  107594. /**
  107595. * Sets the value of the `X` button
  107596. */
  107597. buttonX: number;
  107598. /**
  107599. * Gets the value of the `Y` button
  107600. */
  107601. /**
  107602. * Sets the value of the `Y` button
  107603. */
  107604. buttonY: number;
  107605. /**
  107606. * Gets the value of the `Start` button
  107607. */
  107608. /**
  107609. * Sets the value of the `Start` button
  107610. */
  107611. buttonStart: number;
  107612. /**
  107613. * Gets the value of the `Back` button
  107614. */
  107615. /**
  107616. * Sets the value of the `Back` button
  107617. */
  107618. buttonBack: number;
  107619. /**
  107620. * Gets the value of the `Left` button
  107621. */
  107622. /**
  107623. * Sets the value of the `Left` button
  107624. */
  107625. buttonLB: number;
  107626. /**
  107627. * Gets the value of the `Right` button
  107628. */
  107629. /**
  107630. * Sets the value of the `Right` button
  107631. */
  107632. buttonRB: number;
  107633. /**
  107634. * Gets the value of the Left joystick
  107635. */
  107636. /**
  107637. * Sets the value of the Left joystick
  107638. */
  107639. buttonLeftStick: number;
  107640. /**
  107641. * Gets the value of the Right joystick
  107642. */
  107643. /**
  107644. * Sets the value of the Right joystick
  107645. */
  107646. buttonRightStick: number;
  107647. /**
  107648. * Gets the value of D-pad up
  107649. */
  107650. /**
  107651. * Sets the value of D-pad up
  107652. */
  107653. dPadUp: number;
  107654. /**
  107655. * Gets the value of D-pad down
  107656. */
  107657. /**
  107658. * Sets the value of D-pad down
  107659. */
  107660. dPadDown: number;
  107661. /**
  107662. * Gets the value of D-pad left
  107663. */
  107664. /**
  107665. * Sets the value of D-pad left
  107666. */
  107667. dPadLeft: number;
  107668. /**
  107669. * Gets the value of D-pad right
  107670. */
  107671. /**
  107672. * Sets the value of D-pad right
  107673. */
  107674. dPadRight: number;
  107675. /**
  107676. * Force the gamepad to synchronize with device values
  107677. */
  107678. update(): void;
  107679. /**
  107680. * Disposes the gamepad
  107681. */
  107682. dispose(): void;
  107683. }
  107684. }
  107685. declare module BABYLON {
  107686. /**
  107687. * Defines supported buttons for DualShock compatible gamepads
  107688. */
  107689. export enum DualShockButton {
  107690. /** Cross */
  107691. Cross = 0,
  107692. /** Circle */
  107693. Circle = 1,
  107694. /** Square */
  107695. Square = 2,
  107696. /** Triangle */
  107697. Triangle = 3,
  107698. /** Options */
  107699. Options = 4,
  107700. /** Share */
  107701. Share = 5,
  107702. /** L1 */
  107703. L1 = 6,
  107704. /** R1 */
  107705. R1 = 7,
  107706. /** Left stick */
  107707. LeftStick = 8,
  107708. /** Right stick */
  107709. RightStick = 9
  107710. }
  107711. /** Defines values for DualShock DPad */
  107712. export enum DualShockDpad {
  107713. /** Up */
  107714. Up = 0,
  107715. /** Down */
  107716. Down = 1,
  107717. /** Left */
  107718. Left = 2,
  107719. /** Right */
  107720. Right = 3
  107721. }
  107722. /**
  107723. * Defines a DualShock gamepad
  107724. */
  107725. export class DualShockPad extends Gamepad {
  107726. private _leftTrigger;
  107727. private _rightTrigger;
  107728. private _onlefttriggerchanged;
  107729. private _onrighttriggerchanged;
  107730. private _onbuttondown;
  107731. private _onbuttonup;
  107732. private _ondpaddown;
  107733. private _ondpadup;
  107734. /** Observable raised when a button is pressed */
  107735. onButtonDownObservable: Observable<DualShockButton>;
  107736. /** Observable raised when a button is released */
  107737. onButtonUpObservable: Observable<DualShockButton>;
  107738. /** Observable raised when a pad is pressed */
  107739. onPadDownObservable: Observable<DualShockDpad>;
  107740. /** Observable raised when a pad is released */
  107741. onPadUpObservable: Observable<DualShockDpad>;
  107742. private _buttonCross;
  107743. private _buttonCircle;
  107744. private _buttonSquare;
  107745. private _buttonTriangle;
  107746. private _buttonShare;
  107747. private _buttonOptions;
  107748. private _buttonL1;
  107749. private _buttonR1;
  107750. private _buttonLeftStick;
  107751. private _buttonRightStick;
  107752. private _dPadUp;
  107753. private _dPadDown;
  107754. private _dPadLeft;
  107755. private _dPadRight;
  107756. /**
  107757. * Creates a new DualShock gamepad object
  107758. * @param id defines the id of this gamepad
  107759. * @param index defines its index
  107760. * @param gamepad defines the internal HTML gamepad object
  107761. */
  107762. constructor(id: string, index: number, gamepad: any);
  107763. /**
  107764. * Defines the callback to call when left trigger is pressed
  107765. * @param callback defines the callback to use
  107766. */
  107767. onlefttriggerchanged(callback: (value: number) => void): void;
  107768. /**
  107769. * Defines the callback to call when right trigger is pressed
  107770. * @param callback defines the callback to use
  107771. */
  107772. onrighttriggerchanged(callback: (value: number) => void): void;
  107773. /**
  107774. * Gets the left trigger value
  107775. */
  107776. /**
  107777. * Sets the left trigger value
  107778. */
  107779. leftTrigger: number;
  107780. /**
  107781. * Gets the right trigger value
  107782. */
  107783. /**
  107784. * Sets the right trigger value
  107785. */
  107786. rightTrigger: number;
  107787. /**
  107788. * Defines the callback to call when a button is pressed
  107789. * @param callback defines the callback to use
  107790. */
  107791. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  107792. /**
  107793. * Defines the callback to call when a button is released
  107794. * @param callback defines the callback to use
  107795. */
  107796. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  107797. /**
  107798. * Defines the callback to call when a pad is pressed
  107799. * @param callback defines the callback to use
  107800. */
  107801. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  107802. /**
  107803. * Defines the callback to call when a pad is released
  107804. * @param callback defines the callback to use
  107805. */
  107806. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  107807. private _setButtonValue;
  107808. private _setDPadValue;
  107809. /**
  107810. * Gets the value of the `Cross` button
  107811. */
  107812. /**
  107813. * Sets the value of the `Cross` button
  107814. */
  107815. buttonCross: number;
  107816. /**
  107817. * Gets the value of the `Circle` button
  107818. */
  107819. /**
  107820. * Sets the value of the `Circle` button
  107821. */
  107822. buttonCircle: number;
  107823. /**
  107824. * Gets the value of the `Square` button
  107825. */
  107826. /**
  107827. * Sets the value of the `Square` button
  107828. */
  107829. buttonSquare: number;
  107830. /**
  107831. * Gets the value of the `Triangle` button
  107832. */
  107833. /**
  107834. * Sets the value of the `Triangle` button
  107835. */
  107836. buttonTriangle: number;
  107837. /**
  107838. * Gets the value of the `Options` button
  107839. */
  107840. /**
  107841. * Sets the value of the `Options` button
  107842. */
  107843. buttonOptions: number;
  107844. /**
  107845. * Gets the value of the `Share` button
  107846. */
  107847. /**
  107848. * Sets the value of the `Share` button
  107849. */
  107850. buttonShare: number;
  107851. /**
  107852. * Gets the value of the `L1` button
  107853. */
  107854. /**
  107855. * Sets the value of the `L1` button
  107856. */
  107857. buttonL1: number;
  107858. /**
  107859. * Gets the value of the `R1` button
  107860. */
  107861. /**
  107862. * Sets the value of the `R1` button
  107863. */
  107864. buttonR1: number;
  107865. /**
  107866. * Gets the value of the Left joystick
  107867. */
  107868. /**
  107869. * Sets the value of the Left joystick
  107870. */
  107871. buttonLeftStick: number;
  107872. /**
  107873. * Gets the value of the Right joystick
  107874. */
  107875. /**
  107876. * Sets the value of the Right joystick
  107877. */
  107878. buttonRightStick: number;
  107879. /**
  107880. * Gets the value of D-pad up
  107881. */
  107882. /**
  107883. * Sets the value of D-pad up
  107884. */
  107885. dPadUp: number;
  107886. /**
  107887. * Gets the value of D-pad down
  107888. */
  107889. /**
  107890. * Sets the value of D-pad down
  107891. */
  107892. dPadDown: number;
  107893. /**
  107894. * Gets the value of D-pad left
  107895. */
  107896. /**
  107897. * Sets the value of D-pad left
  107898. */
  107899. dPadLeft: number;
  107900. /**
  107901. * Gets the value of D-pad right
  107902. */
  107903. /**
  107904. * Sets the value of D-pad right
  107905. */
  107906. dPadRight: number;
  107907. /**
  107908. * Force the gamepad to synchronize with device values
  107909. */
  107910. update(): void;
  107911. /**
  107912. * Disposes the gamepad
  107913. */
  107914. dispose(): void;
  107915. }
  107916. }
  107917. declare module BABYLON {
  107918. /**
  107919. * Manager for handling gamepads
  107920. */
  107921. export class GamepadManager {
  107922. private _scene?;
  107923. private _babylonGamepads;
  107924. private _oneGamepadConnected;
  107925. /** @hidden */
  107926. _isMonitoring: boolean;
  107927. private _gamepadEventSupported;
  107928. private _gamepadSupport;
  107929. /**
  107930. * observable to be triggered when the gamepad controller has been connected
  107931. */
  107932. onGamepadConnectedObservable: Observable<Gamepad>;
  107933. /**
  107934. * observable to be triggered when the gamepad controller has been disconnected
  107935. */
  107936. onGamepadDisconnectedObservable: Observable<Gamepad>;
  107937. private _onGamepadConnectedEvent;
  107938. private _onGamepadDisconnectedEvent;
  107939. /**
  107940. * Initializes the gamepad manager
  107941. * @param _scene BabylonJS scene
  107942. */
  107943. constructor(_scene?: Scene | undefined);
  107944. /**
  107945. * The gamepads in the game pad manager
  107946. */
  107947. readonly gamepads: Gamepad[];
  107948. /**
  107949. * Get the gamepad controllers based on type
  107950. * @param type The type of gamepad controller
  107951. * @returns Nullable gamepad
  107952. */
  107953. getGamepadByType(type?: number): Nullable<Gamepad>;
  107954. /**
  107955. * Disposes the gamepad manager
  107956. */
  107957. dispose(): void;
  107958. private _addNewGamepad;
  107959. private _startMonitoringGamepads;
  107960. private _stopMonitoringGamepads;
  107961. /** @hidden */
  107962. _checkGamepadsStatus(): void;
  107963. private _updateGamepadObjects;
  107964. }
  107965. }
  107966. declare module BABYLON {
  107967. interface Scene {
  107968. /** @hidden */
  107969. _gamepadManager: Nullable<GamepadManager>;
  107970. /**
  107971. * Gets the gamepad manager associated with the scene
  107972. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  107973. */
  107974. gamepadManager: GamepadManager;
  107975. }
  107976. /**
  107977. * Interface representing a free camera inputs manager
  107978. */
  107979. interface FreeCameraInputsManager {
  107980. /**
  107981. * Adds gamepad input support to the FreeCameraInputsManager.
  107982. * @returns the FreeCameraInputsManager
  107983. */
  107984. addGamepad(): FreeCameraInputsManager;
  107985. }
  107986. /**
  107987. * Interface representing an arc rotate camera inputs manager
  107988. */
  107989. interface ArcRotateCameraInputsManager {
  107990. /**
  107991. * Adds gamepad input support to the ArcRotateCamera InputManager.
  107992. * @returns the camera inputs manager
  107993. */
  107994. addGamepad(): ArcRotateCameraInputsManager;
  107995. }
  107996. /**
  107997. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  107998. */
  107999. export class GamepadSystemSceneComponent implements ISceneComponent {
  108000. /**
  108001. * The component name helpfull to identify the component in the list of scene components.
  108002. */
  108003. readonly name: string;
  108004. /**
  108005. * The scene the component belongs to.
  108006. */
  108007. scene: Scene;
  108008. /**
  108009. * Creates a new instance of the component for the given scene
  108010. * @param scene Defines the scene to register the component in
  108011. */
  108012. constructor(scene: Scene);
  108013. /**
  108014. * Registers the component in a given scene
  108015. */
  108016. register(): void;
  108017. /**
  108018. * Rebuilds the elements related to this component in case of
  108019. * context lost for instance.
  108020. */
  108021. rebuild(): void;
  108022. /**
  108023. * Disposes the component and the associated ressources
  108024. */
  108025. dispose(): void;
  108026. private _beforeCameraUpdate;
  108027. }
  108028. }
  108029. declare module BABYLON {
  108030. /**
  108031. * 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,
  108032. * which still works and will still be found in many Playgrounds.
  108033. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  108034. */
  108035. export class UniversalCamera extends TouchCamera {
  108036. /**
  108037. * Defines the gamepad rotation sensiblity.
  108038. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  108039. */
  108040. gamepadAngularSensibility: number;
  108041. /**
  108042. * Defines the gamepad move sensiblity.
  108043. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  108044. */
  108045. gamepadMoveSensibility: number;
  108046. /**
  108047. * 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,
  108048. * which still works and will still be found in many Playgrounds.
  108049. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  108050. * @param name Define the name of the camera in the scene
  108051. * @param position Define the start position of the camera in the scene
  108052. * @param scene Define the scene the camera belongs to
  108053. */
  108054. constructor(name: string, position: Vector3, scene: Scene);
  108055. /**
  108056. * Gets the current object class name.
  108057. * @return the class name
  108058. */
  108059. getClassName(): string;
  108060. }
  108061. }
  108062. declare module BABYLON {
  108063. /**
  108064. * This represents a FPS type of camera. This is only here for back compat purpose.
  108065. * Please use the UniversalCamera instead as both are identical.
  108066. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  108067. */
  108068. export class GamepadCamera extends UniversalCamera {
  108069. /**
  108070. * Instantiates a new Gamepad Camera
  108071. * This represents a FPS type of camera. This is only here for back compat purpose.
  108072. * Please use the UniversalCamera instead as both are identical.
  108073. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  108074. * @param name Define the name of the camera in the scene
  108075. * @param position Define the start position of the camera in the scene
  108076. * @param scene Define the scene the camera belongs to
  108077. */
  108078. constructor(name: string, position: Vector3, scene: Scene);
  108079. /**
  108080. * Gets the current object class name.
  108081. * @return the class name
  108082. */
  108083. getClassName(): string;
  108084. }
  108085. }
  108086. declare module BABYLON {
  108087. /** @hidden */
  108088. export var passPixelShader: {
  108089. name: string;
  108090. shader: string;
  108091. };
  108092. }
  108093. declare module BABYLON {
  108094. /** @hidden */
  108095. export var passCubePixelShader: {
  108096. name: string;
  108097. shader: string;
  108098. };
  108099. }
  108100. declare module BABYLON {
  108101. /**
  108102. * PassPostProcess which produces an output the same as it's input
  108103. */
  108104. export class PassPostProcess extends PostProcess {
  108105. /**
  108106. * Creates the PassPostProcess
  108107. * @param name The name of the effect.
  108108. * @param options The required width/height ratio to downsize to before computing the render pass.
  108109. * @param camera The camera to apply the render pass to.
  108110. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108111. * @param engine The engine which the post process will be applied. (default: current engine)
  108112. * @param reusable If the post process can be reused on the same frame. (default: false)
  108113. * @param textureType The type of texture to be used when performing the post processing.
  108114. * @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)
  108115. */
  108116. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108117. }
  108118. /**
  108119. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  108120. */
  108121. export class PassCubePostProcess extends PostProcess {
  108122. private _face;
  108123. /**
  108124. * Gets or sets the cube face to display.
  108125. * * 0 is +X
  108126. * * 1 is -X
  108127. * * 2 is +Y
  108128. * * 3 is -Y
  108129. * * 4 is +Z
  108130. * * 5 is -Z
  108131. */
  108132. face: number;
  108133. /**
  108134. * Creates the PassCubePostProcess
  108135. * @param name The name of the effect.
  108136. * @param options The required width/height ratio to downsize to before computing the render pass.
  108137. * @param camera The camera to apply the render pass to.
  108138. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108139. * @param engine The engine which the post process will be applied. (default: current engine)
  108140. * @param reusable If the post process can be reused on the same frame. (default: false)
  108141. * @param textureType The type of texture to be used when performing the post processing.
  108142. * @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)
  108143. */
  108144. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108145. }
  108146. }
  108147. declare module BABYLON {
  108148. /** @hidden */
  108149. export var anaglyphPixelShader: {
  108150. name: string;
  108151. shader: string;
  108152. };
  108153. }
  108154. declare module BABYLON {
  108155. /**
  108156. * Postprocess used to generate anaglyphic rendering
  108157. */
  108158. export class AnaglyphPostProcess extends PostProcess {
  108159. private _passedProcess;
  108160. /**
  108161. * Creates a new AnaglyphPostProcess
  108162. * @param name defines postprocess name
  108163. * @param options defines creation options or target ratio scale
  108164. * @param rigCameras defines cameras using this postprocess
  108165. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  108166. * @param engine defines hosting engine
  108167. * @param reusable defines if the postprocess will be reused multiple times per frame
  108168. */
  108169. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  108170. }
  108171. }
  108172. declare module BABYLON {
  108173. /**
  108174. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  108175. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108176. */
  108177. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  108178. /**
  108179. * Creates a new AnaglyphArcRotateCamera
  108180. * @param name defines camera name
  108181. * @param alpha defines alpha angle (in radians)
  108182. * @param beta defines beta angle (in radians)
  108183. * @param radius defines radius
  108184. * @param target defines camera target
  108185. * @param interaxialDistance defines distance between each color axis
  108186. * @param scene defines the hosting scene
  108187. */
  108188. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  108189. /**
  108190. * Gets camera class name
  108191. * @returns AnaglyphArcRotateCamera
  108192. */
  108193. getClassName(): string;
  108194. }
  108195. }
  108196. declare module BABYLON {
  108197. /**
  108198. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  108199. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108200. */
  108201. export class AnaglyphFreeCamera extends FreeCamera {
  108202. /**
  108203. * Creates a new AnaglyphFreeCamera
  108204. * @param name defines camera name
  108205. * @param position defines initial position
  108206. * @param interaxialDistance defines distance between each color axis
  108207. * @param scene defines the hosting scene
  108208. */
  108209. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108210. /**
  108211. * Gets camera class name
  108212. * @returns AnaglyphFreeCamera
  108213. */
  108214. getClassName(): string;
  108215. }
  108216. }
  108217. declare module BABYLON {
  108218. /**
  108219. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  108220. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108221. */
  108222. export class AnaglyphGamepadCamera extends GamepadCamera {
  108223. /**
  108224. * Creates a new AnaglyphGamepadCamera
  108225. * @param name defines camera name
  108226. * @param position defines initial position
  108227. * @param interaxialDistance defines distance between each color axis
  108228. * @param scene defines the hosting scene
  108229. */
  108230. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108231. /**
  108232. * Gets camera class name
  108233. * @returns AnaglyphGamepadCamera
  108234. */
  108235. getClassName(): string;
  108236. }
  108237. }
  108238. declare module BABYLON {
  108239. /**
  108240. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  108241. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108242. */
  108243. export class AnaglyphUniversalCamera extends UniversalCamera {
  108244. /**
  108245. * Creates a new AnaglyphUniversalCamera
  108246. * @param name defines camera name
  108247. * @param position defines initial position
  108248. * @param interaxialDistance defines distance between each color axis
  108249. * @param scene defines the hosting scene
  108250. */
  108251. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108252. /**
  108253. * Gets camera class name
  108254. * @returns AnaglyphUniversalCamera
  108255. */
  108256. getClassName(): string;
  108257. }
  108258. }
  108259. declare module BABYLON {
  108260. /** @hidden */
  108261. export var stereoscopicInterlacePixelShader: {
  108262. name: string;
  108263. shader: string;
  108264. };
  108265. }
  108266. declare module BABYLON {
  108267. /**
  108268. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  108269. */
  108270. export class StereoscopicInterlacePostProcess extends PostProcess {
  108271. private _stepSize;
  108272. private _passedProcess;
  108273. /**
  108274. * Initializes a StereoscopicInterlacePostProcess
  108275. * @param name The name of the effect.
  108276. * @param rigCameras The rig cameras to be appled to the post process
  108277. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  108278. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108279. * @param engine The engine which the post process will be applied. (default: current engine)
  108280. * @param reusable If the post process can be reused on the same frame. (default: false)
  108281. */
  108282. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108283. }
  108284. }
  108285. declare module BABYLON {
  108286. /**
  108287. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  108288. * @see http://doc.babylonjs.com/features/cameras
  108289. */
  108290. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  108291. /**
  108292. * Creates a new StereoscopicArcRotateCamera
  108293. * @param name defines camera name
  108294. * @param alpha defines alpha angle (in radians)
  108295. * @param beta defines beta angle (in radians)
  108296. * @param radius defines radius
  108297. * @param target defines camera target
  108298. * @param interaxialDistance defines distance between each color axis
  108299. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108300. * @param scene defines the hosting scene
  108301. */
  108302. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108303. /**
  108304. * Gets camera class name
  108305. * @returns StereoscopicArcRotateCamera
  108306. */
  108307. getClassName(): string;
  108308. }
  108309. }
  108310. declare module BABYLON {
  108311. /**
  108312. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  108313. * @see http://doc.babylonjs.com/features/cameras
  108314. */
  108315. export class StereoscopicFreeCamera extends FreeCamera {
  108316. /**
  108317. * Creates a new StereoscopicFreeCamera
  108318. * @param name defines camera name
  108319. * @param position defines initial position
  108320. * @param interaxialDistance defines distance between each color axis
  108321. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108322. * @param scene defines the hosting scene
  108323. */
  108324. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108325. /**
  108326. * Gets camera class name
  108327. * @returns StereoscopicFreeCamera
  108328. */
  108329. getClassName(): string;
  108330. }
  108331. }
  108332. declare module BABYLON {
  108333. /**
  108334. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  108335. * @see http://doc.babylonjs.com/features/cameras
  108336. */
  108337. export class StereoscopicGamepadCamera extends GamepadCamera {
  108338. /**
  108339. * Creates a new StereoscopicGamepadCamera
  108340. * @param name defines camera name
  108341. * @param position defines initial position
  108342. * @param interaxialDistance defines distance between each color axis
  108343. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108344. * @param scene defines the hosting scene
  108345. */
  108346. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108347. /**
  108348. * Gets camera class name
  108349. * @returns StereoscopicGamepadCamera
  108350. */
  108351. getClassName(): string;
  108352. }
  108353. }
  108354. declare module BABYLON {
  108355. /**
  108356. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  108357. * @see http://doc.babylonjs.com/features/cameras
  108358. */
  108359. export class StereoscopicUniversalCamera extends UniversalCamera {
  108360. /**
  108361. * Creates a new StereoscopicUniversalCamera
  108362. * @param name defines camera name
  108363. * @param position defines initial position
  108364. * @param interaxialDistance defines distance between each color axis
  108365. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108366. * @param scene defines the hosting scene
  108367. */
  108368. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108369. /**
  108370. * Gets camera class name
  108371. * @returns StereoscopicUniversalCamera
  108372. */
  108373. getClassName(): string;
  108374. }
  108375. }
  108376. declare module BABYLON {
  108377. /**
  108378. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  108379. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  108380. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  108381. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  108382. */
  108383. export class VirtualJoysticksCamera extends FreeCamera {
  108384. /**
  108385. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  108386. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  108387. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  108388. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  108389. * @param name Define the name of the camera in the scene
  108390. * @param position Define the start position of the camera in the scene
  108391. * @param scene Define the scene the camera belongs to
  108392. */
  108393. constructor(name: string, position: Vector3, scene: Scene);
  108394. /**
  108395. * Gets the current object class name.
  108396. * @return the class name
  108397. */
  108398. getClassName(): string;
  108399. }
  108400. }
  108401. declare module BABYLON {
  108402. /**
  108403. * This represents all the required metrics to create a VR camera.
  108404. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  108405. */
  108406. export class VRCameraMetrics {
  108407. /**
  108408. * Define the horizontal resolution off the screen.
  108409. */
  108410. hResolution: number;
  108411. /**
  108412. * Define the vertical resolution off the screen.
  108413. */
  108414. vResolution: number;
  108415. /**
  108416. * Define the horizontal screen size.
  108417. */
  108418. hScreenSize: number;
  108419. /**
  108420. * Define the vertical screen size.
  108421. */
  108422. vScreenSize: number;
  108423. /**
  108424. * Define the vertical screen center position.
  108425. */
  108426. vScreenCenter: number;
  108427. /**
  108428. * Define the distance of the eyes to the screen.
  108429. */
  108430. eyeToScreenDistance: number;
  108431. /**
  108432. * Define the distance between both lenses
  108433. */
  108434. lensSeparationDistance: number;
  108435. /**
  108436. * Define the distance between both viewer's eyes.
  108437. */
  108438. interpupillaryDistance: number;
  108439. /**
  108440. * Define the distortion factor of the VR postprocess.
  108441. * Please, touch with care.
  108442. */
  108443. distortionK: number[];
  108444. /**
  108445. * Define the chromatic aberration correction factors for the VR post process.
  108446. */
  108447. chromaAbCorrection: number[];
  108448. /**
  108449. * Define the scale factor of the post process.
  108450. * The smaller the better but the slower.
  108451. */
  108452. postProcessScaleFactor: number;
  108453. /**
  108454. * Define an offset for the lens center.
  108455. */
  108456. lensCenterOffset: number;
  108457. /**
  108458. * Define if the current vr camera should compensate the distortion of the lense or not.
  108459. */
  108460. compensateDistortion: boolean;
  108461. /**
  108462. * Defines if multiview should be enabled when rendering (Default: false)
  108463. */
  108464. multiviewEnabled: boolean;
  108465. /**
  108466. * Gets the rendering aspect ratio based on the provided resolutions.
  108467. */
  108468. readonly aspectRatio: number;
  108469. /**
  108470. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  108471. */
  108472. readonly aspectRatioFov: number;
  108473. /**
  108474. * @hidden
  108475. */
  108476. readonly leftHMatrix: Matrix;
  108477. /**
  108478. * @hidden
  108479. */
  108480. readonly rightHMatrix: Matrix;
  108481. /**
  108482. * @hidden
  108483. */
  108484. readonly leftPreViewMatrix: Matrix;
  108485. /**
  108486. * @hidden
  108487. */
  108488. readonly rightPreViewMatrix: Matrix;
  108489. /**
  108490. * Get the default VRMetrics based on the most generic setup.
  108491. * @returns the default vr metrics
  108492. */
  108493. static GetDefault(): VRCameraMetrics;
  108494. }
  108495. }
  108496. declare module BABYLON {
  108497. /** @hidden */
  108498. export var vrDistortionCorrectionPixelShader: {
  108499. name: string;
  108500. shader: string;
  108501. };
  108502. }
  108503. declare module BABYLON {
  108504. /**
  108505. * VRDistortionCorrectionPostProcess used for mobile VR
  108506. */
  108507. export class VRDistortionCorrectionPostProcess extends PostProcess {
  108508. private _isRightEye;
  108509. private _distortionFactors;
  108510. private _postProcessScaleFactor;
  108511. private _lensCenterOffset;
  108512. private _scaleIn;
  108513. private _scaleFactor;
  108514. private _lensCenter;
  108515. /**
  108516. * Initializes the VRDistortionCorrectionPostProcess
  108517. * @param name The name of the effect.
  108518. * @param camera The camera to apply the render pass to.
  108519. * @param isRightEye If this is for the right eye distortion
  108520. * @param vrMetrics All the required metrics for the VR camera
  108521. */
  108522. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  108523. }
  108524. }
  108525. declare module BABYLON {
  108526. /**
  108527. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  108528. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108529. */
  108530. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  108531. /**
  108532. * Creates a new VRDeviceOrientationArcRotateCamera
  108533. * @param name defines camera name
  108534. * @param alpha defines the camera rotation along the logitudinal axis
  108535. * @param beta defines the camera rotation along the latitudinal axis
  108536. * @param radius defines the camera distance from its target
  108537. * @param target defines the camera target
  108538. * @param scene defines the scene the camera belongs to
  108539. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108540. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108541. */
  108542. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108543. /**
  108544. * Gets camera class name
  108545. * @returns VRDeviceOrientationArcRotateCamera
  108546. */
  108547. getClassName(): string;
  108548. }
  108549. }
  108550. declare module BABYLON {
  108551. /**
  108552. * Camera used to simulate VR rendering (based on FreeCamera)
  108553. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108554. */
  108555. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  108556. /**
  108557. * Creates a new VRDeviceOrientationFreeCamera
  108558. * @param name defines camera name
  108559. * @param position defines the start position of the camera
  108560. * @param scene defines the scene the camera belongs to
  108561. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108562. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108563. */
  108564. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108565. /**
  108566. * Gets camera class name
  108567. * @returns VRDeviceOrientationFreeCamera
  108568. */
  108569. getClassName(): string;
  108570. }
  108571. }
  108572. declare module BABYLON {
  108573. /**
  108574. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  108575. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108576. */
  108577. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  108578. /**
  108579. * Creates a new VRDeviceOrientationGamepadCamera
  108580. * @param name defines camera name
  108581. * @param position defines the start position of the camera
  108582. * @param scene defines the scene the camera belongs to
  108583. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108584. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108585. */
  108586. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108587. /**
  108588. * Gets camera class name
  108589. * @returns VRDeviceOrientationGamepadCamera
  108590. */
  108591. getClassName(): string;
  108592. }
  108593. }
  108594. declare module BABYLON {
  108595. /**
  108596. * Base class of materials working in push mode in babylon JS
  108597. * @hidden
  108598. */
  108599. export class PushMaterial extends Material {
  108600. protected _activeEffect: Effect;
  108601. protected _normalMatrix: Matrix;
  108602. /**
  108603. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  108604. * This means that the material can keep using a previous shader while a new one is being compiled.
  108605. * This is mostly used when shader parallel compilation is supported (true by default)
  108606. */
  108607. allowShaderHotSwapping: boolean;
  108608. constructor(name: string, scene: Scene);
  108609. getEffect(): Effect;
  108610. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  108611. /**
  108612. * Binds the given world matrix to the active effect
  108613. *
  108614. * @param world the matrix to bind
  108615. */
  108616. bindOnlyWorldMatrix(world: Matrix): void;
  108617. /**
  108618. * Binds the given normal matrix to the active effect
  108619. *
  108620. * @param normalMatrix the matrix to bind
  108621. */
  108622. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  108623. bind(world: Matrix, mesh?: Mesh): void;
  108624. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  108625. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  108626. }
  108627. }
  108628. declare module BABYLON {
  108629. /**
  108630. * This groups all the flags used to control the materials channel.
  108631. */
  108632. export class MaterialFlags {
  108633. private static _DiffuseTextureEnabled;
  108634. /**
  108635. * Are diffuse textures enabled in the application.
  108636. */
  108637. static DiffuseTextureEnabled: boolean;
  108638. private static _AmbientTextureEnabled;
  108639. /**
  108640. * Are ambient textures enabled in the application.
  108641. */
  108642. static AmbientTextureEnabled: boolean;
  108643. private static _OpacityTextureEnabled;
  108644. /**
  108645. * Are opacity textures enabled in the application.
  108646. */
  108647. static OpacityTextureEnabled: boolean;
  108648. private static _ReflectionTextureEnabled;
  108649. /**
  108650. * Are reflection textures enabled in the application.
  108651. */
  108652. static ReflectionTextureEnabled: boolean;
  108653. private static _EmissiveTextureEnabled;
  108654. /**
  108655. * Are emissive textures enabled in the application.
  108656. */
  108657. static EmissiveTextureEnabled: boolean;
  108658. private static _SpecularTextureEnabled;
  108659. /**
  108660. * Are specular textures enabled in the application.
  108661. */
  108662. static SpecularTextureEnabled: boolean;
  108663. private static _BumpTextureEnabled;
  108664. /**
  108665. * Are bump textures enabled in the application.
  108666. */
  108667. static BumpTextureEnabled: boolean;
  108668. private static _LightmapTextureEnabled;
  108669. /**
  108670. * Are lightmap textures enabled in the application.
  108671. */
  108672. static LightmapTextureEnabled: boolean;
  108673. private static _RefractionTextureEnabled;
  108674. /**
  108675. * Are refraction textures enabled in the application.
  108676. */
  108677. static RefractionTextureEnabled: boolean;
  108678. private static _ColorGradingTextureEnabled;
  108679. /**
  108680. * Are color grading textures enabled in the application.
  108681. */
  108682. static ColorGradingTextureEnabled: boolean;
  108683. private static _FresnelEnabled;
  108684. /**
  108685. * Are fresnels enabled in the application.
  108686. */
  108687. static FresnelEnabled: boolean;
  108688. private static _ClearCoatTextureEnabled;
  108689. /**
  108690. * Are clear coat textures enabled in the application.
  108691. */
  108692. static ClearCoatTextureEnabled: boolean;
  108693. private static _ClearCoatBumpTextureEnabled;
  108694. /**
  108695. * Are clear coat bump textures enabled in the application.
  108696. */
  108697. static ClearCoatBumpTextureEnabled: boolean;
  108698. private static _ClearCoatTintTextureEnabled;
  108699. /**
  108700. * Are clear coat tint textures enabled in the application.
  108701. */
  108702. static ClearCoatTintTextureEnabled: boolean;
  108703. private static _SheenTextureEnabled;
  108704. /**
  108705. * Are sheen textures enabled in the application.
  108706. */
  108707. static SheenTextureEnabled: boolean;
  108708. private static _AnisotropicTextureEnabled;
  108709. /**
  108710. * Are anisotropic textures enabled in the application.
  108711. */
  108712. static AnisotropicTextureEnabled: boolean;
  108713. private static _ThicknessTextureEnabled;
  108714. /**
  108715. * Are thickness textures enabled in the application.
  108716. */
  108717. static ThicknessTextureEnabled: boolean;
  108718. }
  108719. }
  108720. declare module BABYLON {
  108721. /** @hidden */
  108722. export var defaultFragmentDeclaration: {
  108723. name: string;
  108724. shader: string;
  108725. };
  108726. }
  108727. declare module BABYLON {
  108728. /** @hidden */
  108729. export var defaultUboDeclaration: {
  108730. name: string;
  108731. shader: string;
  108732. };
  108733. }
  108734. declare module BABYLON {
  108735. /** @hidden */
  108736. export var lightFragmentDeclaration: {
  108737. name: string;
  108738. shader: string;
  108739. };
  108740. }
  108741. declare module BABYLON {
  108742. /** @hidden */
  108743. export var lightUboDeclaration: {
  108744. name: string;
  108745. shader: string;
  108746. };
  108747. }
  108748. declare module BABYLON {
  108749. /** @hidden */
  108750. export var lightsFragmentFunctions: {
  108751. name: string;
  108752. shader: string;
  108753. };
  108754. }
  108755. declare module BABYLON {
  108756. /** @hidden */
  108757. export var shadowsFragmentFunctions: {
  108758. name: string;
  108759. shader: string;
  108760. };
  108761. }
  108762. declare module BABYLON {
  108763. /** @hidden */
  108764. export var fresnelFunction: {
  108765. name: string;
  108766. shader: string;
  108767. };
  108768. }
  108769. declare module BABYLON {
  108770. /** @hidden */
  108771. export var reflectionFunction: {
  108772. name: string;
  108773. shader: string;
  108774. };
  108775. }
  108776. declare module BABYLON {
  108777. /** @hidden */
  108778. export var bumpFragmentFunctions: {
  108779. name: string;
  108780. shader: string;
  108781. };
  108782. }
  108783. declare module BABYLON {
  108784. /** @hidden */
  108785. export var logDepthDeclaration: {
  108786. name: string;
  108787. shader: string;
  108788. };
  108789. }
  108790. declare module BABYLON {
  108791. /** @hidden */
  108792. export var bumpFragment: {
  108793. name: string;
  108794. shader: string;
  108795. };
  108796. }
  108797. declare module BABYLON {
  108798. /** @hidden */
  108799. export var depthPrePass: {
  108800. name: string;
  108801. shader: string;
  108802. };
  108803. }
  108804. declare module BABYLON {
  108805. /** @hidden */
  108806. export var lightFragment: {
  108807. name: string;
  108808. shader: string;
  108809. };
  108810. }
  108811. declare module BABYLON {
  108812. /** @hidden */
  108813. export var logDepthFragment: {
  108814. name: string;
  108815. shader: string;
  108816. };
  108817. }
  108818. declare module BABYLON {
  108819. /** @hidden */
  108820. export var defaultPixelShader: {
  108821. name: string;
  108822. shader: string;
  108823. };
  108824. }
  108825. declare module BABYLON {
  108826. /** @hidden */
  108827. export var defaultVertexDeclaration: {
  108828. name: string;
  108829. shader: string;
  108830. };
  108831. }
  108832. declare module BABYLON {
  108833. /** @hidden */
  108834. export var bumpVertexDeclaration: {
  108835. name: string;
  108836. shader: string;
  108837. };
  108838. }
  108839. declare module BABYLON {
  108840. /** @hidden */
  108841. export var bumpVertex: {
  108842. name: string;
  108843. shader: string;
  108844. };
  108845. }
  108846. declare module BABYLON {
  108847. /** @hidden */
  108848. export var fogVertex: {
  108849. name: string;
  108850. shader: string;
  108851. };
  108852. }
  108853. declare module BABYLON {
  108854. /** @hidden */
  108855. export var shadowsVertex: {
  108856. name: string;
  108857. shader: string;
  108858. };
  108859. }
  108860. declare module BABYLON {
  108861. /** @hidden */
  108862. export var pointCloudVertex: {
  108863. name: string;
  108864. shader: string;
  108865. };
  108866. }
  108867. declare module BABYLON {
  108868. /** @hidden */
  108869. export var logDepthVertex: {
  108870. name: string;
  108871. shader: string;
  108872. };
  108873. }
  108874. declare module BABYLON {
  108875. /** @hidden */
  108876. export var defaultVertexShader: {
  108877. name: string;
  108878. shader: string;
  108879. };
  108880. }
  108881. declare module BABYLON {
  108882. /** @hidden */
  108883. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  108884. MAINUV1: boolean;
  108885. MAINUV2: boolean;
  108886. DIFFUSE: boolean;
  108887. DIFFUSEDIRECTUV: number;
  108888. AMBIENT: boolean;
  108889. AMBIENTDIRECTUV: number;
  108890. OPACITY: boolean;
  108891. OPACITYDIRECTUV: number;
  108892. OPACITYRGB: boolean;
  108893. REFLECTION: boolean;
  108894. EMISSIVE: boolean;
  108895. EMISSIVEDIRECTUV: number;
  108896. SPECULAR: boolean;
  108897. SPECULARDIRECTUV: number;
  108898. BUMP: boolean;
  108899. BUMPDIRECTUV: number;
  108900. PARALLAX: boolean;
  108901. PARALLAXOCCLUSION: boolean;
  108902. SPECULAROVERALPHA: boolean;
  108903. CLIPPLANE: boolean;
  108904. CLIPPLANE2: boolean;
  108905. CLIPPLANE3: boolean;
  108906. CLIPPLANE4: boolean;
  108907. ALPHATEST: boolean;
  108908. DEPTHPREPASS: boolean;
  108909. ALPHAFROMDIFFUSE: boolean;
  108910. POINTSIZE: boolean;
  108911. FOG: boolean;
  108912. SPECULARTERM: boolean;
  108913. DIFFUSEFRESNEL: boolean;
  108914. OPACITYFRESNEL: boolean;
  108915. REFLECTIONFRESNEL: boolean;
  108916. REFRACTIONFRESNEL: boolean;
  108917. EMISSIVEFRESNEL: boolean;
  108918. FRESNEL: boolean;
  108919. NORMAL: boolean;
  108920. UV1: boolean;
  108921. UV2: boolean;
  108922. VERTEXCOLOR: boolean;
  108923. VERTEXALPHA: boolean;
  108924. NUM_BONE_INFLUENCERS: number;
  108925. BonesPerMesh: number;
  108926. BONETEXTURE: boolean;
  108927. INSTANCES: boolean;
  108928. GLOSSINESS: boolean;
  108929. ROUGHNESS: boolean;
  108930. EMISSIVEASILLUMINATION: boolean;
  108931. LINKEMISSIVEWITHDIFFUSE: boolean;
  108932. REFLECTIONFRESNELFROMSPECULAR: boolean;
  108933. LIGHTMAP: boolean;
  108934. LIGHTMAPDIRECTUV: number;
  108935. OBJECTSPACE_NORMALMAP: boolean;
  108936. USELIGHTMAPASSHADOWMAP: boolean;
  108937. REFLECTIONMAP_3D: boolean;
  108938. REFLECTIONMAP_SPHERICAL: boolean;
  108939. REFLECTIONMAP_PLANAR: boolean;
  108940. REFLECTIONMAP_CUBIC: boolean;
  108941. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108942. REFLECTIONMAP_PROJECTION: boolean;
  108943. REFLECTIONMAP_SKYBOX: boolean;
  108944. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108945. REFLECTIONMAP_EXPLICIT: boolean;
  108946. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108947. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108948. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108949. INVERTCUBICMAP: boolean;
  108950. LOGARITHMICDEPTH: boolean;
  108951. REFRACTION: boolean;
  108952. REFRACTIONMAP_3D: boolean;
  108953. REFLECTIONOVERALPHA: boolean;
  108954. TWOSIDEDLIGHTING: boolean;
  108955. SHADOWFLOAT: boolean;
  108956. MORPHTARGETS: boolean;
  108957. MORPHTARGETS_NORMAL: boolean;
  108958. MORPHTARGETS_TANGENT: boolean;
  108959. MORPHTARGETS_UV: boolean;
  108960. NUM_MORPH_INFLUENCERS: number;
  108961. NONUNIFORMSCALING: boolean;
  108962. PREMULTIPLYALPHA: boolean;
  108963. IMAGEPROCESSING: boolean;
  108964. VIGNETTE: boolean;
  108965. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108966. VIGNETTEBLENDMODEOPAQUE: boolean;
  108967. TONEMAPPING: boolean;
  108968. TONEMAPPING_ACES: boolean;
  108969. CONTRAST: boolean;
  108970. COLORCURVES: boolean;
  108971. COLORGRADING: boolean;
  108972. COLORGRADING3D: boolean;
  108973. SAMPLER3DGREENDEPTH: boolean;
  108974. SAMPLER3DBGRMAP: boolean;
  108975. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108976. MULTIVIEW: boolean;
  108977. /**
  108978. * If the reflection texture on this material is in linear color space
  108979. * @hidden
  108980. */
  108981. IS_REFLECTION_LINEAR: boolean;
  108982. /**
  108983. * If the refraction texture on this material is in linear color space
  108984. * @hidden
  108985. */
  108986. IS_REFRACTION_LINEAR: boolean;
  108987. EXPOSURE: boolean;
  108988. constructor();
  108989. setReflectionMode(modeToEnable: string): void;
  108990. }
  108991. /**
  108992. * This is the default material used in Babylon. It is the best trade off between quality
  108993. * and performances.
  108994. * @see http://doc.babylonjs.com/babylon101/materials
  108995. */
  108996. export class StandardMaterial extends PushMaterial {
  108997. private _diffuseTexture;
  108998. /**
  108999. * The basic texture of the material as viewed under a light.
  109000. */
  109001. diffuseTexture: Nullable<BaseTexture>;
  109002. private _ambientTexture;
  109003. /**
  109004. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  109005. */
  109006. ambientTexture: Nullable<BaseTexture>;
  109007. private _opacityTexture;
  109008. /**
  109009. * Define the transparency of the material from a texture.
  109010. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  109011. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  109012. */
  109013. opacityTexture: Nullable<BaseTexture>;
  109014. private _reflectionTexture;
  109015. /**
  109016. * Define the texture used to display the reflection.
  109017. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109018. */
  109019. reflectionTexture: Nullable<BaseTexture>;
  109020. private _emissiveTexture;
  109021. /**
  109022. * Define texture of the material as if self lit.
  109023. * This will be mixed in the final result even in the absence of light.
  109024. */
  109025. emissiveTexture: Nullable<BaseTexture>;
  109026. private _specularTexture;
  109027. /**
  109028. * Define how the color and intensity of the highlight given by the light in the material.
  109029. */
  109030. specularTexture: Nullable<BaseTexture>;
  109031. private _bumpTexture;
  109032. /**
  109033. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  109034. * 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.
  109035. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  109036. */
  109037. bumpTexture: Nullable<BaseTexture>;
  109038. private _lightmapTexture;
  109039. /**
  109040. * Complex lighting can be computationally expensive to compute at runtime.
  109041. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  109042. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  109043. */
  109044. lightmapTexture: Nullable<BaseTexture>;
  109045. private _refractionTexture;
  109046. /**
  109047. * Define the texture used to display the refraction.
  109048. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109049. */
  109050. refractionTexture: Nullable<BaseTexture>;
  109051. /**
  109052. * The color of the material lit by the environmental background lighting.
  109053. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  109054. */
  109055. ambientColor: Color3;
  109056. /**
  109057. * The basic color of the material as viewed under a light.
  109058. */
  109059. diffuseColor: Color3;
  109060. /**
  109061. * Define how the color and intensity of the highlight given by the light in the material.
  109062. */
  109063. specularColor: Color3;
  109064. /**
  109065. * Define the color of the material as if self lit.
  109066. * This will be mixed in the final result even in the absence of light.
  109067. */
  109068. emissiveColor: Color3;
  109069. /**
  109070. * Defines how sharp are the highlights in the material.
  109071. * The bigger the value the sharper giving a more glossy feeling to the result.
  109072. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  109073. */
  109074. specularPower: number;
  109075. private _useAlphaFromDiffuseTexture;
  109076. /**
  109077. * Does the transparency come from the diffuse texture alpha channel.
  109078. */
  109079. useAlphaFromDiffuseTexture: boolean;
  109080. private _useEmissiveAsIllumination;
  109081. /**
  109082. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  109083. */
  109084. useEmissiveAsIllumination: boolean;
  109085. private _linkEmissiveWithDiffuse;
  109086. /**
  109087. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  109088. * the emissive level when the final color is close to one.
  109089. */
  109090. linkEmissiveWithDiffuse: boolean;
  109091. private _useSpecularOverAlpha;
  109092. /**
  109093. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109094. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109095. */
  109096. useSpecularOverAlpha: boolean;
  109097. private _useReflectionOverAlpha;
  109098. /**
  109099. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109100. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109101. */
  109102. useReflectionOverAlpha: boolean;
  109103. private _disableLighting;
  109104. /**
  109105. * Does lights from the scene impacts this material.
  109106. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  109107. */
  109108. disableLighting: boolean;
  109109. private _useObjectSpaceNormalMap;
  109110. /**
  109111. * Allows using an object space normal map (instead of tangent space).
  109112. */
  109113. useObjectSpaceNormalMap: boolean;
  109114. private _useParallax;
  109115. /**
  109116. * Is parallax enabled or not.
  109117. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  109118. */
  109119. useParallax: boolean;
  109120. private _useParallaxOcclusion;
  109121. /**
  109122. * Is parallax occlusion enabled or not.
  109123. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  109124. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  109125. */
  109126. useParallaxOcclusion: boolean;
  109127. /**
  109128. * 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.
  109129. */
  109130. parallaxScaleBias: number;
  109131. private _roughness;
  109132. /**
  109133. * Helps to define how blurry the reflections should appears in the material.
  109134. */
  109135. roughness: number;
  109136. /**
  109137. * In case of refraction, define the value of the index of refraction.
  109138. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109139. */
  109140. indexOfRefraction: number;
  109141. /**
  109142. * Invert the refraction texture alongside the y axis.
  109143. * It can be useful with procedural textures or probe for instance.
  109144. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109145. */
  109146. invertRefractionY: boolean;
  109147. /**
  109148. * Defines the alpha limits in alpha test mode.
  109149. */
  109150. alphaCutOff: number;
  109151. private _useLightmapAsShadowmap;
  109152. /**
  109153. * In case of light mapping, define whether the map contains light or shadow informations.
  109154. */
  109155. useLightmapAsShadowmap: boolean;
  109156. private _diffuseFresnelParameters;
  109157. /**
  109158. * Define the diffuse fresnel parameters of the material.
  109159. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109160. */
  109161. diffuseFresnelParameters: FresnelParameters;
  109162. private _opacityFresnelParameters;
  109163. /**
  109164. * Define the opacity fresnel parameters of the material.
  109165. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109166. */
  109167. opacityFresnelParameters: FresnelParameters;
  109168. private _reflectionFresnelParameters;
  109169. /**
  109170. * Define the reflection fresnel parameters of the material.
  109171. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109172. */
  109173. reflectionFresnelParameters: FresnelParameters;
  109174. private _refractionFresnelParameters;
  109175. /**
  109176. * Define the refraction fresnel parameters of the material.
  109177. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109178. */
  109179. refractionFresnelParameters: FresnelParameters;
  109180. private _emissiveFresnelParameters;
  109181. /**
  109182. * Define the emissive fresnel parameters of the material.
  109183. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109184. */
  109185. emissiveFresnelParameters: FresnelParameters;
  109186. private _useReflectionFresnelFromSpecular;
  109187. /**
  109188. * If true automatically deducts the fresnels values from the material specularity.
  109189. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109190. */
  109191. useReflectionFresnelFromSpecular: boolean;
  109192. private _useGlossinessFromSpecularMapAlpha;
  109193. /**
  109194. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  109195. */
  109196. useGlossinessFromSpecularMapAlpha: boolean;
  109197. private _maxSimultaneousLights;
  109198. /**
  109199. * Defines the maximum number of lights that can be used in the material
  109200. */
  109201. maxSimultaneousLights: number;
  109202. private _invertNormalMapX;
  109203. /**
  109204. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109205. */
  109206. invertNormalMapX: boolean;
  109207. private _invertNormalMapY;
  109208. /**
  109209. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109210. */
  109211. invertNormalMapY: boolean;
  109212. private _twoSidedLighting;
  109213. /**
  109214. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109215. */
  109216. twoSidedLighting: boolean;
  109217. /**
  109218. * Default configuration related to image processing available in the standard Material.
  109219. */
  109220. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109221. /**
  109222. * Gets the image processing configuration used either in this material.
  109223. */
  109224. /**
  109225. * Sets the Default image processing configuration used either in the this material.
  109226. *
  109227. * If sets to null, the scene one is in use.
  109228. */
  109229. imageProcessingConfiguration: ImageProcessingConfiguration;
  109230. /**
  109231. * Keep track of the image processing observer to allow dispose and replace.
  109232. */
  109233. private _imageProcessingObserver;
  109234. /**
  109235. * Attaches a new image processing configuration to the Standard Material.
  109236. * @param configuration
  109237. */
  109238. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109239. /**
  109240. * Gets wether the color curves effect is enabled.
  109241. */
  109242. /**
  109243. * Sets wether the color curves effect is enabled.
  109244. */
  109245. cameraColorCurvesEnabled: boolean;
  109246. /**
  109247. * Gets wether the color grading effect is enabled.
  109248. */
  109249. /**
  109250. * Gets wether the color grading effect is enabled.
  109251. */
  109252. cameraColorGradingEnabled: boolean;
  109253. /**
  109254. * Gets wether tonemapping is enabled or not.
  109255. */
  109256. /**
  109257. * Sets wether tonemapping is enabled or not
  109258. */
  109259. cameraToneMappingEnabled: boolean;
  109260. /**
  109261. * The camera exposure used on this material.
  109262. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109263. * This corresponds to a photographic exposure.
  109264. */
  109265. /**
  109266. * The camera exposure used on this material.
  109267. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109268. * This corresponds to a photographic exposure.
  109269. */
  109270. cameraExposure: number;
  109271. /**
  109272. * Gets The camera contrast used on this material.
  109273. */
  109274. /**
  109275. * Sets The camera contrast used on this material.
  109276. */
  109277. cameraContrast: number;
  109278. /**
  109279. * Gets the Color Grading 2D Lookup Texture.
  109280. */
  109281. /**
  109282. * Sets the Color Grading 2D Lookup Texture.
  109283. */
  109284. cameraColorGradingTexture: Nullable<BaseTexture>;
  109285. /**
  109286. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109287. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109288. * 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;
  109289. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109290. */
  109291. /**
  109292. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109293. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109294. * 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;
  109295. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109296. */
  109297. cameraColorCurves: Nullable<ColorCurves>;
  109298. /**
  109299. * Custom callback helping to override the default shader used in the material.
  109300. */
  109301. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  109302. protected _renderTargets: SmartArray<RenderTargetTexture>;
  109303. protected _worldViewProjectionMatrix: Matrix;
  109304. protected _globalAmbientColor: Color3;
  109305. protected _useLogarithmicDepth: boolean;
  109306. protected _rebuildInParallel: boolean;
  109307. /**
  109308. * Instantiates a new standard material.
  109309. * This is the default material used in Babylon. It is the best trade off between quality
  109310. * and performances.
  109311. * @see http://doc.babylonjs.com/babylon101/materials
  109312. * @param name Define the name of the material in the scene
  109313. * @param scene Define the scene the material belong to
  109314. */
  109315. constructor(name: string, scene: Scene);
  109316. /**
  109317. * Gets a boolean indicating that current material needs to register RTT
  109318. */
  109319. readonly hasRenderTargetTextures: boolean;
  109320. /**
  109321. * Gets the current class name of the material e.g. "StandardMaterial"
  109322. * Mainly use in serialization.
  109323. * @returns the class name
  109324. */
  109325. getClassName(): string;
  109326. /**
  109327. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  109328. * You can try switching to logarithmic depth.
  109329. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  109330. */
  109331. useLogarithmicDepth: boolean;
  109332. /**
  109333. * Specifies if the material will require alpha blending
  109334. * @returns a boolean specifying if alpha blending is needed
  109335. */
  109336. needAlphaBlending(): boolean;
  109337. /**
  109338. * Specifies if this material should be rendered in alpha test mode
  109339. * @returns a boolean specifying if an alpha test is needed.
  109340. */
  109341. needAlphaTesting(): boolean;
  109342. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  109343. /**
  109344. * Get the texture used for alpha test purpose.
  109345. * @returns the diffuse texture in case of the standard material.
  109346. */
  109347. getAlphaTestTexture(): Nullable<BaseTexture>;
  109348. /**
  109349. * Get if the submesh is ready to be used and all its information available.
  109350. * Child classes can use it to update shaders
  109351. * @param mesh defines the mesh to check
  109352. * @param subMesh defines which submesh to check
  109353. * @param useInstances specifies that instances should be used
  109354. * @returns a boolean indicating that the submesh is ready or not
  109355. */
  109356. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109357. /**
  109358. * Builds the material UBO layouts.
  109359. * Used internally during the effect preparation.
  109360. */
  109361. buildUniformLayout(): void;
  109362. /**
  109363. * Unbinds the material from the mesh
  109364. */
  109365. unbind(): void;
  109366. /**
  109367. * Binds the submesh to this material by preparing the effect and shader to draw
  109368. * @param world defines the world transformation matrix
  109369. * @param mesh defines the mesh containing the submesh
  109370. * @param subMesh defines the submesh to bind the material to
  109371. */
  109372. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109373. /**
  109374. * Get the list of animatables in the material.
  109375. * @returns the list of animatables object used in the material
  109376. */
  109377. getAnimatables(): IAnimatable[];
  109378. /**
  109379. * Gets the active textures from the material
  109380. * @returns an array of textures
  109381. */
  109382. getActiveTextures(): BaseTexture[];
  109383. /**
  109384. * Specifies if the material uses a texture
  109385. * @param texture defines the texture to check against the material
  109386. * @returns a boolean specifying if the material uses the texture
  109387. */
  109388. hasTexture(texture: BaseTexture): boolean;
  109389. /**
  109390. * Disposes the material
  109391. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109392. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109393. */
  109394. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109395. /**
  109396. * Makes a duplicate of the material, and gives it a new name
  109397. * @param name defines the new name for the duplicated material
  109398. * @returns the cloned material
  109399. */
  109400. clone(name: string): StandardMaterial;
  109401. /**
  109402. * Serializes this material in a JSON representation
  109403. * @returns the serialized material object
  109404. */
  109405. serialize(): any;
  109406. /**
  109407. * Creates a standard material from parsed material data
  109408. * @param source defines the JSON representation of the material
  109409. * @param scene defines the hosting scene
  109410. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109411. * @returns a new standard material
  109412. */
  109413. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  109414. /**
  109415. * Are diffuse textures enabled in the application.
  109416. */
  109417. static DiffuseTextureEnabled: boolean;
  109418. /**
  109419. * Are ambient textures enabled in the application.
  109420. */
  109421. static AmbientTextureEnabled: boolean;
  109422. /**
  109423. * Are opacity textures enabled in the application.
  109424. */
  109425. static OpacityTextureEnabled: boolean;
  109426. /**
  109427. * Are reflection textures enabled in the application.
  109428. */
  109429. static ReflectionTextureEnabled: boolean;
  109430. /**
  109431. * Are emissive textures enabled in the application.
  109432. */
  109433. static EmissiveTextureEnabled: boolean;
  109434. /**
  109435. * Are specular textures enabled in the application.
  109436. */
  109437. static SpecularTextureEnabled: boolean;
  109438. /**
  109439. * Are bump textures enabled in the application.
  109440. */
  109441. static BumpTextureEnabled: boolean;
  109442. /**
  109443. * Are lightmap textures enabled in the application.
  109444. */
  109445. static LightmapTextureEnabled: boolean;
  109446. /**
  109447. * Are refraction textures enabled in the application.
  109448. */
  109449. static RefractionTextureEnabled: boolean;
  109450. /**
  109451. * Are color grading textures enabled in the application.
  109452. */
  109453. static ColorGradingTextureEnabled: boolean;
  109454. /**
  109455. * Are fresnels enabled in the application.
  109456. */
  109457. static FresnelEnabled: boolean;
  109458. }
  109459. }
  109460. declare module BABYLON {
  109461. /** @hidden */
  109462. export var imageProcessingPixelShader: {
  109463. name: string;
  109464. shader: string;
  109465. };
  109466. }
  109467. declare module BABYLON {
  109468. /**
  109469. * ImageProcessingPostProcess
  109470. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  109471. */
  109472. export class ImageProcessingPostProcess extends PostProcess {
  109473. /**
  109474. * Default configuration related to image processing available in the PBR Material.
  109475. */
  109476. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109477. /**
  109478. * Gets the image processing configuration used either in this material.
  109479. */
  109480. /**
  109481. * Sets the Default image processing configuration used either in the this material.
  109482. *
  109483. * If sets to null, the scene one is in use.
  109484. */
  109485. imageProcessingConfiguration: ImageProcessingConfiguration;
  109486. /**
  109487. * Keep track of the image processing observer to allow dispose and replace.
  109488. */
  109489. private _imageProcessingObserver;
  109490. /**
  109491. * Attaches a new image processing configuration to the PBR Material.
  109492. * @param configuration
  109493. */
  109494. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  109495. /**
  109496. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109497. */
  109498. /**
  109499. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109500. */
  109501. colorCurves: Nullable<ColorCurves>;
  109502. /**
  109503. * Gets wether the color curves effect is enabled.
  109504. */
  109505. /**
  109506. * Sets wether the color curves effect is enabled.
  109507. */
  109508. colorCurvesEnabled: boolean;
  109509. /**
  109510. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109511. */
  109512. /**
  109513. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109514. */
  109515. colorGradingTexture: Nullable<BaseTexture>;
  109516. /**
  109517. * Gets wether the color grading effect is enabled.
  109518. */
  109519. /**
  109520. * Gets wether the color grading effect is enabled.
  109521. */
  109522. colorGradingEnabled: boolean;
  109523. /**
  109524. * Gets exposure used in the effect.
  109525. */
  109526. /**
  109527. * Sets exposure used in the effect.
  109528. */
  109529. exposure: number;
  109530. /**
  109531. * Gets wether tonemapping is enabled or not.
  109532. */
  109533. /**
  109534. * Sets wether tonemapping is enabled or not
  109535. */
  109536. toneMappingEnabled: boolean;
  109537. /**
  109538. * Gets the type of tone mapping effect.
  109539. */
  109540. /**
  109541. * Sets the type of tone mapping effect.
  109542. */
  109543. toneMappingType: number;
  109544. /**
  109545. * Gets contrast used in the effect.
  109546. */
  109547. /**
  109548. * Sets contrast used in the effect.
  109549. */
  109550. contrast: number;
  109551. /**
  109552. * Gets Vignette stretch size.
  109553. */
  109554. /**
  109555. * Sets Vignette stretch size.
  109556. */
  109557. vignetteStretch: number;
  109558. /**
  109559. * Gets Vignette centre X Offset.
  109560. */
  109561. /**
  109562. * Sets Vignette centre X Offset.
  109563. */
  109564. vignetteCentreX: number;
  109565. /**
  109566. * Gets Vignette centre Y Offset.
  109567. */
  109568. /**
  109569. * Sets Vignette centre Y Offset.
  109570. */
  109571. vignetteCentreY: number;
  109572. /**
  109573. * Gets Vignette weight or intensity of the vignette effect.
  109574. */
  109575. /**
  109576. * Sets Vignette weight or intensity of the vignette effect.
  109577. */
  109578. vignetteWeight: number;
  109579. /**
  109580. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  109581. * if vignetteEnabled is set to true.
  109582. */
  109583. /**
  109584. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  109585. * if vignetteEnabled is set to true.
  109586. */
  109587. vignetteColor: Color4;
  109588. /**
  109589. * Gets Camera field of view used by the Vignette effect.
  109590. */
  109591. /**
  109592. * Sets Camera field of view used by the Vignette effect.
  109593. */
  109594. vignetteCameraFov: number;
  109595. /**
  109596. * Gets the vignette blend mode allowing different kind of effect.
  109597. */
  109598. /**
  109599. * Sets the vignette blend mode allowing different kind of effect.
  109600. */
  109601. vignetteBlendMode: number;
  109602. /**
  109603. * Gets wether the vignette effect is enabled.
  109604. */
  109605. /**
  109606. * Sets wether the vignette effect is enabled.
  109607. */
  109608. vignetteEnabled: boolean;
  109609. private _fromLinearSpace;
  109610. /**
  109611. * Gets wether the input of the processing is in Gamma or Linear Space.
  109612. */
  109613. /**
  109614. * Sets wether the input of the processing is in Gamma or Linear Space.
  109615. */
  109616. fromLinearSpace: boolean;
  109617. /**
  109618. * Defines cache preventing GC.
  109619. */
  109620. private _defines;
  109621. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  109622. /**
  109623. * "ImageProcessingPostProcess"
  109624. * @returns "ImageProcessingPostProcess"
  109625. */
  109626. getClassName(): string;
  109627. protected _updateParameters(): void;
  109628. dispose(camera?: Camera): void;
  109629. }
  109630. }
  109631. declare module BABYLON {
  109632. /**
  109633. * Class containing static functions to help procedurally build meshes
  109634. */
  109635. export class GroundBuilder {
  109636. /**
  109637. * Creates a ground mesh
  109638. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  109639. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  109640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109641. * @param name defines the name of the mesh
  109642. * @param options defines the options used to create the mesh
  109643. * @param scene defines the hosting scene
  109644. * @returns the ground mesh
  109645. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  109646. */
  109647. static CreateGround(name: string, options: {
  109648. width?: number;
  109649. height?: number;
  109650. subdivisions?: number;
  109651. subdivisionsX?: number;
  109652. subdivisionsY?: number;
  109653. updatable?: boolean;
  109654. }, scene: any): Mesh;
  109655. /**
  109656. * Creates a tiled ground mesh
  109657. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  109658. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  109659. * * 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
  109660. * * 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
  109661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109662. * @param name defines the name of the mesh
  109663. * @param options defines the options used to create the mesh
  109664. * @param scene defines the hosting scene
  109665. * @returns the tiled ground mesh
  109666. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  109667. */
  109668. static CreateTiledGround(name: string, options: {
  109669. xmin: number;
  109670. zmin: number;
  109671. xmax: number;
  109672. zmax: number;
  109673. subdivisions?: {
  109674. w: number;
  109675. h: number;
  109676. };
  109677. precision?: {
  109678. w: number;
  109679. h: number;
  109680. };
  109681. updatable?: boolean;
  109682. }, scene?: Nullable<Scene>): Mesh;
  109683. /**
  109684. * Creates a ground mesh from a height map
  109685. * * The parameter `url` sets the URL of the height map image resource.
  109686. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  109687. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  109688. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  109689. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  109690. * * 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.
  109691. * * 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).
  109692. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109694. * @param name defines the name of the mesh
  109695. * @param url defines the url to the height map
  109696. * @param options defines the options used to create the mesh
  109697. * @param scene defines the hosting scene
  109698. * @returns the ground mesh
  109699. * @see https://doc.babylonjs.com/babylon101/height_map
  109700. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  109701. */
  109702. static CreateGroundFromHeightMap(name: string, url: string, options: {
  109703. width?: number;
  109704. height?: number;
  109705. subdivisions?: number;
  109706. minHeight?: number;
  109707. maxHeight?: number;
  109708. colorFilter?: Color3;
  109709. alphaFilter?: number;
  109710. updatable?: boolean;
  109711. onReady?: (mesh: GroundMesh) => void;
  109712. }, scene?: Nullable<Scene>): GroundMesh;
  109713. }
  109714. }
  109715. declare module BABYLON {
  109716. /**
  109717. * Class containing static functions to help procedurally build meshes
  109718. */
  109719. export class TorusBuilder {
  109720. /**
  109721. * Creates a torus mesh
  109722. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  109723. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  109724. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  109725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109726. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109728. * @param name defines the name of the mesh
  109729. * @param options defines the options used to create the mesh
  109730. * @param scene defines the hosting scene
  109731. * @returns the torus mesh
  109732. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  109733. */
  109734. static CreateTorus(name: string, options: {
  109735. diameter?: number;
  109736. thickness?: number;
  109737. tessellation?: number;
  109738. updatable?: boolean;
  109739. sideOrientation?: number;
  109740. frontUVs?: Vector4;
  109741. backUVs?: Vector4;
  109742. }, scene: any): Mesh;
  109743. }
  109744. }
  109745. declare module BABYLON {
  109746. /**
  109747. * Class containing static functions to help procedurally build meshes
  109748. */
  109749. export class CylinderBuilder {
  109750. /**
  109751. * Creates a cylinder or a cone mesh
  109752. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  109753. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  109754. * * 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.
  109755. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  109756. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  109757. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  109758. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  109759. * * 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).
  109760. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  109761. * * 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).
  109762. * * 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
  109763. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  109764. * * 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
  109765. * * 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.
  109766. * * If `enclose` is false, a ring surface is one element.
  109767. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  109768. * * 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
  109769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109770. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109772. * @param name defines the name of the mesh
  109773. * @param options defines the options used to create the mesh
  109774. * @param scene defines the hosting scene
  109775. * @returns the cylinder mesh
  109776. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  109777. */
  109778. static CreateCylinder(name: string, options: {
  109779. height?: number;
  109780. diameterTop?: number;
  109781. diameterBottom?: number;
  109782. diameter?: number;
  109783. tessellation?: number;
  109784. subdivisions?: number;
  109785. arc?: number;
  109786. faceColors?: Color4[];
  109787. faceUV?: Vector4[];
  109788. updatable?: boolean;
  109789. hasRings?: boolean;
  109790. enclose?: boolean;
  109791. cap?: number;
  109792. sideOrientation?: number;
  109793. frontUVs?: Vector4;
  109794. backUVs?: Vector4;
  109795. }, scene: any): Mesh;
  109796. }
  109797. }
  109798. declare module BABYLON {
  109799. /**
  109800. * Options to modify the vr teleportation behavior.
  109801. */
  109802. export interface VRTeleportationOptions {
  109803. /**
  109804. * The name of the mesh which should be used as the teleportation floor. (default: null)
  109805. */
  109806. floorMeshName?: string;
  109807. /**
  109808. * A list of meshes to be used as the teleportation floor. (default: empty)
  109809. */
  109810. floorMeshes?: Mesh[];
  109811. }
  109812. /**
  109813. * Options to modify the vr experience helper's behavior.
  109814. */
  109815. export interface VRExperienceHelperOptions extends WebVROptions {
  109816. /**
  109817. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  109818. */
  109819. createDeviceOrientationCamera?: boolean;
  109820. /**
  109821. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  109822. */
  109823. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  109824. /**
  109825. * Uses the main button on the controller to toggle the laser casted. (default: true)
  109826. */
  109827. laserToggle?: boolean;
  109828. /**
  109829. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  109830. */
  109831. floorMeshes?: Mesh[];
  109832. /**
  109833. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  109834. */
  109835. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  109836. }
  109837. /**
  109838. * Event containing information after VR has been entered
  109839. */
  109840. export class OnAfterEnteringVRObservableEvent {
  109841. /**
  109842. * If entering vr was successful
  109843. */
  109844. success: boolean;
  109845. }
  109846. /**
  109847. * Helps to quickly add VR support to an existing scene.
  109848. * See http://doc.babylonjs.com/how_to/webvr_helper
  109849. */
  109850. export class VRExperienceHelper {
  109851. /** Options to modify the vr experience helper's behavior. */
  109852. webVROptions: VRExperienceHelperOptions;
  109853. private _scene;
  109854. private _position;
  109855. private _btnVR;
  109856. private _btnVRDisplayed;
  109857. private _webVRsupported;
  109858. private _webVRready;
  109859. private _webVRrequesting;
  109860. private _webVRpresenting;
  109861. private _hasEnteredVR;
  109862. private _fullscreenVRpresenting;
  109863. private _inputElement;
  109864. private _webVRCamera;
  109865. private _vrDeviceOrientationCamera;
  109866. private _deviceOrientationCamera;
  109867. private _existingCamera;
  109868. private _onKeyDown;
  109869. private _onVrDisplayPresentChange;
  109870. private _onVRDisplayChanged;
  109871. private _onVRRequestPresentStart;
  109872. private _onVRRequestPresentComplete;
  109873. /**
  109874. * 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)
  109875. */
  109876. enableGazeEvenWhenNoPointerLock: boolean;
  109877. /**
  109878. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  109879. */
  109880. exitVROnDoubleTap: boolean;
  109881. /**
  109882. * Observable raised right before entering VR.
  109883. */
  109884. onEnteringVRObservable: Observable<VRExperienceHelper>;
  109885. /**
  109886. * Observable raised when entering VR has completed.
  109887. */
  109888. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  109889. /**
  109890. * Observable raised when exiting VR.
  109891. */
  109892. onExitingVRObservable: Observable<VRExperienceHelper>;
  109893. /**
  109894. * Observable raised when controller mesh is loaded.
  109895. */
  109896. onControllerMeshLoadedObservable: Observable<WebVRController>;
  109897. /** Return this.onEnteringVRObservable
  109898. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  109899. */
  109900. readonly onEnteringVR: Observable<VRExperienceHelper>;
  109901. /** Return this.onExitingVRObservable
  109902. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  109903. */
  109904. readonly onExitingVR: Observable<VRExperienceHelper>;
  109905. /** Return this.onControllerMeshLoadedObservable
  109906. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  109907. */
  109908. readonly onControllerMeshLoaded: Observable<WebVRController>;
  109909. private _rayLength;
  109910. private _useCustomVRButton;
  109911. private _teleportationRequested;
  109912. private _teleportActive;
  109913. private _floorMeshName;
  109914. private _floorMeshesCollection;
  109915. private _rotationAllowed;
  109916. private _teleportBackwardsVector;
  109917. private _teleportationTarget;
  109918. private _isDefaultTeleportationTarget;
  109919. private _postProcessMove;
  109920. private _teleportationFillColor;
  109921. private _teleportationBorderColor;
  109922. private _rotationAngle;
  109923. private _haloCenter;
  109924. private _cameraGazer;
  109925. private _padSensibilityUp;
  109926. private _padSensibilityDown;
  109927. private _leftController;
  109928. private _rightController;
  109929. /**
  109930. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  109931. */
  109932. onNewMeshSelected: Observable<AbstractMesh>;
  109933. /**
  109934. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  109935. * This observable will provide the mesh and the controller used to select the mesh
  109936. */
  109937. onMeshSelectedWithController: Observable<{
  109938. mesh: AbstractMesh;
  109939. controller: WebVRController;
  109940. }>;
  109941. /**
  109942. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  109943. */
  109944. onNewMeshPicked: Observable<PickingInfo>;
  109945. private _circleEase;
  109946. /**
  109947. * Observable raised before camera teleportation
  109948. */
  109949. onBeforeCameraTeleport: Observable<Vector3>;
  109950. /**
  109951. * Observable raised after camera teleportation
  109952. */
  109953. onAfterCameraTeleport: Observable<Vector3>;
  109954. /**
  109955. * Observable raised when current selected mesh gets unselected
  109956. */
  109957. onSelectedMeshUnselected: Observable<AbstractMesh>;
  109958. private _raySelectionPredicate;
  109959. /**
  109960. * To be optionaly changed by user to define custom ray selection
  109961. */
  109962. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  109963. /**
  109964. * To be optionaly changed by user to define custom selection logic (after ray selection)
  109965. */
  109966. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  109967. /**
  109968. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  109969. */
  109970. teleportationEnabled: boolean;
  109971. private _defaultHeight;
  109972. private _teleportationInitialized;
  109973. private _interactionsEnabled;
  109974. private _interactionsRequested;
  109975. private _displayGaze;
  109976. private _displayLaserPointer;
  109977. /**
  109978. * The mesh used to display where the user is going to teleport.
  109979. */
  109980. /**
  109981. * Sets the mesh to be used to display where the user is going to teleport.
  109982. */
  109983. teleportationTarget: Mesh;
  109984. /**
  109985. * 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
  109986. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  109987. * See http://doc.babylonjs.com/resources/baking_transformations
  109988. */
  109989. gazeTrackerMesh: Mesh;
  109990. /**
  109991. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  109992. */
  109993. updateGazeTrackerScale: boolean;
  109994. /**
  109995. * If the gaze trackers color should be updated when selecting meshes
  109996. */
  109997. updateGazeTrackerColor: boolean;
  109998. /**
  109999. * If the controller laser color should be updated when selecting meshes
  110000. */
  110001. updateControllerLaserColor: boolean;
  110002. /**
  110003. * The gaze tracking mesh corresponding to the left controller
  110004. */
  110005. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  110006. /**
  110007. * The gaze tracking mesh corresponding to the right controller
  110008. */
  110009. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  110010. /**
  110011. * If the ray of the gaze should be displayed.
  110012. */
  110013. /**
  110014. * Sets if the ray of the gaze should be displayed.
  110015. */
  110016. displayGaze: boolean;
  110017. /**
  110018. * If the ray of the LaserPointer should be displayed.
  110019. */
  110020. /**
  110021. * Sets if the ray of the LaserPointer should be displayed.
  110022. */
  110023. displayLaserPointer: boolean;
  110024. /**
  110025. * The deviceOrientationCamera used as the camera when not in VR.
  110026. */
  110027. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  110028. /**
  110029. * Based on the current WebVR support, returns the current VR camera used.
  110030. */
  110031. readonly currentVRCamera: Nullable<Camera>;
  110032. /**
  110033. * The webVRCamera which is used when in VR.
  110034. */
  110035. readonly webVRCamera: WebVRFreeCamera;
  110036. /**
  110037. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  110038. */
  110039. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  110040. /**
  110041. * The html button that is used to trigger entering into VR.
  110042. */
  110043. readonly vrButton: Nullable<HTMLButtonElement>;
  110044. private readonly _teleportationRequestInitiated;
  110045. /**
  110046. * Defines wether or not Pointer lock should be requested when switching to
  110047. * full screen.
  110048. */
  110049. requestPointerLockOnFullScreen: boolean;
  110050. /**
  110051. * Instantiates a VRExperienceHelper.
  110052. * Helps to quickly add VR support to an existing scene.
  110053. * @param scene The scene the VRExperienceHelper belongs to.
  110054. * @param webVROptions Options to modify the vr experience helper's behavior.
  110055. */
  110056. constructor(scene: Scene,
  110057. /** Options to modify the vr experience helper's behavior. */
  110058. webVROptions?: VRExperienceHelperOptions);
  110059. private _onDefaultMeshLoaded;
  110060. private _onResize;
  110061. private _onFullscreenChange;
  110062. /**
  110063. * Gets a value indicating if we are currently in VR mode.
  110064. */
  110065. readonly isInVRMode: boolean;
  110066. private onVrDisplayPresentChange;
  110067. private onVRDisplayChanged;
  110068. private moveButtonToBottomRight;
  110069. private displayVRButton;
  110070. private updateButtonVisibility;
  110071. private _cachedAngularSensibility;
  110072. /**
  110073. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  110074. * Otherwise, will use the fullscreen API.
  110075. */
  110076. enterVR(): void;
  110077. /**
  110078. * Attempt to exit VR, or fullscreen.
  110079. */
  110080. exitVR(): void;
  110081. /**
  110082. * The position of the vr experience helper.
  110083. */
  110084. /**
  110085. * Sets the position of the vr experience helper.
  110086. */
  110087. position: Vector3;
  110088. /**
  110089. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  110090. */
  110091. enableInteractions(): void;
  110092. private readonly _noControllerIsActive;
  110093. private beforeRender;
  110094. private _isTeleportationFloor;
  110095. /**
  110096. * Adds a floor mesh to be used for teleportation.
  110097. * @param floorMesh the mesh to be used for teleportation.
  110098. */
  110099. addFloorMesh(floorMesh: Mesh): void;
  110100. /**
  110101. * Removes a floor mesh from being used for teleportation.
  110102. * @param floorMesh the mesh to be removed.
  110103. */
  110104. removeFloorMesh(floorMesh: Mesh): void;
  110105. /**
  110106. * Enables interactions and teleportation using the VR controllers and gaze.
  110107. * @param vrTeleportationOptions options to modify teleportation behavior.
  110108. */
  110109. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  110110. private _onNewGamepadConnected;
  110111. private _tryEnableInteractionOnController;
  110112. private _onNewGamepadDisconnected;
  110113. private _enableInteractionOnController;
  110114. private _checkTeleportWithRay;
  110115. private _checkRotate;
  110116. private _checkTeleportBackwards;
  110117. private _enableTeleportationOnController;
  110118. private _createTeleportationCircles;
  110119. private _displayTeleportationTarget;
  110120. private _hideTeleportationTarget;
  110121. private _rotateCamera;
  110122. private _moveTeleportationSelectorTo;
  110123. private _workingVector;
  110124. private _workingQuaternion;
  110125. private _workingMatrix;
  110126. /**
  110127. * Teleports the users feet to the desired location
  110128. * @param location The location where the user's feet should be placed
  110129. */
  110130. teleportCamera(location: Vector3): void;
  110131. private _convertNormalToDirectionOfRay;
  110132. private _castRayAndSelectObject;
  110133. private _notifySelectedMeshUnselected;
  110134. /**
  110135. * Sets the color of the laser ray from the vr controllers.
  110136. * @param color new color for the ray.
  110137. */
  110138. changeLaserColor(color: Color3): void;
  110139. /**
  110140. * Sets the color of the ray from the vr headsets gaze.
  110141. * @param color new color for the ray.
  110142. */
  110143. changeGazeColor(color: Color3): void;
  110144. /**
  110145. * Exits VR and disposes of the vr experience helper
  110146. */
  110147. dispose(): void;
  110148. /**
  110149. * Gets the name of the VRExperienceHelper class
  110150. * @returns "VRExperienceHelper"
  110151. */
  110152. getClassName(): string;
  110153. }
  110154. }
  110155. declare module BABYLON {
  110156. /**
  110157. * States of the webXR experience
  110158. */
  110159. export enum WebXRState {
  110160. /**
  110161. * Transitioning to being in XR mode
  110162. */
  110163. ENTERING_XR = 0,
  110164. /**
  110165. * Transitioning to non XR mode
  110166. */
  110167. EXITING_XR = 1,
  110168. /**
  110169. * In XR mode and presenting
  110170. */
  110171. IN_XR = 2,
  110172. /**
  110173. * Not entered XR mode
  110174. */
  110175. NOT_IN_XR = 3
  110176. }
  110177. /**
  110178. * Abstraction of the XR render target
  110179. */
  110180. export interface WebXRRenderTarget extends IDisposable {
  110181. /**
  110182. * xrpresent context of the canvas which can be used to display/mirror xr content
  110183. */
  110184. canvasContext: WebGLRenderingContext;
  110185. /**
  110186. * xr layer for the canvas
  110187. */
  110188. xrLayer: Nullable<XRWebGLLayer>;
  110189. /**
  110190. * Initializes the xr layer for the session
  110191. * @param xrSession xr session
  110192. * @returns a promise that will resolve once the XR Layer has been created
  110193. */
  110194. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  110195. }
  110196. }
  110197. declare module BABYLON {
  110198. /**
  110199. * COnfiguration object for WebXR output canvas
  110200. */
  110201. export class WebXRManagedOutputCanvasOptions {
  110202. /**
  110203. * Options for this XR Layer output
  110204. */
  110205. canvasOptions: XRWebGLLayerOptions;
  110206. /**
  110207. * CSS styling for a newly created canvas (if not provided)
  110208. */
  110209. newCanvasCssStyle?: string;
  110210. /**
  110211. * Get the default values of the configuration object
  110212. * @returns default values of this configuration object
  110213. */
  110214. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  110215. }
  110216. /**
  110217. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  110218. */
  110219. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  110220. private configuration;
  110221. private _engine;
  110222. private _canvas;
  110223. /**
  110224. * xrpresent context of the canvas which can be used to display/mirror xr content
  110225. */
  110226. canvasContext: WebGLRenderingContext;
  110227. /**
  110228. * xr layer for the canvas
  110229. */
  110230. xrLayer: Nullable<XRWebGLLayer>;
  110231. /**
  110232. * Initializes the xr layer for the session
  110233. * @param xrSession xr session
  110234. * @returns a promise that will resolve once the XR Layer has been created
  110235. */
  110236. initializeXRLayerAsync(xrSession: any): any;
  110237. /**
  110238. * Initializes the canvas to be added/removed upon entering/exiting xr
  110239. * @param engine the Babylon engine
  110240. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  110241. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  110242. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  110243. */
  110244. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  110245. /**
  110246. * Disposes of the object
  110247. */
  110248. dispose(): void;
  110249. private _setManagedOutputCanvas;
  110250. private _addCanvas;
  110251. private _removeCanvas;
  110252. }
  110253. }
  110254. declare module BABYLON {
  110255. /**
  110256. * Manages an XRSession to work with Babylon's engine
  110257. * @see https://doc.babylonjs.com/how_to/webxr
  110258. */
  110259. export class WebXRSessionManager implements IDisposable {
  110260. private scene;
  110261. /**
  110262. * Fires every time a new xrFrame arrives which can be used to update the camera
  110263. */
  110264. onXRFrameObservable: Observable<any>;
  110265. /**
  110266. * Fires when the xr session is ended either by the device or manually done
  110267. */
  110268. onXRSessionEnded: Observable<any>;
  110269. /**
  110270. * Underlying xr session
  110271. */
  110272. session: XRSession;
  110273. /**
  110274. * Type of reference space used when creating the session
  110275. */
  110276. referenceSpace: XRReferenceSpace;
  110277. /**
  110278. * Current XR frame
  110279. */
  110280. currentFrame: Nullable<XRFrame>;
  110281. private _xrNavigator;
  110282. private baseLayer;
  110283. private _rttProvider;
  110284. private _sessionEnded;
  110285. /**
  110286. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  110287. * @param scene The scene which the session should be created for
  110288. */
  110289. constructor(scene: Scene);
  110290. /**
  110291. * Initializes the manager
  110292. * After initialization enterXR can be called to start an XR session
  110293. * @returns Promise which resolves after it is initialized
  110294. */
  110295. initializeAsync(): Promise<void>;
  110296. /**
  110297. * Initializes an xr session
  110298. * @param xrSessionMode mode to initialize
  110299. * @param optionalFeatures defines optional values to pass to the session builder
  110300. * @returns a promise which will resolve once the session has been initialized
  110301. */
  110302. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  110303. /**
  110304. * Sets the reference space on the xr session
  110305. * @param referenceSpace space to set
  110306. * @returns a promise that will resolve once the reference space has been set
  110307. */
  110308. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  110309. /**
  110310. * Updates the render state of the session
  110311. * @param state state to set
  110312. * @returns a promise that resolves once the render state has been updated
  110313. */
  110314. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  110315. /**
  110316. * Starts rendering to the xr layer
  110317. * @returns a promise that will resolve once rendering has started
  110318. */
  110319. startRenderingToXRAsync(): Promise<void>;
  110320. /**
  110321. * Gets the correct render target texture to be rendered this frame for this eye
  110322. * @param eye the eye for which to get the render target
  110323. * @returns the render target for the specified eye
  110324. */
  110325. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  110326. /**
  110327. * Stops the xrSession and restores the renderloop
  110328. * @returns Promise which resolves after it exits XR
  110329. */
  110330. exitXRAsync(): Promise<void>;
  110331. /**
  110332. * Checks if a session would be supported for the creation options specified
  110333. * @param sessionMode session mode to check if supported eg. immersive-vr
  110334. * @returns true if supported
  110335. */
  110336. supportsSessionAsync(sessionMode: XRSessionMode): any;
  110337. /**
  110338. * Creates a WebXRRenderTarget object for the XR session
  110339. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  110340. * @param options optional options to provide when creating a new render target
  110341. * @returns a WebXR render target to which the session can render
  110342. */
  110343. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  110344. /**
  110345. * @hidden
  110346. * Converts the render layer of xrSession to a render target
  110347. * @param session session to create render target for
  110348. * @param scene scene the new render target should be created for
  110349. */
  110350. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  110351. /**
  110352. * Disposes of the session manager
  110353. */
  110354. dispose(): void;
  110355. }
  110356. }
  110357. declare module BABYLON {
  110358. /**
  110359. * WebXR Camera which holds the views for the xrSession
  110360. * @see https://doc.babylonjs.com/how_to/webxr
  110361. */
  110362. export class WebXRCamera extends FreeCamera {
  110363. /**
  110364. * Is the camera in debug mode. Used when using an emulator
  110365. */
  110366. debugMode: boolean;
  110367. /**
  110368. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  110369. * @param name the name of the camera
  110370. * @param scene the scene to add the camera to
  110371. */
  110372. constructor(name: string, scene: Scene);
  110373. private _updateNumberOfRigCameras;
  110374. /** @hidden */
  110375. _updateForDualEyeDebugging(): void;
  110376. /**
  110377. * Updates the cameras position from the current pose information of the XR session
  110378. * @param xrSessionManager the session containing pose information
  110379. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  110380. */
  110381. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  110382. }
  110383. }
  110384. declare module BABYLON {
  110385. /**
  110386. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  110387. * @see https://doc.babylonjs.com/how_to/webxr
  110388. */
  110389. export class WebXRExperienceHelper implements IDisposable {
  110390. private scene;
  110391. /**
  110392. * 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
  110393. */
  110394. container: AbstractMesh;
  110395. /**
  110396. * Camera used to render xr content
  110397. */
  110398. camera: WebXRCamera;
  110399. /**
  110400. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  110401. */
  110402. state: WebXRState;
  110403. private _setState;
  110404. private static _TmpVector;
  110405. /**
  110406. * Fires when the state of the experience helper has changed
  110407. */
  110408. onStateChangedObservable: Observable<WebXRState>;
  110409. /** Session manager used to keep track of xr session */
  110410. sessionManager: WebXRSessionManager;
  110411. private _nonVRCamera;
  110412. private _originalSceneAutoClear;
  110413. private _supported;
  110414. /**
  110415. * Creates the experience helper
  110416. * @param scene the scene to attach the experience helper to
  110417. * @returns a promise for the experience helper
  110418. */
  110419. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  110420. /**
  110421. * Creates a WebXRExperienceHelper
  110422. * @param scene The scene the helper should be created in
  110423. */
  110424. private constructor();
  110425. /**
  110426. * Exits XR mode and returns the scene to its original state
  110427. * @returns promise that resolves after xr mode has exited
  110428. */
  110429. exitXRAsync(): Promise<void>;
  110430. /**
  110431. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  110432. * @param sessionMode options for the XR session
  110433. * @param referenceSpaceType frame of reference of the XR session
  110434. * @param renderTarget the output canvas that will be used to enter XR mode
  110435. * @returns promise that resolves after xr mode has entered
  110436. */
  110437. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  110438. /**
  110439. * Updates the global position of the camera by moving the camera's container
  110440. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  110441. * @param position The desired global position of the camera
  110442. */
  110443. setPositionOfCameraUsingContainer(position: Vector3): void;
  110444. /**
  110445. * Rotates the xr camera by rotating the camera's container around the camera's position
  110446. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  110447. * @param rotation the desired quaternion rotation to apply to the camera
  110448. */
  110449. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  110450. /**
  110451. * Disposes of the experience helper
  110452. */
  110453. dispose(): void;
  110454. }
  110455. }
  110456. declare module BABYLON {
  110457. /**
  110458. * Button which can be used to enter a different mode of XR
  110459. */
  110460. export class WebXREnterExitUIButton {
  110461. /** button element */
  110462. element: HTMLElement;
  110463. /** XR initialization options for the button */
  110464. sessionMode: XRSessionMode;
  110465. /** Reference space type */
  110466. referenceSpaceType: XRReferenceSpaceType;
  110467. /**
  110468. * Creates a WebXREnterExitUIButton
  110469. * @param element button element
  110470. * @param sessionMode XR initialization session mode
  110471. * @param referenceSpaceType the type of reference space to be used
  110472. */
  110473. constructor(
  110474. /** button element */
  110475. element: HTMLElement,
  110476. /** XR initialization options for the button */
  110477. sessionMode: XRSessionMode,
  110478. /** Reference space type */
  110479. referenceSpaceType: XRReferenceSpaceType);
  110480. /**
  110481. * Overwritable function which can be used to update the button's visuals when the state changes
  110482. * @param activeButton the current active button in the UI
  110483. */
  110484. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  110485. }
  110486. /**
  110487. * Options to create the webXR UI
  110488. */
  110489. export class WebXREnterExitUIOptions {
  110490. /**
  110491. * Context to enter xr with
  110492. */
  110493. renderTarget?: Nullable<WebXRRenderTarget>;
  110494. /**
  110495. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  110496. */
  110497. customButtons?: Array<WebXREnterExitUIButton>;
  110498. }
  110499. /**
  110500. * UI to allow the user to enter/exit XR mode
  110501. */
  110502. export class WebXREnterExitUI implements IDisposable {
  110503. private scene;
  110504. private _overlay;
  110505. private _buttons;
  110506. private _activeButton;
  110507. /**
  110508. * Fired every time the active button is changed.
  110509. *
  110510. * When xr is entered via a button that launches xr that button will be the callback parameter
  110511. *
  110512. * When exiting xr the callback parameter will be null)
  110513. */
  110514. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  110515. /**
  110516. * Creates UI to allow the user to enter/exit XR mode
  110517. * @param scene the scene to add the ui to
  110518. * @param helper the xr experience helper to enter/exit xr with
  110519. * @param options options to configure the UI
  110520. * @returns the created ui
  110521. */
  110522. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  110523. private constructor();
  110524. private _updateButtons;
  110525. /**
  110526. * Disposes of the object
  110527. */
  110528. dispose(): void;
  110529. }
  110530. }
  110531. declare module BABYLON {
  110532. /**
  110533. * Represents an XR input
  110534. */
  110535. export class WebXRController {
  110536. private scene;
  110537. /** The underlying input source for the controller */
  110538. inputSource: XRInputSource;
  110539. private parentContainer;
  110540. /**
  110541. * 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
  110542. */
  110543. grip?: AbstractMesh;
  110544. /**
  110545. * Pointer which can be used to select objects or attach a visible laser to
  110546. */
  110547. pointer: AbstractMesh;
  110548. private _gamepadMode;
  110549. /**
  110550. * If available, this is the gamepad object related to this controller.
  110551. * Using this object it is possible to get click events and trackpad changes of the
  110552. * webxr controller that is currently being used.
  110553. */
  110554. gamepadController?: WebVRController;
  110555. /**
  110556. * Event that fires when the controller is removed/disposed
  110557. */
  110558. onDisposeObservable: Observable<{}>;
  110559. private _tmpMatrix;
  110560. private _tmpQuaternion;
  110561. private _tmpVector;
  110562. /**
  110563. * Creates the controller
  110564. * @see https://doc.babylonjs.com/how_to/webxr
  110565. * @param scene the scene which the controller should be associated to
  110566. * @param inputSource the underlying input source for the controller
  110567. * @param parentContainer parent that the controller meshes should be children of
  110568. */
  110569. constructor(scene: Scene,
  110570. /** The underlying input source for the controller */
  110571. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  110572. /**
  110573. * Updates the controller pose based on the given XRFrame
  110574. * @param xrFrame xr frame to update the pose with
  110575. * @param referenceSpace reference space to use
  110576. */
  110577. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  110578. /**
  110579. * Gets a world space ray coming from the controller
  110580. * @param result the resulting ray
  110581. */
  110582. getWorldPointerRayToRef(result: Ray): void;
  110583. /**
  110584. * Get the scene associated with this controller
  110585. * @returns the scene object
  110586. */
  110587. getScene(): Scene;
  110588. /**
  110589. * Disposes of the object
  110590. */
  110591. dispose(): void;
  110592. }
  110593. }
  110594. declare module BABYLON {
  110595. /**
  110596. * XR input used to track XR inputs such as controllers/rays
  110597. */
  110598. export class WebXRInput implements IDisposable {
  110599. /**
  110600. * Base experience the input listens to
  110601. */
  110602. baseExperience: WebXRExperienceHelper;
  110603. /**
  110604. * XR controllers being tracked
  110605. */
  110606. controllers: Array<WebXRController>;
  110607. private _frameObserver;
  110608. private _stateObserver;
  110609. /**
  110610. * Event when a controller has been connected/added
  110611. */
  110612. onControllerAddedObservable: Observable<WebXRController>;
  110613. /**
  110614. * Event when a controller has been removed/disconnected
  110615. */
  110616. onControllerRemovedObservable: Observable<WebXRController>;
  110617. /**
  110618. * Initializes the WebXRInput
  110619. * @param baseExperience experience helper which the input should be created for
  110620. */
  110621. constructor(
  110622. /**
  110623. * Base experience the input listens to
  110624. */
  110625. baseExperience: WebXRExperienceHelper);
  110626. private _onInputSourcesChange;
  110627. private _addAndRemoveControllers;
  110628. /**
  110629. * Disposes of the object
  110630. */
  110631. dispose(): void;
  110632. }
  110633. }
  110634. declare module BABYLON {
  110635. /**
  110636. * Enables teleportation
  110637. */
  110638. export class WebXRControllerTeleportation {
  110639. private _teleportationFillColor;
  110640. private _teleportationBorderColor;
  110641. private _tmpRay;
  110642. private _tmpVector;
  110643. /**
  110644. * Creates a WebXRControllerTeleportation
  110645. * @param input input manager to add teleportation to
  110646. * @param floorMeshes floormeshes which can be teleported to
  110647. */
  110648. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  110649. }
  110650. }
  110651. declare module BABYLON {
  110652. /**
  110653. * Handles pointer input automatically for the pointer of XR controllers
  110654. */
  110655. export class WebXRControllerPointerSelection {
  110656. private static _idCounter;
  110657. private _tmpRay;
  110658. /**
  110659. * Creates a WebXRControllerPointerSelection
  110660. * @param input input manager to setup pointer selection
  110661. */
  110662. constructor(input: WebXRInput);
  110663. private _convertNormalToDirectionOfRay;
  110664. private _updatePointerDistance;
  110665. }
  110666. }
  110667. declare module BABYLON {
  110668. /**
  110669. * Class used to represent data loading progression
  110670. */
  110671. export class SceneLoaderProgressEvent {
  110672. /** defines if data length to load can be evaluated */
  110673. readonly lengthComputable: boolean;
  110674. /** defines the loaded data length */
  110675. readonly loaded: number;
  110676. /** defines the data length to load */
  110677. readonly total: number;
  110678. /**
  110679. * Create a new progress event
  110680. * @param lengthComputable defines if data length to load can be evaluated
  110681. * @param loaded defines the loaded data length
  110682. * @param total defines the data length to load
  110683. */
  110684. constructor(
  110685. /** defines if data length to load can be evaluated */
  110686. lengthComputable: boolean,
  110687. /** defines the loaded data length */
  110688. loaded: number,
  110689. /** defines the data length to load */
  110690. total: number);
  110691. /**
  110692. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  110693. * @param event defines the source event
  110694. * @returns a new SceneLoaderProgressEvent
  110695. */
  110696. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  110697. }
  110698. /**
  110699. * Interface used by SceneLoader plugins to define supported file extensions
  110700. */
  110701. export interface ISceneLoaderPluginExtensions {
  110702. /**
  110703. * Defines the list of supported extensions
  110704. */
  110705. [extension: string]: {
  110706. isBinary: boolean;
  110707. };
  110708. }
  110709. /**
  110710. * Interface used by SceneLoader plugin factory
  110711. */
  110712. export interface ISceneLoaderPluginFactory {
  110713. /**
  110714. * Defines the name of the factory
  110715. */
  110716. name: string;
  110717. /**
  110718. * Function called to create a new plugin
  110719. * @return the new plugin
  110720. */
  110721. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  110722. /**
  110723. * The callback that returns true if the data can be directly loaded.
  110724. * @param data string containing the file data
  110725. * @returns if the data can be loaded directly
  110726. */
  110727. canDirectLoad?(data: string): boolean;
  110728. }
  110729. /**
  110730. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  110731. */
  110732. export interface ISceneLoaderPluginBase {
  110733. /**
  110734. * The friendly name of this plugin.
  110735. */
  110736. name: string;
  110737. /**
  110738. * The file extensions supported by this plugin.
  110739. */
  110740. extensions: string | ISceneLoaderPluginExtensions;
  110741. /**
  110742. * The callback called when loading from a url.
  110743. * @param scene scene loading this url
  110744. * @param url url to load
  110745. * @param onSuccess callback called when the file successfully loads
  110746. * @param onProgress callback called while file is loading (if the server supports this mode)
  110747. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110748. * @param onError callback called when the file fails to load
  110749. * @returns a file request object
  110750. */
  110751. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110752. /**
  110753. * The callback called when loading from a file object.
  110754. * @param scene scene loading this file
  110755. * @param file defines the file to load
  110756. * @param onSuccess defines the callback to call when data is loaded
  110757. * @param onProgress defines the callback to call during loading process
  110758. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  110759. * @param onError defines the callback to call when an error occurs
  110760. * @returns a file request object
  110761. */
  110762. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110763. /**
  110764. * The callback that returns true if the data can be directly loaded.
  110765. * @param data string containing the file data
  110766. * @returns if the data can be loaded directly
  110767. */
  110768. canDirectLoad?(data: string): boolean;
  110769. /**
  110770. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  110771. * @param scene scene loading this data
  110772. * @param data string containing the data
  110773. * @returns data to pass to the plugin
  110774. */
  110775. directLoad?(scene: Scene, data: string): any;
  110776. /**
  110777. * The callback that allows custom handling of the root url based on the response url.
  110778. * @param rootUrl the original root url
  110779. * @param responseURL the response url if available
  110780. * @returns the new root url
  110781. */
  110782. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  110783. }
  110784. /**
  110785. * Interface used to define a SceneLoader plugin
  110786. */
  110787. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  110788. /**
  110789. * Import meshes into a scene.
  110790. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110791. * @param scene The scene to import into
  110792. * @param data The data to import
  110793. * @param rootUrl The root url for scene and resources
  110794. * @param meshes The meshes array to import into
  110795. * @param particleSystems The particle systems array to import into
  110796. * @param skeletons The skeletons array to import into
  110797. * @param onError The callback when import fails
  110798. * @returns True if successful or false otherwise
  110799. */
  110800. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  110801. /**
  110802. * Load into a scene.
  110803. * @param scene The scene to load into
  110804. * @param data The data to import
  110805. * @param rootUrl The root url for scene and resources
  110806. * @param onError The callback when import fails
  110807. * @returns True if successful or false otherwise
  110808. */
  110809. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  110810. /**
  110811. * Load into an asset container.
  110812. * @param scene The scene to load into
  110813. * @param data The data to import
  110814. * @param rootUrl The root url for scene and resources
  110815. * @param onError The callback when import fails
  110816. * @returns The loaded asset container
  110817. */
  110818. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  110819. }
  110820. /**
  110821. * Interface used to define an async SceneLoader plugin
  110822. */
  110823. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  110824. /**
  110825. * Import meshes into a scene.
  110826. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110827. * @param scene The scene to import into
  110828. * @param data The data to import
  110829. * @param rootUrl The root url for scene and resources
  110830. * @param onProgress The callback when the load progresses
  110831. * @param fileName Defines the name of the file to load
  110832. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  110833. */
  110834. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  110835. meshes: AbstractMesh[];
  110836. particleSystems: IParticleSystem[];
  110837. skeletons: Skeleton[];
  110838. animationGroups: AnimationGroup[];
  110839. }>;
  110840. /**
  110841. * Load into a scene.
  110842. * @param scene The scene to load into
  110843. * @param data The data to import
  110844. * @param rootUrl The root url for scene and resources
  110845. * @param onProgress The callback when the load progresses
  110846. * @param fileName Defines the name of the file to load
  110847. * @returns Nothing
  110848. */
  110849. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  110850. /**
  110851. * Load into an asset container.
  110852. * @param scene The scene to load into
  110853. * @param data The data to import
  110854. * @param rootUrl The root url for scene and resources
  110855. * @param onProgress The callback when the load progresses
  110856. * @param fileName Defines the name of the file to load
  110857. * @returns The loaded asset container
  110858. */
  110859. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  110860. }
  110861. /**
  110862. * Class used to load scene from various file formats using registered plugins
  110863. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  110864. */
  110865. export class SceneLoader {
  110866. /**
  110867. * No logging while loading
  110868. */
  110869. static readonly NO_LOGGING: number;
  110870. /**
  110871. * Minimal logging while loading
  110872. */
  110873. static readonly MINIMAL_LOGGING: number;
  110874. /**
  110875. * Summary logging while loading
  110876. */
  110877. static readonly SUMMARY_LOGGING: number;
  110878. /**
  110879. * Detailled logging while loading
  110880. */
  110881. static readonly DETAILED_LOGGING: number;
  110882. /**
  110883. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  110884. */
  110885. static ForceFullSceneLoadingForIncremental: boolean;
  110886. /**
  110887. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  110888. */
  110889. static ShowLoadingScreen: boolean;
  110890. /**
  110891. * Defines the current logging level (while loading the scene)
  110892. * @ignorenaming
  110893. */
  110894. static loggingLevel: number;
  110895. /**
  110896. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  110897. */
  110898. static CleanBoneMatrixWeights: boolean;
  110899. /**
  110900. * Event raised when a plugin is used to load a scene
  110901. */
  110902. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  110903. private static _registeredPlugins;
  110904. private static _getDefaultPlugin;
  110905. private static _getPluginForExtension;
  110906. private static _getPluginForDirectLoad;
  110907. private static _getPluginForFilename;
  110908. private static _getDirectLoad;
  110909. private static _loadData;
  110910. private static _getFileInfo;
  110911. /**
  110912. * Gets a plugin that can load the given extension
  110913. * @param extension defines the extension to load
  110914. * @returns a plugin or null if none works
  110915. */
  110916. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  110917. /**
  110918. * Gets a boolean indicating that the given extension can be loaded
  110919. * @param extension defines the extension to load
  110920. * @returns true if the extension is supported
  110921. */
  110922. static IsPluginForExtensionAvailable(extension: string): boolean;
  110923. /**
  110924. * Adds a new plugin to the list of registered plugins
  110925. * @param plugin defines the plugin to add
  110926. */
  110927. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  110928. /**
  110929. * Import meshes into a scene
  110930. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110931. * @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)
  110932. * @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)
  110933. * @param scene the instance of BABYLON.Scene to append to
  110934. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  110935. * @param onProgress a callback with a progress event for each file being loaded
  110936. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110937. * @param pluginExtension the extension used to determine the plugin
  110938. * @returns The loaded plugin
  110939. */
  110940. 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>;
  110941. /**
  110942. * Import meshes into a scene
  110943. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110944. * @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)
  110945. * @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)
  110946. * @param scene the instance of BABYLON.Scene to append to
  110947. * @param onProgress a callback with a progress event for each file being loaded
  110948. * @param pluginExtension the extension used to determine the plugin
  110949. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  110950. */
  110951. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  110952. meshes: AbstractMesh[];
  110953. particleSystems: IParticleSystem[];
  110954. skeletons: Skeleton[];
  110955. animationGroups: AnimationGroup[];
  110956. }>;
  110957. /**
  110958. * Load a scene
  110959. * @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)
  110960. * @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)
  110961. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110962. * @param onSuccess a callback with the scene when import succeeds
  110963. * @param onProgress a callback with a progress event for each file being loaded
  110964. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110965. * @param pluginExtension the extension used to determine the plugin
  110966. * @returns The loaded plugin
  110967. */
  110968. 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>;
  110969. /**
  110970. * Load a scene
  110971. * @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)
  110972. * @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)
  110973. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110974. * @param onProgress a callback with a progress event for each file being loaded
  110975. * @param pluginExtension the extension used to determine the plugin
  110976. * @returns The loaded scene
  110977. */
  110978. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110979. /**
  110980. * Append a scene
  110981. * @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)
  110982. * @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)
  110983. * @param scene is the instance of BABYLON.Scene to append to
  110984. * @param onSuccess a callback with the scene when import succeeds
  110985. * @param onProgress a callback with a progress event for each file being loaded
  110986. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110987. * @param pluginExtension the extension used to determine the plugin
  110988. * @returns The loaded plugin
  110989. */
  110990. 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>;
  110991. /**
  110992. * Append a scene
  110993. * @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)
  110994. * @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)
  110995. * @param scene is the instance of BABYLON.Scene to append to
  110996. * @param onProgress a callback with a progress event for each file being loaded
  110997. * @param pluginExtension the extension used to determine the plugin
  110998. * @returns The given scene
  110999. */
  111000. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  111001. /**
  111002. * Load a scene into an asset container
  111003. * @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)
  111004. * @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)
  111005. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  111006. * @param onSuccess a callback with the scene when import succeeds
  111007. * @param onProgress a callback with a progress event for each file being loaded
  111008. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111009. * @param pluginExtension the extension used to determine the plugin
  111010. * @returns The loaded plugin
  111011. */
  111012. 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>;
  111013. /**
  111014. * Load a scene into an asset container
  111015. * @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)
  111016. * @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)
  111017. * @param scene is the instance of Scene to append to
  111018. * @param onProgress a callback with a progress event for each file being loaded
  111019. * @param pluginExtension the extension used to determine the plugin
  111020. * @returns The loaded asset container
  111021. */
  111022. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  111023. }
  111024. }
  111025. declare module BABYLON {
  111026. /**
  111027. * Generic Controller
  111028. */
  111029. export class GenericController extends WebVRController {
  111030. /**
  111031. * Base Url for the controller model.
  111032. */
  111033. static readonly MODEL_BASE_URL: string;
  111034. /**
  111035. * File name for the controller model.
  111036. */
  111037. static readonly MODEL_FILENAME: string;
  111038. /**
  111039. * Creates a new GenericController from a gamepad
  111040. * @param vrGamepad the gamepad that the controller should be created from
  111041. */
  111042. constructor(vrGamepad: any);
  111043. /**
  111044. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111045. * @param scene scene in which to add meshes
  111046. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111047. */
  111048. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111049. /**
  111050. * Called once for each button that changed state since the last frame
  111051. * @param buttonIdx Which button index changed
  111052. * @param state New state of the button
  111053. * @param changes Which properties on the state changed since last frame
  111054. */
  111055. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111056. }
  111057. }
  111058. declare module BABYLON {
  111059. /**
  111060. * Defines the WindowsMotionController object that the state of the windows motion controller
  111061. */
  111062. export class WindowsMotionController extends WebVRController {
  111063. /**
  111064. * The base url used to load the left and right controller models
  111065. */
  111066. static MODEL_BASE_URL: string;
  111067. /**
  111068. * The name of the left controller model file
  111069. */
  111070. static MODEL_LEFT_FILENAME: string;
  111071. /**
  111072. * The name of the right controller model file
  111073. */
  111074. static MODEL_RIGHT_FILENAME: string;
  111075. /**
  111076. * The controller name prefix for this controller type
  111077. */
  111078. static readonly GAMEPAD_ID_PREFIX: string;
  111079. /**
  111080. * The controller id pattern for this controller type
  111081. */
  111082. private static readonly GAMEPAD_ID_PATTERN;
  111083. private _loadedMeshInfo;
  111084. private readonly _mapping;
  111085. /**
  111086. * Fired when the trackpad on this controller is clicked
  111087. */
  111088. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  111089. /**
  111090. * Fired when the trackpad on this controller is modified
  111091. */
  111092. onTrackpadValuesChangedObservable: Observable<StickValues>;
  111093. /**
  111094. * The current x and y values of this controller's trackpad
  111095. */
  111096. trackpad: StickValues;
  111097. /**
  111098. * Creates a new WindowsMotionController from a gamepad
  111099. * @param vrGamepad the gamepad that the controller should be created from
  111100. */
  111101. constructor(vrGamepad: any);
  111102. /**
  111103. * Fired when the trigger on this controller is modified
  111104. */
  111105. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111106. /**
  111107. * Fired when the menu button on this controller is modified
  111108. */
  111109. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111110. /**
  111111. * Fired when the grip button on this controller is modified
  111112. */
  111113. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111114. /**
  111115. * Fired when the thumbstick button on this controller is modified
  111116. */
  111117. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111118. /**
  111119. * Fired when the touchpad button on this controller is modified
  111120. */
  111121. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111122. /**
  111123. * Fired when the touchpad values on this controller are modified
  111124. */
  111125. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  111126. private _updateTrackpad;
  111127. /**
  111128. * Called once per frame by the engine.
  111129. */
  111130. update(): void;
  111131. /**
  111132. * Called once for each button that changed state since the last frame
  111133. * @param buttonIdx Which button index changed
  111134. * @param state New state of the button
  111135. * @param changes Which properties on the state changed since last frame
  111136. */
  111137. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111138. /**
  111139. * Moves the buttons on the controller mesh based on their current state
  111140. * @param buttonName the name of the button to move
  111141. * @param buttonValue the value of the button which determines the buttons new position
  111142. */
  111143. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  111144. /**
  111145. * Moves the axis on the controller mesh based on its current state
  111146. * @param axis the index of the axis
  111147. * @param axisValue the value of the axis which determines the meshes new position
  111148. * @hidden
  111149. */
  111150. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  111151. /**
  111152. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111153. * @param scene scene in which to add meshes
  111154. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111155. */
  111156. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  111157. /**
  111158. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  111159. * can be transformed by button presses and axes values, based on this._mapping.
  111160. *
  111161. * @param scene scene in which the meshes exist
  111162. * @param meshes list of meshes that make up the controller model to process
  111163. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  111164. */
  111165. private processModel;
  111166. private createMeshInfo;
  111167. /**
  111168. * Gets the ray of the controller in the direction the controller is pointing
  111169. * @param length the length the resulting ray should be
  111170. * @returns a ray in the direction the controller is pointing
  111171. */
  111172. getForwardRay(length?: number): Ray;
  111173. /**
  111174. * Disposes of the controller
  111175. */
  111176. dispose(): void;
  111177. }
  111178. }
  111179. declare module BABYLON {
  111180. /**
  111181. * Oculus Touch Controller
  111182. */
  111183. export class OculusTouchController extends WebVRController {
  111184. /**
  111185. * Base Url for the controller model.
  111186. */
  111187. static MODEL_BASE_URL: string;
  111188. /**
  111189. * File name for the left controller model.
  111190. */
  111191. static MODEL_LEFT_FILENAME: string;
  111192. /**
  111193. * File name for the right controller model.
  111194. */
  111195. static MODEL_RIGHT_FILENAME: string;
  111196. /**
  111197. * Base Url for the Quest controller model.
  111198. */
  111199. static QUEST_MODEL_BASE_URL: string;
  111200. /**
  111201. * @hidden
  111202. * If the controllers are running on a device that needs the updated Quest controller models
  111203. */
  111204. static _IsQuest: boolean;
  111205. /**
  111206. * Fired when the secondary trigger on this controller is modified
  111207. */
  111208. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  111209. /**
  111210. * Fired when the thumb rest on this controller is modified
  111211. */
  111212. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  111213. /**
  111214. * Creates a new OculusTouchController from a gamepad
  111215. * @param vrGamepad the gamepad that the controller should be created from
  111216. */
  111217. constructor(vrGamepad: any);
  111218. /**
  111219. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111220. * @param scene scene in which to add meshes
  111221. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111222. */
  111223. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111224. /**
  111225. * Fired when the A button on this controller is modified
  111226. */
  111227. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111228. /**
  111229. * Fired when the B button on this controller is modified
  111230. */
  111231. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111232. /**
  111233. * Fired when the X button on this controller is modified
  111234. */
  111235. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111236. /**
  111237. * Fired when the Y button on this controller is modified
  111238. */
  111239. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111240. /**
  111241. * Called once for each button that changed state since the last frame
  111242. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  111243. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  111244. * 2) secondary trigger (same)
  111245. * 3) A (right) X (left), touch, pressed = value
  111246. * 4) B / Y
  111247. * 5) thumb rest
  111248. * @param buttonIdx Which button index changed
  111249. * @param state New state of the button
  111250. * @param changes Which properties on the state changed since last frame
  111251. */
  111252. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111253. }
  111254. }
  111255. declare module BABYLON {
  111256. /**
  111257. * Vive Controller
  111258. */
  111259. export class ViveController extends WebVRController {
  111260. /**
  111261. * Base Url for the controller model.
  111262. */
  111263. static MODEL_BASE_URL: string;
  111264. /**
  111265. * File name for the controller model.
  111266. */
  111267. static MODEL_FILENAME: string;
  111268. /**
  111269. * Creates a new ViveController from a gamepad
  111270. * @param vrGamepad the gamepad that the controller should be created from
  111271. */
  111272. constructor(vrGamepad: any);
  111273. /**
  111274. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111275. * @param scene scene in which to add meshes
  111276. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111277. */
  111278. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111279. /**
  111280. * Fired when the left button on this controller is modified
  111281. */
  111282. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111283. /**
  111284. * Fired when the right button on this controller is modified
  111285. */
  111286. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111287. /**
  111288. * Fired when the menu button on this controller is modified
  111289. */
  111290. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111291. /**
  111292. * Called once for each button that changed state since the last frame
  111293. * Vive mapping:
  111294. * 0: touchpad
  111295. * 1: trigger
  111296. * 2: left AND right buttons
  111297. * 3: menu button
  111298. * @param buttonIdx Which button index changed
  111299. * @param state New state of the button
  111300. * @param changes Which properties on the state changed since last frame
  111301. */
  111302. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111303. }
  111304. }
  111305. declare module BABYLON {
  111306. /**
  111307. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  111308. */
  111309. export class WebXRControllerModelLoader {
  111310. /**
  111311. * Creates the WebXRControllerModelLoader
  111312. * @param input xr input that creates the controllers
  111313. */
  111314. constructor(input: WebXRInput);
  111315. }
  111316. }
  111317. declare module BABYLON {
  111318. /**
  111319. * Options for the default xr helper
  111320. */
  111321. export class WebXRDefaultExperienceOptions {
  111322. /**
  111323. * Floor meshes that should be used for teleporting
  111324. */
  111325. floorMeshes: Array<AbstractMesh>;
  111326. /**
  111327. * Enable or disable default UI to enter XR
  111328. */
  111329. disableDefaultUI: boolean;
  111330. /**
  111331. * optional configuration for the output canvas
  111332. */
  111333. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  111334. }
  111335. /**
  111336. * Default experience which provides a similar setup to the previous webVRExperience
  111337. */
  111338. export class WebXRDefaultExperience {
  111339. /**
  111340. * Base experience
  111341. */
  111342. baseExperience: WebXRExperienceHelper;
  111343. /**
  111344. * Input experience extension
  111345. */
  111346. input: WebXRInput;
  111347. /**
  111348. * Loads the controller models
  111349. */
  111350. controllerModelLoader: WebXRControllerModelLoader;
  111351. /**
  111352. * Enables laser pointer and selection
  111353. */
  111354. pointerSelection: WebXRControllerPointerSelection;
  111355. /**
  111356. * Enables teleportation
  111357. */
  111358. teleportation: WebXRControllerTeleportation;
  111359. /**
  111360. * Enables ui for enetering/exiting xr
  111361. */
  111362. enterExitUI: WebXREnterExitUI;
  111363. /**
  111364. * Default target xr should render to
  111365. */
  111366. renderTarget: WebXRRenderTarget;
  111367. /**
  111368. * Creates the default xr experience
  111369. * @param scene scene
  111370. * @param options options for basic configuration
  111371. * @returns resulting WebXRDefaultExperience
  111372. */
  111373. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111374. private constructor();
  111375. /**
  111376. * DIsposes of the experience helper
  111377. */
  111378. dispose(): void;
  111379. }
  111380. }
  111381. declare module BABYLON {
  111382. /**
  111383. * Contains an array of blocks representing the octree
  111384. */
  111385. export interface IOctreeContainer<T> {
  111386. /**
  111387. * Blocks within the octree
  111388. */
  111389. blocks: Array<OctreeBlock<T>>;
  111390. }
  111391. /**
  111392. * Class used to store a cell in an octree
  111393. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111394. */
  111395. export class OctreeBlock<T> {
  111396. /**
  111397. * Gets the content of the current block
  111398. */
  111399. entries: T[];
  111400. /**
  111401. * Gets the list of block children
  111402. */
  111403. blocks: Array<OctreeBlock<T>>;
  111404. private _depth;
  111405. private _maxDepth;
  111406. private _capacity;
  111407. private _minPoint;
  111408. private _maxPoint;
  111409. private _boundingVectors;
  111410. private _creationFunc;
  111411. /**
  111412. * Creates a new block
  111413. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  111414. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  111415. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  111416. * @param depth defines the current depth of this block in the octree
  111417. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  111418. * @param creationFunc defines a callback to call when an element is added to the block
  111419. */
  111420. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  111421. /**
  111422. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  111423. */
  111424. readonly capacity: number;
  111425. /**
  111426. * Gets the minimum vector (in world space) of the block's bounding box
  111427. */
  111428. readonly minPoint: Vector3;
  111429. /**
  111430. * Gets the maximum vector (in world space) of the block's bounding box
  111431. */
  111432. readonly maxPoint: Vector3;
  111433. /**
  111434. * Add a new element to this block
  111435. * @param entry defines the element to add
  111436. */
  111437. addEntry(entry: T): void;
  111438. /**
  111439. * Remove an element from this block
  111440. * @param entry defines the element to remove
  111441. */
  111442. removeEntry(entry: T): void;
  111443. /**
  111444. * Add an array of elements to this block
  111445. * @param entries defines the array of elements to add
  111446. */
  111447. addEntries(entries: T[]): void;
  111448. /**
  111449. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  111450. * @param frustumPlanes defines the frustum planes to test
  111451. * @param selection defines the array to store current content if selection is positive
  111452. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111453. */
  111454. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  111455. /**
  111456. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  111457. * @param sphereCenter defines the bounding sphere center
  111458. * @param sphereRadius defines the bounding sphere radius
  111459. * @param selection defines the array to store current content if selection is positive
  111460. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111461. */
  111462. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  111463. /**
  111464. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  111465. * @param ray defines the ray to test with
  111466. * @param selection defines the array to store current content if selection is positive
  111467. */
  111468. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  111469. /**
  111470. * Subdivide the content into child blocks (this block will then be empty)
  111471. */
  111472. createInnerBlocks(): void;
  111473. /**
  111474. * @hidden
  111475. */
  111476. 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;
  111477. }
  111478. }
  111479. declare module BABYLON {
  111480. /**
  111481. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  111482. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111483. */
  111484. export class Octree<T> {
  111485. /** 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.) */
  111486. maxDepth: number;
  111487. /**
  111488. * Blocks within the octree containing objects
  111489. */
  111490. blocks: Array<OctreeBlock<T>>;
  111491. /**
  111492. * Content stored in the octree
  111493. */
  111494. dynamicContent: T[];
  111495. private _maxBlockCapacity;
  111496. private _selectionContent;
  111497. private _creationFunc;
  111498. /**
  111499. * Creates a octree
  111500. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111501. * @param creationFunc function to be used to instatiate the octree
  111502. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  111503. * @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.)
  111504. */
  111505. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  111506. /** 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.) */
  111507. maxDepth?: number);
  111508. /**
  111509. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  111510. * @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);
  111511. * @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);
  111512. * @param entries meshes to be added to the octree blocks
  111513. */
  111514. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  111515. /**
  111516. * Adds a mesh to the octree
  111517. * @param entry Mesh to add to the octree
  111518. */
  111519. addMesh(entry: T): void;
  111520. /**
  111521. * Remove an element from the octree
  111522. * @param entry defines the element to remove
  111523. */
  111524. removeMesh(entry: T): void;
  111525. /**
  111526. * Selects an array of meshes within the frustum
  111527. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  111528. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  111529. * @returns array of meshes within the frustum
  111530. */
  111531. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  111532. /**
  111533. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  111534. * @param sphereCenter defines the bounding sphere center
  111535. * @param sphereRadius defines the bounding sphere radius
  111536. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111537. * @returns an array of objects that intersect the sphere
  111538. */
  111539. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  111540. /**
  111541. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  111542. * @param ray defines the ray to test with
  111543. * @returns array of intersected objects
  111544. */
  111545. intersectsRay(ray: Ray): SmartArray<T>;
  111546. /**
  111547. * Adds a mesh into the octree block if it intersects the block
  111548. */
  111549. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  111550. /**
  111551. * Adds a submesh into the octree block if it intersects the block
  111552. */
  111553. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  111554. }
  111555. }
  111556. declare module BABYLON {
  111557. interface Scene {
  111558. /**
  111559. * @hidden
  111560. * Backing Filed
  111561. */
  111562. _selectionOctree: Octree<AbstractMesh>;
  111563. /**
  111564. * Gets the octree used to boost mesh selection (picking)
  111565. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111566. */
  111567. selectionOctree: Octree<AbstractMesh>;
  111568. /**
  111569. * Creates or updates the octree used to boost selection (picking)
  111570. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111571. * @param maxCapacity defines the maximum capacity per leaf
  111572. * @param maxDepth defines the maximum depth of the octree
  111573. * @returns an octree of AbstractMesh
  111574. */
  111575. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  111576. }
  111577. interface AbstractMesh {
  111578. /**
  111579. * @hidden
  111580. * Backing Field
  111581. */
  111582. _submeshesOctree: Octree<SubMesh>;
  111583. /**
  111584. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  111585. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  111586. * @param maxCapacity defines the maximum size of each block (64 by default)
  111587. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  111588. * @returns the new octree
  111589. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  111590. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111591. */
  111592. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  111593. }
  111594. /**
  111595. * Defines the octree scene component responsible to manage any octrees
  111596. * in a given scene.
  111597. */
  111598. export class OctreeSceneComponent {
  111599. /**
  111600. * The component name help to identify the component in the list of scene components.
  111601. */
  111602. readonly name: string;
  111603. /**
  111604. * The scene the component belongs to.
  111605. */
  111606. scene: Scene;
  111607. /**
  111608. * Indicates if the meshes have been checked to make sure they are isEnabled()
  111609. */
  111610. readonly checksIsEnabled: boolean;
  111611. /**
  111612. * Creates a new instance of the component for the given scene
  111613. * @param scene Defines the scene to register the component in
  111614. */
  111615. constructor(scene: Scene);
  111616. /**
  111617. * Registers the component in a given scene
  111618. */
  111619. register(): void;
  111620. /**
  111621. * Return the list of active meshes
  111622. * @returns the list of active meshes
  111623. */
  111624. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  111625. /**
  111626. * Return the list of active sub meshes
  111627. * @param mesh The mesh to get the candidates sub meshes from
  111628. * @returns the list of active sub meshes
  111629. */
  111630. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  111631. private _tempRay;
  111632. /**
  111633. * Return the list of sub meshes intersecting with a given local ray
  111634. * @param mesh defines the mesh to find the submesh for
  111635. * @param localRay defines the ray in local space
  111636. * @returns the list of intersecting sub meshes
  111637. */
  111638. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  111639. /**
  111640. * Return the list of sub meshes colliding with a collider
  111641. * @param mesh defines the mesh to find the submesh for
  111642. * @param collider defines the collider to evaluate the collision against
  111643. * @returns the list of colliding sub meshes
  111644. */
  111645. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  111646. /**
  111647. * Rebuilds the elements related to this component in case of
  111648. * context lost for instance.
  111649. */
  111650. rebuild(): void;
  111651. /**
  111652. * Disposes the component and the associated ressources.
  111653. */
  111654. dispose(): void;
  111655. }
  111656. }
  111657. declare module BABYLON {
  111658. /**
  111659. * Renders a layer on top of an existing scene
  111660. */
  111661. export class UtilityLayerRenderer implements IDisposable {
  111662. /** the original scene that will be rendered on top of */
  111663. originalScene: Scene;
  111664. private _pointerCaptures;
  111665. private _lastPointerEvents;
  111666. private static _DefaultUtilityLayer;
  111667. private static _DefaultKeepDepthUtilityLayer;
  111668. private _sharedGizmoLight;
  111669. private _renderCamera;
  111670. /**
  111671. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  111672. * @returns the camera that is used when rendering the utility layer
  111673. */
  111674. getRenderCamera(): Nullable<Camera>;
  111675. /**
  111676. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  111677. * @param cam the camera that should be used when rendering the utility layer
  111678. */
  111679. setRenderCamera(cam: Nullable<Camera>): void;
  111680. /**
  111681. * @hidden
  111682. * Light which used by gizmos to get light shading
  111683. */
  111684. _getSharedGizmoLight(): HemisphericLight;
  111685. /**
  111686. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  111687. */
  111688. pickUtilitySceneFirst: boolean;
  111689. /**
  111690. * 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)
  111691. */
  111692. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  111693. /**
  111694. * 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)
  111695. */
  111696. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  111697. /**
  111698. * The scene that is rendered on top of the original scene
  111699. */
  111700. utilityLayerScene: Scene;
  111701. /**
  111702. * If the utility layer should automatically be rendered on top of existing scene
  111703. */
  111704. shouldRender: boolean;
  111705. /**
  111706. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  111707. */
  111708. onlyCheckPointerDownEvents: boolean;
  111709. /**
  111710. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  111711. */
  111712. processAllEvents: boolean;
  111713. /**
  111714. * Observable raised when the pointer move from the utility layer scene to the main scene
  111715. */
  111716. onPointerOutObservable: Observable<number>;
  111717. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  111718. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  111719. private _afterRenderObserver;
  111720. private _sceneDisposeObserver;
  111721. private _originalPointerObserver;
  111722. /**
  111723. * Instantiates a UtilityLayerRenderer
  111724. * @param originalScene the original scene that will be rendered on top of
  111725. * @param handleEvents boolean indicating if the utility layer should handle events
  111726. */
  111727. constructor(
  111728. /** the original scene that will be rendered on top of */
  111729. originalScene: Scene, handleEvents?: boolean);
  111730. private _notifyObservers;
  111731. /**
  111732. * Renders the utility layers scene on top of the original scene
  111733. */
  111734. render(): void;
  111735. /**
  111736. * Disposes of the renderer
  111737. */
  111738. dispose(): void;
  111739. private _updateCamera;
  111740. }
  111741. }
  111742. declare module BABYLON {
  111743. /**
  111744. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  111745. */
  111746. export class Gizmo implements IDisposable {
  111747. /** The utility layer the gizmo will be added to */
  111748. gizmoLayer: UtilityLayerRenderer;
  111749. /**
  111750. * The root mesh of the gizmo
  111751. */
  111752. _rootMesh: Mesh;
  111753. private _attachedMesh;
  111754. /**
  111755. * Ratio for the scale of the gizmo (Default: 1)
  111756. */
  111757. scaleRatio: number;
  111758. /**
  111759. * If a custom mesh has been set (Default: false)
  111760. */
  111761. protected _customMeshSet: boolean;
  111762. /**
  111763. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  111764. * * When set, interactions will be enabled
  111765. */
  111766. attachedMesh: Nullable<AbstractMesh>;
  111767. /**
  111768. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111769. * @param mesh The mesh to replace the default mesh of the gizmo
  111770. */
  111771. setCustomMesh(mesh: Mesh): void;
  111772. /**
  111773. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  111774. */
  111775. updateGizmoRotationToMatchAttachedMesh: boolean;
  111776. /**
  111777. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  111778. */
  111779. updateGizmoPositionToMatchAttachedMesh: boolean;
  111780. /**
  111781. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  111782. */
  111783. updateScale: boolean;
  111784. protected _interactionsEnabled: boolean;
  111785. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111786. private _beforeRenderObserver;
  111787. private _tempVector;
  111788. /**
  111789. * Creates a gizmo
  111790. * @param gizmoLayer The utility layer the gizmo will be added to
  111791. */
  111792. constructor(
  111793. /** The utility layer the gizmo will be added to */
  111794. gizmoLayer?: UtilityLayerRenderer);
  111795. /**
  111796. * Updates the gizmo to match the attached mesh's position/rotation
  111797. */
  111798. protected _update(): void;
  111799. /**
  111800. * Disposes of the gizmo
  111801. */
  111802. dispose(): void;
  111803. }
  111804. }
  111805. declare module BABYLON {
  111806. /**
  111807. * Single plane drag gizmo
  111808. */
  111809. export class PlaneDragGizmo extends Gizmo {
  111810. /**
  111811. * Drag behavior responsible for the gizmos dragging interactions
  111812. */
  111813. dragBehavior: PointerDragBehavior;
  111814. private _pointerObserver;
  111815. /**
  111816. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111817. */
  111818. snapDistance: number;
  111819. /**
  111820. * Event that fires each time the gizmo snaps to a new location.
  111821. * * snapDistance is the the change in distance
  111822. */
  111823. onSnapObservable: Observable<{
  111824. snapDistance: number;
  111825. }>;
  111826. private _plane;
  111827. private _coloredMaterial;
  111828. private _hoverMaterial;
  111829. private _isEnabled;
  111830. private _parent;
  111831. /** @hidden */
  111832. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  111833. /** @hidden */
  111834. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  111835. /**
  111836. * Creates a PlaneDragGizmo
  111837. * @param gizmoLayer The utility layer the gizmo will be added to
  111838. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  111839. * @param color The color of the gizmo
  111840. */
  111841. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  111842. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111843. /**
  111844. * If the gizmo is enabled
  111845. */
  111846. isEnabled: boolean;
  111847. /**
  111848. * Disposes of the gizmo
  111849. */
  111850. dispose(): void;
  111851. }
  111852. }
  111853. declare module BABYLON {
  111854. /**
  111855. * Gizmo that enables dragging a mesh along 3 axis
  111856. */
  111857. export class PositionGizmo extends Gizmo {
  111858. /**
  111859. * Internal gizmo used for interactions on the x axis
  111860. */
  111861. xGizmo: AxisDragGizmo;
  111862. /**
  111863. * Internal gizmo used for interactions on the y axis
  111864. */
  111865. yGizmo: AxisDragGizmo;
  111866. /**
  111867. * Internal gizmo used for interactions on the z axis
  111868. */
  111869. zGizmo: AxisDragGizmo;
  111870. /**
  111871. * Internal gizmo used for interactions on the yz plane
  111872. */
  111873. xPlaneGizmo: PlaneDragGizmo;
  111874. /**
  111875. * Internal gizmo used for interactions on the xz plane
  111876. */
  111877. yPlaneGizmo: PlaneDragGizmo;
  111878. /**
  111879. * Internal gizmo used for interactions on the xy plane
  111880. */
  111881. zPlaneGizmo: PlaneDragGizmo;
  111882. /**
  111883. * private variables
  111884. */
  111885. private _meshAttached;
  111886. private _updateGizmoRotationToMatchAttachedMesh;
  111887. private _snapDistance;
  111888. private _scaleRatio;
  111889. /** Fires an event when any of it's sub gizmos are dragged */
  111890. onDragStartObservable: Observable<unknown>;
  111891. /** Fires an event when any of it's sub gizmos are released from dragging */
  111892. onDragEndObservable: Observable<unknown>;
  111893. /**
  111894. * If set to true, planar drag is enabled
  111895. */
  111896. private _planarGizmoEnabled;
  111897. attachedMesh: Nullable<AbstractMesh>;
  111898. /**
  111899. * Creates a PositionGizmo
  111900. * @param gizmoLayer The utility layer the gizmo will be added to
  111901. */
  111902. constructor(gizmoLayer?: UtilityLayerRenderer);
  111903. /**
  111904. * If the planar drag gizmo is enabled
  111905. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  111906. */
  111907. planarGizmoEnabled: boolean;
  111908. updateGizmoRotationToMatchAttachedMesh: boolean;
  111909. /**
  111910. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111911. */
  111912. snapDistance: number;
  111913. /**
  111914. * Ratio for the scale of the gizmo (Default: 1)
  111915. */
  111916. scaleRatio: number;
  111917. /**
  111918. * Disposes of the gizmo
  111919. */
  111920. dispose(): void;
  111921. /**
  111922. * CustomMeshes are not supported by this gizmo
  111923. * @param mesh The mesh to replace the default mesh of the gizmo
  111924. */
  111925. setCustomMesh(mesh: Mesh): void;
  111926. }
  111927. }
  111928. declare module BABYLON {
  111929. /**
  111930. * Single axis drag gizmo
  111931. */
  111932. export class AxisDragGizmo extends Gizmo {
  111933. /**
  111934. * Drag behavior responsible for the gizmos dragging interactions
  111935. */
  111936. dragBehavior: PointerDragBehavior;
  111937. private _pointerObserver;
  111938. /**
  111939. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111940. */
  111941. snapDistance: number;
  111942. /**
  111943. * Event that fires each time the gizmo snaps to a new location.
  111944. * * snapDistance is the the change in distance
  111945. */
  111946. onSnapObservable: Observable<{
  111947. snapDistance: number;
  111948. }>;
  111949. private _isEnabled;
  111950. private _parent;
  111951. private _arrow;
  111952. private _coloredMaterial;
  111953. private _hoverMaterial;
  111954. /** @hidden */
  111955. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  111956. /** @hidden */
  111957. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  111958. /**
  111959. * Creates an AxisDragGizmo
  111960. * @param gizmoLayer The utility layer the gizmo will be added to
  111961. * @param dragAxis The axis which the gizmo will be able to drag on
  111962. * @param color The color of the gizmo
  111963. */
  111964. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  111965. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111966. /**
  111967. * If the gizmo is enabled
  111968. */
  111969. isEnabled: boolean;
  111970. /**
  111971. * Disposes of the gizmo
  111972. */
  111973. dispose(): void;
  111974. }
  111975. }
  111976. declare module BABYLON.Debug {
  111977. /**
  111978. * The Axes viewer will show 3 axes in a specific point in space
  111979. */
  111980. export class AxesViewer {
  111981. private _xAxis;
  111982. private _yAxis;
  111983. private _zAxis;
  111984. private _scaleLinesFactor;
  111985. private _instanced;
  111986. /**
  111987. * Gets the hosting scene
  111988. */
  111989. scene: Scene;
  111990. /**
  111991. * Gets or sets a number used to scale line length
  111992. */
  111993. scaleLines: number;
  111994. /** Gets the node hierarchy used to render x-axis */
  111995. readonly xAxis: TransformNode;
  111996. /** Gets the node hierarchy used to render y-axis */
  111997. readonly yAxis: TransformNode;
  111998. /** Gets the node hierarchy used to render z-axis */
  111999. readonly zAxis: TransformNode;
  112000. /**
  112001. * Creates a new AxesViewer
  112002. * @param scene defines the hosting scene
  112003. * @param scaleLines defines a number used to scale line length (1 by default)
  112004. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  112005. * @param xAxis defines the node hierarchy used to render the x-axis
  112006. * @param yAxis defines the node hierarchy used to render the y-axis
  112007. * @param zAxis defines the node hierarchy used to render the z-axis
  112008. */
  112009. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  112010. /**
  112011. * Force the viewer to update
  112012. * @param position defines the position of the viewer
  112013. * @param xaxis defines the x axis of the viewer
  112014. * @param yaxis defines the y axis of the viewer
  112015. * @param zaxis defines the z axis of the viewer
  112016. */
  112017. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  112018. /**
  112019. * Creates an instance of this axes viewer.
  112020. * @returns a new axes viewer with instanced meshes
  112021. */
  112022. createInstance(): AxesViewer;
  112023. /** Releases resources */
  112024. dispose(): void;
  112025. private static _SetRenderingGroupId;
  112026. }
  112027. }
  112028. declare module BABYLON.Debug {
  112029. /**
  112030. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  112031. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  112032. */
  112033. export class BoneAxesViewer extends AxesViewer {
  112034. /**
  112035. * Gets or sets the target mesh where to display the axes viewer
  112036. */
  112037. mesh: Nullable<Mesh>;
  112038. /**
  112039. * Gets or sets the target bone where to display the axes viewer
  112040. */
  112041. bone: Nullable<Bone>;
  112042. /** Gets current position */
  112043. pos: Vector3;
  112044. /** Gets direction of X axis */
  112045. xaxis: Vector3;
  112046. /** Gets direction of Y axis */
  112047. yaxis: Vector3;
  112048. /** Gets direction of Z axis */
  112049. zaxis: Vector3;
  112050. /**
  112051. * Creates a new BoneAxesViewer
  112052. * @param scene defines the hosting scene
  112053. * @param bone defines the target bone
  112054. * @param mesh defines the target mesh
  112055. * @param scaleLines defines a scaling factor for line length (1 by default)
  112056. */
  112057. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  112058. /**
  112059. * Force the viewer to update
  112060. */
  112061. update(): void;
  112062. /** Releases resources */
  112063. dispose(): void;
  112064. }
  112065. }
  112066. declare module BABYLON {
  112067. /**
  112068. * Interface used to define scene explorer extensibility option
  112069. */
  112070. export interface IExplorerExtensibilityOption {
  112071. /**
  112072. * Define the option label
  112073. */
  112074. label: string;
  112075. /**
  112076. * Defines the action to execute on click
  112077. */
  112078. action: (entity: any) => void;
  112079. }
  112080. /**
  112081. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  112082. */
  112083. export interface IExplorerExtensibilityGroup {
  112084. /**
  112085. * Defines a predicate to test if a given type mut be extended
  112086. */
  112087. predicate: (entity: any) => boolean;
  112088. /**
  112089. * Gets the list of options added to a type
  112090. */
  112091. entries: IExplorerExtensibilityOption[];
  112092. }
  112093. /**
  112094. * Interface used to define the options to use to create the Inspector
  112095. */
  112096. export interface IInspectorOptions {
  112097. /**
  112098. * Display in overlay mode (default: false)
  112099. */
  112100. overlay?: boolean;
  112101. /**
  112102. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  112103. */
  112104. globalRoot?: HTMLElement;
  112105. /**
  112106. * Display the Scene explorer
  112107. */
  112108. showExplorer?: boolean;
  112109. /**
  112110. * Display the property inspector
  112111. */
  112112. showInspector?: boolean;
  112113. /**
  112114. * Display in embed mode (both panes on the right)
  112115. */
  112116. embedMode?: boolean;
  112117. /**
  112118. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  112119. */
  112120. handleResize?: boolean;
  112121. /**
  112122. * Allow the panes to popup (default: true)
  112123. */
  112124. enablePopup?: boolean;
  112125. /**
  112126. * Allow the panes to be closed by users (default: true)
  112127. */
  112128. enableClose?: boolean;
  112129. /**
  112130. * Optional list of extensibility entries
  112131. */
  112132. explorerExtensibility?: IExplorerExtensibilityGroup[];
  112133. /**
  112134. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  112135. */
  112136. inspectorURL?: string;
  112137. }
  112138. interface Scene {
  112139. /**
  112140. * @hidden
  112141. * Backing field
  112142. */
  112143. _debugLayer: DebugLayer;
  112144. /**
  112145. * Gets the debug layer (aka Inspector) associated with the scene
  112146. * @see http://doc.babylonjs.com/features/playground_debuglayer
  112147. */
  112148. debugLayer: DebugLayer;
  112149. }
  112150. /**
  112151. * The debug layer (aka Inspector) is the go to tool in order to better understand
  112152. * what is happening in your scene
  112153. * @see http://doc.babylonjs.com/features/playground_debuglayer
  112154. */
  112155. export class DebugLayer {
  112156. /**
  112157. * Define the url to get the inspector script from.
  112158. * By default it uses the babylonjs CDN.
  112159. * @ignoreNaming
  112160. */
  112161. static InspectorURL: string;
  112162. private _scene;
  112163. private BJSINSPECTOR;
  112164. private _onPropertyChangedObservable?;
  112165. /**
  112166. * Observable triggered when a property is changed through the inspector.
  112167. */
  112168. readonly onPropertyChangedObservable: any;
  112169. /**
  112170. * Instantiates a new debug layer.
  112171. * The debug layer (aka Inspector) is the go to tool in order to better understand
  112172. * what is happening in your scene
  112173. * @see http://doc.babylonjs.com/features/playground_debuglayer
  112174. * @param scene Defines the scene to inspect
  112175. */
  112176. constructor(scene: Scene);
  112177. /** Creates the inspector window. */
  112178. private _createInspector;
  112179. /**
  112180. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  112181. * @param entity defines the entity to select
  112182. * @param lineContainerTitle defines the specific block to highlight
  112183. */
  112184. select(entity: any, lineContainerTitle?: string): void;
  112185. /** Get the inspector from bundle or global */
  112186. private _getGlobalInspector;
  112187. /**
  112188. * Get if the inspector is visible or not.
  112189. * @returns true if visible otherwise, false
  112190. */
  112191. isVisible(): boolean;
  112192. /**
  112193. * Hide the inspector and close its window.
  112194. */
  112195. hide(): void;
  112196. /**
  112197. * Launch the debugLayer.
  112198. * @param config Define the configuration of the inspector
  112199. * @return a promise fulfilled when the debug layer is visible
  112200. */
  112201. show(config?: IInspectorOptions): Promise<DebugLayer>;
  112202. }
  112203. }
  112204. declare module BABYLON {
  112205. /**
  112206. * Class containing static functions to help procedurally build meshes
  112207. */
  112208. export class BoxBuilder {
  112209. /**
  112210. * Creates a box mesh
  112211. * * The parameter `size` sets the size (float) of each box side (default 1)
  112212. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  112213. * * 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)
  112214. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  112215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112216. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112218. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  112219. * @param name defines the name of the mesh
  112220. * @param options defines the options used to create the mesh
  112221. * @param scene defines the hosting scene
  112222. * @returns the box mesh
  112223. */
  112224. static CreateBox(name: string, options: {
  112225. size?: number;
  112226. width?: number;
  112227. height?: number;
  112228. depth?: number;
  112229. faceUV?: Vector4[];
  112230. faceColors?: Color4[];
  112231. sideOrientation?: number;
  112232. frontUVs?: Vector4;
  112233. backUVs?: Vector4;
  112234. wrap?: boolean;
  112235. topBaseAt?: number;
  112236. bottomBaseAt?: number;
  112237. updatable?: boolean;
  112238. }, scene?: Nullable<Scene>): Mesh;
  112239. }
  112240. }
  112241. declare module BABYLON {
  112242. /**
  112243. * Class containing static functions to help procedurally build meshes
  112244. */
  112245. export class SphereBuilder {
  112246. /**
  112247. * Creates a sphere mesh
  112248. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  112249. * * 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`)
  112250. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  112251. * * 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
  112252. * * 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)
  112253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112256. * @param name defines the name of the mesh
  112257. * @param options defines the options used to create the mesh
  112258. * @param scene defines the hosting scene
  112259. * @returns the sphere mesh
  112260. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  112261. */
  112262. static CreateSphere(name: string, options: {
  112263. segments?: number;
  112264. diameter?: number;
  112265. diameterX?: number;
  112266. diameterY?: number;
  112267. diameterZ?: number;
  112268. arc?: number;
  112269. slice?: number;
  112270. sideOrientation?: number;
  112271. frontUVs?: Vector4;
  112272. backUVs?: Vector4;
  112273. updatable?: boolean;
  112274. }, scene?: Nullable<Scene>): Mesh;
  112275. }
  112276. }
  112277. declare module BABYLON.Debug {
  112278. /**
  112279. * Used to show the physics impostor around the specific mesh
  112280. */
  112281. export class PhysicsViewer {
  112282. /** @hidden */
  112283. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  112284. /** @hidden */
  112285. protected _meshes: Array<Nullable<AbstractMesh>>;
  112286. /** @hidden */
  112287. protected _scene: Nullable<Scene>;
  112288. /** @hidden */
  112289. protected _numMeshes: number;
  112290. /** @hidden */
  112291. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  112292. private _renderFunction;
  112293. private _utilityLayer;
  112294. private _debugBoxMesh;
  112295. private _debugSphereMesh;
  112296. private _debugCylinderMesh;
  112297. private _debugMaterial;
  112298. private _debugMeshMeshes;
  112299. /**
  112300. * Creates a new PhysicsViewer
  112301. * @param scene defines the hosting scene
  112302. */
  112303. constructor(scene: Scene);
  112304. /** @hidden */
  112305. protected _updateDebugMeshes(): void;
  112306. /**
  112307. * Renders a specified physic impostor
  112308. * @param impostor defines the impostor to render
  112309. * @param targetMesh defines the mesh represented by the impostor
  112310. * @returns the new debug mesh used to render the impostor
  112311. */
  112312. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  112313. /**
  112314. * Hides a specified physic impostor
  112315. * @param impostor defines the impostor to hide
  112316. */
  112317. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  112318. private _getDebugMaterial;
  112319. private _getDebugBoxMesh;
  112320. private _getDebugSphereMesh;
  112321. private _getDebugCylinderMesh;
  112322. private _getDebugMeshMesh;
  112323. private _getDebugMesh;
  112324. /** Releases all resources */
  112325. dispose(): void;
  112326. }
  112327. }
  112328. declare module BABYLON {
  112329. /**
  112330. * Class containing static functions to help procedurally build meshes
  112331. */
  112332. export class LinesBuilder {
  112333. /**
  112334. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  112335. * * 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
  112336. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  112337. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  112338. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  112339. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  112340. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  112341. * * 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
  112342. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  112343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112344. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  112345. * @param name defines the name of the new line system
  112346. * @param options defines the options used to create the line system
  112347. * @param scene defines the hosting scene
  112348. * @returns a new line system mesh
  112349. */
  112350. static CreateLineSystem(name: string, options: {
  112351. lines: Vector3[][];
  112352. updatable?: boolean;
  112353. instance?: Nullable<LinesMesh>;
  112354. colors?: Nullable<Color4[][]>;
  112355. useVertexAlpha?: boolean;
  112356. }, scene: Nullable<Scene>): LinesMesh;
  112357. /**
  112358. * Creates a line mesh
  112359. * 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
  112360. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  112361. * * The parameter `points` is an array successive Vector3
  112362. * * 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
  112363. * * The optional parameter `colors` is an array of successive Color4, one per line point
  112364. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  112365. * * When updating an instance, remember that only point positions can change, not the number of points
  112366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112367. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  112368. * @param name defines the name of the new line system
  112369. * @param options defines the options used to create the line system
  112370. * @param scene defines the hosting scene
  112371. * @returns a new line mesh
  112372. */
  112373. static CreateLines(name: string, options: {
  112374. points: Vector3[];
  112375. updatable?: boolean;
  112376. instance?: Nullable<LinesMesh>;
  112377. colors?: Color4[];
  112378. useVertexAlpha?: boolean;
  112379. }, scene?: Nullable<Scene>): LinesMesh;
  112380. /**
  112381. * Creates a dashed line mesh
  112382. * * 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
  112383. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  112384. * * The parameter `points` is an array successive Vector3
  112385. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  112386. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  112387. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  112388. * * 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
  112389. * * When updating an instance, remember that only point positions can change, not the number of points
  112390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112391. * @param name defines the name of the mesh
  112392. * @param options defines the options used to create the mesh
  112393. * @param scene defines the hosting scene
  112394. * @returns the dashed line mesh
  112395. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  112396. */
  112397. static CreateDashedLines(name: string, options: {
  112398. points: Vector3[];
  112399. dashSize?: number;
  112400. gapSize?: number;
  112401. dashNb?: number;
  112402. updatable?: boolean;
  112403. instance?: LinesMesh;
  112404. }, scene?: Nullable<Scene>): LinesMesh;
  112405. }
  112406. }
  112407. declare module BABYLON {
  112408. /**
  112409. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  112410. * in order to better appreciate the issue one might have.
  112411. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  112412. */
  112413. export class RayHelper {
  112414. /**
  112415. * Defines the ray we are currently tryin to visualize.
  112416. */
  112417. ray: Nullable<Ray>;
  112418. private _renderPoints;
  112419. private _renderLine;
  112420. private _renderFunction;
  112421. private _scene;
  112422. private _updateToMeshFunction;
  112423. private _attachedToMesh;
  112424. private _meshSpaceDirection;
  112425. private _meshSpaceOrigin;
  112426. /**
  112427. * Helper function to create a colored helper in a scene in one line.
  112428. * @param ray Defines the ray we are currently tryin to visualize
  112429. * @param scene Defines the scene the ray is used in
  112430. * @param color Defines the color we want to see the ray in
  112431. * @returns The newly created ray helper.
  112432. */
  112433. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  112434. /**
  112435. * Instantiate a new ray helper.
  112436. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  112437. * in order to better appreciate the issue one might have.
  112438. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  112439. * @param ray Defines the ray we are currently tryin to visualize
  112440. */
  112441. constructor(ray: Ray);
  112442. /**
  112443. * Shows the ray we are willing to debug.
  112444. * @param scene Defines the scene the ray needs to be rendered in
  112445. * @param color Defines the color the ray needs to be rendered in
  112446. */
  112447. show(scene: Scene, color?: Color3): void;
  112448. /**
  112449. * Hides the ray we are debugging.
  112450. */
  112451. hide(): void;
  112452. private _render;
  112453. /**
  112454. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  112455. * @param mesh Defines the mesh we want the helper attached to
  112456. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  112457. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  112458. * @param length Defines the length of the ray
  112459. */
  112460. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  112461. /**
  112462. * Detach the ray helper from the mesh it has previously been attached to.
  112463. */
  112464. detachFromMesh(): void;
  112465. private _updateToMesh;
  112466. /**
  112467. * Dispose the helper and release its associated resources.
  112468. */
  112469. dispose(): void;
  112470. }
  112471. }
  112472. declare module BABYLON.Debug {
  112473. /**
  112474. * Class used to render a debug view of a given skeleton
  112475. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  112476. */
  112477. export class SkeletonViewer {
  112478. /** defines the skeleton to render */
  112479. skeleton: Skeleton;
  112480. /** defines the mesh attached to the skeleton */
  112481. mesh: AbstractMesh;
  112482. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  112483. autoUpdateBonesMatrices: boolean;
  112484. /** defines the rendering group id to use with the viewer */
  112485. renderingGroupId: number;
  112486. /** Gets or sets the color used to render the skeleton */
  112487. color: Color3;
  112488. private _scene;
  112489. private _debugLines;
  112490. private _debugMesh;
  112491. private _isEnabled;
  112492. private _renderFunction;
  112493. private _utilityLayer;
  112494. /**
  112495. * Returns the mesh used to render the bones
  112496. */
  112497. readonly debugMesh: Nullable<LinesMesh>;
  112498. /**
  112499. * Creates a new SkeletonViewer
  112500. * @param skeleton defines the skeleton to render
  112501. * @param mesh defines the mesh attached to the skeleton
  112502. * @param scene defines the hosting scene
  112503. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  112504. * @param renderingGroupId defines the rendering group id to use with the viewer
  112505. */
  112506. constructor(
  112507. /** defines the skeleton to render */
  112508. skeleton: Skeleton,
  112509. /** defines the mesh attached to the skeleton */
  112510. mesh: AbstractMesh, scene: Scene,
  112511. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  112512. autoUpdateBonesMatrices?: boolean,
  112513. /** defines the rendering group id to use with the viewer */
  112514. renderingGroupId?: number);
  112515. /** Gets or sets a boolean indicating if the viewer is enabled */
  112516. isEnabled: boolean;
  112517. private _getBonePosition;
  112518. private _getLinesForBonesWithLength;
  112519. private _getLinesForBonesNoLength;
  112520. /** Update the viewer to sync with current skeleton state */
  112521. update(): void;
  112522. /** Release associated resources */
  112523. dispose(): void;
  112524. }
  112525. }
  112526. declare module BABYLON {
  112527. /**
  112528. * Options to create the null engine
  112529. */
  112530. export class NullEngineOptions {
  112531. /**
  112532. * Render width (Default: 512)
  112533. */
  112534. renderWidth: number;
  112535. /**
  112536. * Render height (Default: 256)
  112537. */
  112538. renderHeight: number;
  112539. /**
  112540. * Texture size (Default: 512)
  112541. */
  112542. textureSize: number;
  112543. /**
  112544. * If delta time between frames should be constant
  112545. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112546. */
  112547. deterministicLockstep: boolean;
  112548. /**
  112549. * Maximum about of steps between frames (Default: 4)
  112550. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112551. */
  112552. lockstepMaxSteps: number;
  112553. }
  112554. /**
  112555. * The null engine class provides support for headless version of babylon.js.
  112556. * This can be used in server side scenario or for testing purposes
  112557. */
  112558. export class NullEngine extends Engine {
  112559. private _options;
  112560. /**
  112561. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  112562. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112563. * @returns true if engine is in deterministic lock step mode
  112564. */
  112565. isDeterministicLockStep(): boolean;
  112566. /**
  112567. * Gets the max steps when engine is running in deterministic lock step
  112568. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112569. * @returns the max steps
  112570. */
  112571. getLockstepMaxSteps(): number;
  112572. /**
  112573. * Gets the current hardware scaling level.
  112574. * By default the hardware scaling level is computed from the window device ratio.
  112575. * 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.
  112576. * @returns a number indicating the current hardware scaling level
  112577. */
  112578. getHardwareScalingLevel(): number;
  112579. constructor(options?: NullEngineOptions);
  112580. /**
  112581. * Creates a vertex buffer
  112582. * @param vertices the data for the vertex buffer
  112583. * @returns the new WebGL static buffer
  112584. */
  112585. createVertexBuffer(vertices: FloatArray): DataBuffer;
  112586. /**
  112587. * Creates a new index buffer
  112588. * @param indices defines the content of the index buffer
  112589. * @param updatable defines if the index buffer must be updatable
  112590. * @returns a new webGL buffer
  112591. */
  112592. createIndexBuffer(indices: IndicesArray): DataBuffer;
  112593. /**
  112594. * Clear the current render buffer or the current render target (if any is set up)
  112595. * @param color defines the color to use
  112596. * @param backBuffer defines if the back buffer must be cleared
  112597. * @param depth defines if the depth buffer must be cleared
  112598. * @param stencil defines if the stencil buffer must be cleared
  112599. */
  112600. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112601. /**
  112602. * Gets the current render width
  112603. * @param useScreen defines if screen size must be used (or the current render target if any)
  112604. * @returns a number defining the current render width
  112605. */
  112606. getRenderWidth(useScreen?: boolean): number;
  112607. /**
  112608. * Gets the current render height
  112609. * @param useScreen defines if screen size must be used (or the current render target if any)
  112610. * @returns a number defining the current render height
  112611. */
  112612. getRenderHeight(useScreen?: boolean): number;
  112613. /**
  112614. * Set the WebGL's viewport
  112615. * @param viewport defines the viewport element to be used
  112616. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  112617. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  112618. */
  112619. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  112620. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  112621. /**
  112622. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  112623. * @param pipelineContext defines the pipeline context to use
  112624. * @param uniformsNames defines the list of uniform names
  112625. * @returns an array of webGL uniform locations
  112626. */
  112627. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  112628. /**
  112629. * Gets the lsit of active attributes for a given webGL program
  112630. * @param pipelineContext defines the pipeline context to use
  112631. * @param attributesNames defines the list of attribute names to get
  112632. * @returns an array of indices indicating the offset of each attribute
  112633. */
  112634. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112635. /**
  112636. * Binds an effect to the webGL context
  112637. * @param effect defines the effect to bind
  112638. */
  112639. bindSamplers(effect: Effect): void;
  112640. /**
  112641. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  112642. * @param effect defines the effect to activate
  112643. */
  112644. enableEffect(effect: Effect): void;
  112645. /**
  112646. * Set various states to the webGL context
  112647. * @param culling defines backface culling state
  112648. * @param zOffset defines the value to apply to zOffset (0 by default)
  112649. * @param force defines if states must be applied even if cache is up to date
  112650. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  112651. */
  112652. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  112653. /**
  112654. * Set the value of an uniform to an array of int32
  112655. * @param uniform defines the webGL uniform location where to store the value
  112656. * @param array defines the array of int32 to store
  112657. */
  112658. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  112659. /**
  112660. * Set the value of an uniform to an array of int32 (stored as vec2)
  112661. * @param uniform defines the webGL uniform location where to store the value
  112662. * @param array defines the array of int32 to store
  112663. */
  112664. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  112665. /**
  112666. * Set the value of an uniform to an array of int32 (stored as vec3)
  112667. * @param uniform defines the webGL uniform location where to store the value
  112668. * @param array defines the array of int32 to store
  112669. */
  112670. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  112671. /**
  112672. * Set the value of an uniform to an array of int32 (stored as vec4)
  112673. * @param uniform defines the webGL uniform location where to store the value
  112674. * @param array defines the array of int32 to store
  112675. */
  112676. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  112677. /**
  112678. * Set the value of an uniform to an array of float32
  112679. * @param uniform defines the webGL uniform location where to store the value
  112680. * @param array defines the array of float32 to store
  112681. */
  112682. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  112683. /**
  112684. * Set the value of an uniform to an array of float32 (stored as vec2)
  112685. * @param uniform defines the webGL uniform location where to store the value
  112686. * @param array defines the array of float32 to store
  112687. */
  112688. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  112689. /**
  112690. * Set the value of an uniform to an array of float32 (stored as vec3)
  112691. * @param uniform defines the webGL uniform location where to store the value
  112692. * @param array defines the array of float32 to store
  112693. */
  112694. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  112695. /**
  112696. * Set the value of an uniform to an array of float32 (stored as vec4)
  112697. * @param uniform defines the webGL uniform location where to store the value
  112698. * @param array defines the array of float32 to store
  112699. */
  112700. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  112701. /**
  112702. * Set the value of an uniform to an array of number
  112703. * @param uniform defines the webGL uniform location where to store the value
  112704. * @param array defines the array of number to store
  112705. */
  112706. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  112707. /**
  112708. * Set the value of an uniform to an array of number (stored as vec2)
  112709. * @param uniform defines the webGL uniform location where to store the value
  112710. * @param array defines the array of number to store
  112711. */
  112712. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  112713. /**
  112714. * Set the value of an uniform to an array of number (stored as vec3)
  112715. * @param uniform defines the webGL uniform location where to store the value
  112716. * @param array defines the array of number to store
  112717. */
  112718. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  112719. /**
  112720. * Set the value of an uniform to an array of number (stored as vec4)
  112721. * @param uniform defines the webGL uniform location where to store the value
  112722. * @param array defines the array of number to store
  112723. */
  112724. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  112725. /**
  112726. * Set the value of an uniform to an array of float32 (stored as matrices)
  112727. * @param uniform defines the webGL uniform location where to store the value
  112728. * @param matrices defines the array of float32 to store
  112729. */
  112730. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  112731. /**
  112732. * Set the value of an uniform to a matrix (3x3)
  112733. * @param uniform defines the webGL uniform location where to store the value
  112734. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  112735. */
  112736. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112737. /**
  112738. * Set the value of an uniform to a matrix (2x2)
  112739. * @param uniform defines the webGL uniform location where to store the value
  112740. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  112741. */
  112742. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112743. /**
  112744. * Set the value of an uniform to a number (float)
  112745. * @param uniform defines the webGL uniform location where to store the value
  112746. * @param value defines the float number to store
  112747. */
  112748. setFloat(uniform: WebGLUniformLocation, value: number): void;
  112749. /**
  112750. * Set the value of an uniform to a vec2
  112751. * @param uniform defines the webGL uniform location where to store the value
  112752. * @param x defines the 1st component of the value
  112753. * @param y defines the 2nd component of the value
  112754. */
  112755. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  112756. /**
  112757. * Set the value of an uniform to a vec3
  112758. * @param uniform defines the webGL uniform location where to store the value
  112759. * @param x defines the 1st component of the value
  112760. * @param y defines the 2nd component of the value
  112761. * @param z defines the 3rd component of the value
  112762. */
  112763. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  112764. /**
  112765. * Set the value of an uniform to a boolean
  112766. * @param uniform defines the webGL uniform location where to store the value
  112767. * @param bool defines the boolean to store
  112768. */
  112769. setBool(uniform: WebGLUniformLocation, bool: number): void;
  112770. /**
  112771. * Set the value of an uniform to a vec4
  112772. * @param uniform defines the webGL uniform location where to store the value
  112773. * @param x defines the 1st component of the value
  112774. * @param y defines the 2nd component of the value
  112775. * @param z defines the 3rd component of the value
  112776. * @param w defines the 4th component of the value
  112777. */
  112778. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  112779. /**
  112780. * Sets the current alpha mode
  112781. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  112782. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  112783. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112784. */
  112785. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  112786. /**
  112787. * Bind webGl buffers directly to the webGL context
  112788. * @param vertexBuffers defines the vertex buffer to bind
  112789. * @param indexBuffer defines the index buffer to bind
  112790. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  112791. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  112792. * @param effect defines the effect associated with the vertex buffer
  112793. */
  112794. bindBuffers(vertexBuffers: {
  112795. [key: string]: VertexBuffer;
  112796. }, indexBuffer: DataBuffer, effect: Effect): void;
  112797. /**
  112798. * Force the entire cache to be cleared
  112799. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  112800. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  112801. */
  112802. wipeCaches(bruteForce?: boolean): void;
  112803. /**
  112804. * Send a draw order
  112805. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112806. * @param indexStart defines the starting index
  112807. * @param indexCount defines the number of index to draw
  112808. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112809. */
  112810. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  112811. /**
  112812. * Draw a list of indexed primitives
  112813. * @param fillMode defines the primitive to use
  112814. * @param indexStart defines the starting index
  112815. * @param indexCount defines the number of index to draw
  112816. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112817. */
  112818. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112819. /**
  112820. * Draw a list of unindexed primitives
  112821. * @param fillMode defines the primitive to use
  112822. * @param verticesStart defines the index of first vertex to draw
  112823. * @param verticesCount defines the count of vertices to draw
  112824. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112825. */
  112826. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112827. /** @hidden */
  112828. _createTexture(): WebGLTexture;
  112829. /** @hidden */
  112830. _releaseTexture(texture: InternalTexture): void;
  112831. /**
  112832. * Usually called from Texture.ts.
  112833. * Passed information to create a WebGLTexture
  112834. * @param urlArg defines a value which contains one of the following:
  112835. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112836. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112837. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112838. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112839. * @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)
  112840. * @param scene needed for loading to the correct scene
  112841. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  112842. * @param onLoad optional callback to be called upon successful completion
  112843. * @param onError optional callback to be called upon failure
  112844. * @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
  112845. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112846. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112847. * @param forcedExtension defines the extension to use to pick the right loader
  112848. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  112849. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112850. */
  112851. 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;
  112852. /**
  112853. * Creates a new render target texture
  112854. * @param size defines the size of the texture
  112855. * @param options defines the options used to create the texture
  112856. * @returns a new render target texture stored in an InternalTexture
  112857. */
  112858. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  112859. /**
  112860. * Update the sampling mode of a given texture
  112861. * @param samplingMode defines the required sampling mode
  112862. * @param texture defines the texture to update
  112863. */
  112864. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  112865. /**
  112866. * Binds the frame buffer to the specified texture.
  112867. * @param texture The texture to render to or null for the default canvas
  112868. * @param faceIndex The face of the texture to render to in case of cube texture
  112869. * @param requiredWidth The width of the target to render to
  112870. * @param requiredHeight The height of the target to render to
  112871. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  112872. * @param depthStencilTexture The depth stencil texture to use to render
  112873. * @param lodLevel defines le lod level to bind to the frame buffer
  112874. */
  112875. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  112876. /**
  112877. * Unbind the current render target texture from the webGL context
  112878. * @param texture defines the render target texture to unbind
  112879. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112880. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112881. */
  112882. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112883. /**
  112884. * Creates a dynamic vertex buffer
  112885. * @param vertices the data for the dynamic vertex buffer
  112886. * @returns the new WebGL dynamic buffer
  112887. */
  112888. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  112889. /**
  112890. * Update the content of a dynamic texture
  112891. * @param texture defines the texture to update
  112892. * @param canvas defines the canvas containing the source
  112893. * @param invertY defines if data must be stored with Y axis inverted
  112894. * @param premulAlpha defines if alpha is stored as premultiplied
  112895. * @param format defines the format of the data
  112896. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  112897. */
  112898. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  112899. /**
  112900. * Gets a boolean indicating if all created effects are ready
  112901. * @returns true if all effects are ready
  112902. */
  112903. areAllEffectsReady(): boolean;
  112904. /**
  112905. * @hidden
  112906. * Get the current error code of the webGL context
  112907. * @returns the error code
  112908. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  112909. */
  112910. getError(): number;
  112911. /** @hidden */
  112912. _getUnpackAlignement(): number;
  112913. /** @hidden */
  112914. _unpackFlipY(value: boolean): void;
  112915. /**
  112916. * Update a dynamic index buffer
  112917. * @param indexBuffer defines the target index buffer
  112918. * @param indices defines the data to update
  112919. * @param offset defines the offset in the target index buffer where update should start
  112920. */
  112921. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  112922. /**
  112923. * Updates a dynamic vertex buffer.
  112924. * @param vertexBuffer the vertex buffer to update
  112925. * @param vertices the data used to update the vertex buffer
  112926. * @param byteOffset the byte offset of the data (optional)
  112927. * @param byteLength the byte length of the data (optional)
  112928. */
  112929. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  112930. /** @hidden */
  112931. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  112932. /** @hidden */
  112933. _bindTexture(channel: number, texture: InternalTexture): void;
  112934. protected _deleteBuffer(buffer: WebGLBuffer): void;
  112935. /**
  112936. * 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
  112937. */
  112938. releaseEffects(): void;
  112939. displayLoadingUI(): void;
  112940. hideLoadingUI(): void;
  112941. /** @hidden */
  112942. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112943. /** @hidden */
  112944. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112945. /** @hidden */
  112946. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112947. /** @hidden */
  112948. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  112949. }
  112950. }
  112951. declare module BABYLON {
  112952. /** @hidden */
  112953. export class _OcclusionDataStorage {
  112954. /** @hidden */
  112955. occlusionInternalRetryCounter: number;
  112956. /** @hidden */
  112957. isOcclusionQueryInProgress: boolean;
  112958. /** @hidden */
  112959. isOccluded: boolean;
  112960. /** @hidden */
  112961. occlusionRetryCount: number;
  112962. /** @hidden */
  112963. occlusionType: number;
  112964. /** @hidden */
  112965. occlusionQueryAlgorithmType: number;
  112966. }
  112967. interface Engine {
  112968. /**
  112969. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  112970. * @return the new query
  112971. */
  112972. createQuery(): WebGLQuery;
  112973. /**
  112974. * Delete and release a webGL query
  112975. * @param query defines the query to delete
  112976. * @return the current engine
  112977. */
  112978. deleteQuery(query: WebGLQuery): Engine;
  112979. /**
  112980. * Check if a given query has resolved and got its value
  112981. * @param query defines the query to check
  112982. * @returns true if the query got its value
  112983. */
  112984. isQueryResultAvailable(query: WebGLQuery): boolean;
  112985. /**
  112986. * Gets the value of a given query
  112987. * @param query defines the query to check
  112988. * @returns the value of the query
  112989. */
  112990. getQueryResult(query: WebGLQuery): number;
  112991. /**
  112992. * Initiates an occlusion query
  112993. * @param algorithmType defines the algorithm to use
  112994. * @param query defines the query to use
  112995. * @returns the current engine
  112996. * @see http://doc.babylonjs.com/features/occlusionquery
  112997. */
  112998. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  112999. /**
  113000. * Ends an occlusion query
  113001. * @see http://doc.babylonjs.com/features/occlusionquery
  113002. * @param algorithmType defines the algorithm to use
  113003. * @returns the current engine
  113004. */
  113005. endOcclusionQuery(algorithmType: number): Engine;
  113006. /**
  113007. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  113008. * Please note that only one query can be issued at a time
  113009. * @returns a time token used to track the time span
  113010. */
  113011. startTimeQuery(): Nullable<_TimeToken>;
  113012. /**
  113013. * Ends a time query
  113014. * @param token defines the token used to measure the time span
  113015. * @returns the time spent (in ns)
  113016. */
  113017. endTimeQuery(token: _TimeToken): int;
  113018. /** @hidden */
  113019. _currentNonTimestampToken: Nullable<_TimeToken>;
  113020. /** @hidden */
  113021. _createTimeQuery(): WebGLQuery;
  113022. /** @hidden */
  113023. _deleteTimeQuery(query: WebGLQuery): void;
  113024. /** @hidden */
  113025. _getGlAlgorithmType(algorithmType: number): number;
  113026. /** @hidden */
  113027. _getTimeQueryResult(query: WebGLQuery): any;
  113028. /** @hidden */
  113029. _getTimeQueryAvailability(query: WebGLQuery): any;
  113030. }
  113031. interface AbstractMesh {
  113032. /**
  113033. * Backing filed
  113034. * @hidden
  113035. */
  113036. __occlusionDataStorage: _OcclusionDataStorage;
  113037. /**
  113038. * Access property
  113039. * @hidden
  113040. */
  113041. _occlusionDataStorage: _OcclusionDataStorage;
  113042. /**
  113043. * 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.
  113044. * The default value is -1 which means don't break the query and wait till the result
  113045. * @see http://doc.babylonjs.com/features/occlusionquery
  113046. */
  113047. occlusionRetryCount: number;
  113048. /**
  113049. * 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:
  113050. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  113051. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  113052. * * 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.
  113053. * @see http://doc.babylonjs.com/features/occlusionquery
  113054. */
  113055. occlusionType: number;
  113056. /**
  113057. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  113058. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  113059. * * 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.
  113060. * @see http://doc.babylonjs.com/features/occlusionquery
  113061. */
  113062. occlusionQueryAlgorithmType: number;
  113063. /**
  113064. * 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
  113065. * @see http://doc.babylonjs.com/features/occlusionquery
  113066. */
  113067. isOccluded: boolean;
  113068. /**
  113069. * Flag to check the progress status of the query
  113070. * @see http://doc.babylonjs.com/features/occlusionquery
  113071. */
  113072. isOcclusionQueryInProgress: boolean;
  113073. }
  113074. }
  113075. declare module BABYLON {
  113076. /** @hidden */
  113077. export var _forceTransformFeedbackToBundle: boolean;
  113078. interface Engine {
  113079. /**
  113080. * Creates a webGL transform feedback object
  113081. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  113082. * @returns the webGL transform feedback object
  113083. */
  113084. createTransformFeedback(): WebGLTransformFeedback;
  113085. /**
  113086. * Delete a webGL transform feedback object
  113087. * @param value defines the webGL transform feedback object to delete
  113088. */
  113089. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  113090. /**
  113091. * Bind a webGL transform feedback object to the webgl context
  113092. * @param value defines the webGL transform feedback object to bind
  113093. */
  113094. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  113095. /**
  113096. * Begins a transform feedback operation
  113097. * @param usePoints defines if points or triangles must be used
  113098. */
  113099. beginTransformFeedback(usePoints: boolean): void;
  113100. /**
  113101. * Ends a transform feedback operation
  113102. */
  113103. endTransformFeedback(): void;
  113104. /**
  113105. * Specify the varyings to use with transform feedback
  113106. * @param program defines the associated webGL program
  113107. * @param value defines the list of strings representing the varying names
  113108. */
  113109. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  113110. /**
  113111. * Bind a webGL buffer for a transform feedback operation
  113112. * @param value defines the webGL buffer to bind
  113113. */
  113114. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  113115. }
  113116. }
  113117. declare module BABYLON {
  113118. /**
  113119. * Creation options of the multi render target texture.
  113120. */
  113121. export interface IMultiRenderTargetOptions {
  113122. /**
  113123. * Define if the texture needs to create mip maps after render.
  113124. */
  113125. generateMipMaps?: boolean;
  113126. /**
  113127. * Define the types of all the draw buffers we want to create
  113128. */
  113129. types?: number[];
  113130. /**
  113131. * Define the sampling modes of all the draw buffers we want to create
  113132. */
  113133. samplingModes?: number[];
  113134. /**
  113135. * Define if a depth buffer is required
  113136. */
  113137. generateDepthBuffer?: boolean;
  113138. /**
  113139. * Define if a stencil buffer is required
  113140. */
  113141. generateStencilBuffer?: boolean;
  113142. /**
  113143. * Define if a depth texture is required instead of a depth buffer
  113144. */
  113145. generateDepthTexture?: boolean;
  113146. /**
  113147. * Define the number of desired draw buffers
  113148. */
  113149. textureCount?: number;
  113150. /**
  113151. * Define if aspect ratio should be adapted to the texture or stay the scene one
  113152. */
  113153. doNotChangeAspectRatio?: boolean;
  113154. /**
  113155. * Define the default type of the buffers we are creating
  113156. */
  113157. defaultType?: number;
  113158. }
  113159. /**
  113160. * A multi render target, like a render target provides the ability to render to a texture.
  113161. * Unlike the render target, it can render to several draw buffers in one draw.
  113162. * This is specially interesting in deferred rendering or for any effects requiring more than
  113163. * just one color from a single pass.
  113164. */
  113165. export class MultiRenderTarget extends RenderTargetTexture {
  113166. private _internalTextures;
  113167. private _textures;
  113168. private _multiRenderTargetOptions;
  113169. /**
  113170. * Get if draw buffers are currently supported by the used hardware and browser.
  113171. */
  113172. readonly isSupported: boolean;
  113173. /**
  113174. * Get the list of textures generated by the multi render target.
  113175. */
  113176. readonly textures: Texture[];
  113177. /**
  113178. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  113179. */
  113180. readonly depthTexture: Texture;
  113181. /**
  113182. * Set the wrapping mode on U of all the textures we are rendering to.
  113183. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  113184. */
  113185. wrapU: number;
  113186. /**
  113187. * Set the wrapping mode on V of all the textures we are rendering to.
  113188. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  113189. */
  113190. wrapV: number;
  113191. /**
  113192. * Instantiate a new multi render target texture.
  113193. * A multi render target, like a render target provides the ability to render to a texture.
  113194. * Unlike the render target, it can render to several draw buffers in one draw.
  113195. * This is specially interesting in deferred rendering or for any effects requiring more than
  113196. * just one color from a single pass.
  113197. * @param name Define the name of the texture
  113198. * @param size Define the size of the buffers to render to
  113199. * @param count Define the number of target we are rendering into
  113200. * @param scene Define the scene the texture belongs to
  113201. * @param options Define the options used to create the multi render target
  113202. */
  113203. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  113204. /** @hidden */
  113205. _rebuild(): void;
  113206. private _createInternalTextures;
  113207. private _createTextures;
  113208. /**
  113209. * Define the number of samples used if MSAA is enabled.
  113210. */
  113211. samples: number;
  113212. /**
  113213. * Resize all the textures in the multi render target.
  113214. * Be carrefull as it will recreate all the data in the new texture.
  113215. * @param size Define the new size
  113216. */
  113217. resize(size: any): void;
  113218. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  113219. /**
  113220. * Dispose the render targets and their associated resources
  113221. */
  113222. dispose(): void;
  113223. /**
  113224. * Release all the underlying texture used as draw buffers.
  113225. */
  113226. releaseInternalTextures(): void;
  113227. }
  113228. }
  113229. declare module BABYLON {
  113230. interface ThinEngine {
  113231. /**
  113232. * Unbind a list of render target textures from the webGL context
  113233. * This is used only when drawBuffer extension or webGL2 are active
  113234. * @param textures defines the render target textures to unbind
  113235. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  113236. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  113237. */
  113238. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  113239. /**
  113240. * Create a multi render target texture
  113241. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  113242. * @param size defines the size of the texture
  113243. * @param options defines the creation options
  113244. * @returns the cube texture as an InternalTexture
  113245. */
  113246. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  113247. /**
  113248. * Update the sample count for a given multiple render target texture
  113249. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  113250. * @param textures defines the textures to update
  113251. * @param samples defines the sample count to set
  113252. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  113253. */
  113254. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  113255. }
  113256. }
  113257. declare module BABYLON {
  113258. /**
  113259. * Class used to define an additional view for the engine
  113260. * @see https://doc.babylonjs.com/how_to/multi_canvases
  113261. */
  113262. export class EngineView {
  113263. /** Defines the canvas where to render the view */
  113264. target: HTMLCanvasElement;
  113265. /** Defines an optional camera used to render the view (will use active camera else) */
  113266. camera?: Camera;
  113267. }
  113268. interface Engine {
  113269. /**
  113270. * Gets or sets the HTML element to use for attaching events
  113271. */
  113272. inputElement: Nullable<HTMLElement>;
  113273. /**
  113274. * Gets the current engine view
  113275. * @see https://doc.babylonjs.com/how_to/multi_canvases
  113276. */
  113277. activeView: Nullable<EngineView>;
  113278. /** Gets or sets the list of views */
  113279. views: EngineView[];
  113280. /**
  113281. * Register a new child canvas
  113282. * @param canvas defines the canvas to register
  113283. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  113284. * @returns the associated view
  113285. */
  113286. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  113287. /**
  113288. * Remove a registered child canvas
  113289. * @param canvas defines the canvas to remove
  113290. * @returns the current engine
  113291. */
  113292. unRegisterView(canvas: HTMLCanvasElement): Engine;
  113293. }
  113294. }
  113295. declare module BABYLON {
  113296. /**
  113297. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  113298. */
  113299. export interface CubeMapInfo {
  113300. /**
  113301. * The pixel array for the front face.
  113302. * This is stored in format, left to right, up to down format.
  113303. */
  113304. front: Nullable<ArrayBufferView>;
  113305. /**
  113306. * The pixel array for the back face.
  113307. * This is stored in format, left to right, up to down format.
  113308. */
  113309. back: Nullable<ArrayBufferView>;
  113310. /**
  113311. * The pixel array for the left face.
  113312. * This is stored in format, left to right, up to down format.
  113313. */
  113314. left: Nullable<ArrayBufferView>;
  113315. /**
  113316. * The pixel array for the right face.
  113317. * This is stored in format, left to right, up to down format.
  113318. */
  113319. right: Nullable<ArrayBufferView>;
  113320. /**
  113321. * The pixel array for the up face.
  113322. * This is stored in format, left to right, up to down format.
  113323. */
  113324. up: Nullable<ArrayBufferView>;
  113325. /**
  113326. * The pixel array for the down face.
  113327. * This is stored in format, left to right, up to down format.
  113328. */
  113329. down: Nullable<ArrayBufferView>;
  113330. /**
  113331. * The size of the cubemap stored.
  113332. *
  113333. * Each faces will be size * size pixels.
  113334. */
  113335. size: number;
  113336. /**
  113337. * The format of the texture.
  113338. *
  113339. * RGBA, RGB.
  113340. */
  113341. format: number;
  113342. /**
  113343. * The type of the texture data.
  113344. *
  113345. * UNSIGNED_INT, FLOAT.
  113346. */
  113347. type: number;
  113348. /**
  113349. * Specifies whether the texture is in gamma space.
  113350. */
  113351. gammaSpace: boolean;
  113352. }
  113353. /**
  113354. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  113355. */
  113356. export class PanoramaToCubeMapTools {
  113357. private static FACE_FRONT;
  113358. private static FACE_BACK;
  113359. private static FACE_RIGHT;
  113360. private static FACE_LEFT;
  113361. private static FACE_DOWN;
  113362. private static FACE_UP;
  113363. /**
  113364. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  113365. *
  113366. * @param float32Array The source data.
  113367. * @param inputWidth The width of the input panorama.
  113368. * @param inputHeight The height of the input panorama.
  113369. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  113370. * @return The cubemap data
  113371. */
  113372. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  113373. private static CreateCubemapTexture;
  113374. private static CalcProjectionSpherical;
  113375. }
  113376. }
  113377. declare module BABYLON {
  113378. /**
  113379. * Helper class dealing with the extraction of spherical polynomial dataArray
  113380. * from a cube map.
  113381. */
  113382. export class CubeMapToSphericalPolynomialTools {
  113383. private static FileFaces;
  113384. /**
  113385. * Converts a texture to the according Spherical Polynomial data.
  113386. * This extracts the first 3 orders only as they are the only one used in the lighting.
  113387. *
  113388. * @param texture The texture to extract the information from.
  113389. * @return The Spherical Polynomial data.
  113390. */
  113391. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  113392. /**
  113393. * Converts a cubemap to the according Spherical Polynomial data.
  113394. * This extracts the first 3 orders only as they are the only one used in the lighting.
  113395. *
  113396. * @param cubeInfo The Cube map to extract the information from.
  113397. * @return The Spherical Polynomial data.
  113398. */
  113399. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  113400. }
  113401. }
  113402. declare module BABYLON {
  113403. interface BaseTexture {
  113404. /**
  113405. * Get the polynomial representation of the texture data.
  113406. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  113407. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  113408. */
  113409. sphericalPolynomial: Nullable<SphericalPolynomial>;
  113410. }
  113411. }
  113412. declare module BABYLON {
  113413. /** @hidden */
  113414. export var rgbdEncodePixelShader: {
  113415. name: string;
  113416. shader: string;
  113417. };
  113418. }
  113419. declare module BABYLON {
  113420. /** @hidden */
  113421. export var rgbdDecodePixelShader: {
  113422. name: string;
  113423. shader: string;
  113424. };
  113425. }
  113426. declare module BABYLON {
  113427. /**
  113428. * Raw texture data and descriptor sufficient for WebGL texture upload
  113429. */
  113430. export interface EnvironmentTextureInfo {
  113431. /**
  113432. * Version of the environment map
  113433. */
  113434. version: number;
  113435. /**
  113436. * Width of image
  113437. */
  113438. width: number;
  113439. /**
  113440. * Irradiance information stored in the file.
  113441. */
  113442. irradiance: any;
  113443. /**
  113444. * Specular information stored in the file.
  113445. */
  113446. specular: any;
  113447. }
  113448. /**
  113449. * Defines One Image in the file. It requires only the position in the file
  113450. * as well as the length.
  113451. */
  113452. interface BufferImageData {
  113453. /**
  113454. * Length of the image data.
  113455. */
  113456. length: number;
  113457. /**
  113458. * Position of the data from the null terminator delimiting the end of the JSON.
  113459. */
  113460. position: number;
  113461. }
  113462. /**
  113463. * Defines the specular data enclosed in the file.
  113464. * This corresponds to the version 1 of the data.
  113465. */
  113466. export interface EnvironmentTextureSpecularInfoV1 {
  113467. /**
  113468. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  113469. */
  113470. specularDataPosition?: number;
  113471. /**
  113472. * This contains all the images data needed to reconstruct the cubemap.
  113473. */
  113474. mipmaps: Array<BufferImageData>;
  113475. /**
  113476. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  113477. */
  113478. lodGenerationScale: number;
  113479. }
  113480. /**
  113481. * Sets of helpers addressing the serialization and deserialization of environment texture
  113482. * stored in a BabylonJS env file.
  113483. * Those files are usually stored as .env files.
  113484. */
  113485. export class EnvironmentTextureTools {
  113486. /**
  113487. * Magic number identifying the env file.
  113488. */
  113489. private static _MagicBytes;
  113490. /**
  113491. * Gets the environment info from an env file.
  113492. * @param data The array buffer containing the .env bytes.
  113493. * @returns the environment file info (the json header) if successfully parsed.
  113494. */
  113495. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  113496. /**
  113497. * Creates an environment texture from a loaded cube texture.
  113498. * @param texture defines the cube texture to convert in env file
  113499. * @return a promise containing the environment data if succesfull.
  113500. */
  113501. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  113502. /**
  113503. * Creates a JSON representation of the spherical data.
  113504. * @param texture defines the texture containing the polynomials
  113505. * @return the JSON representation of the spherical info
  113506. */
  113507. private static _CreateEnvTextureIrradiance;
  113508. /**
  113509. * Creates the ArrayBufferViews used for initializing environment texture image data.
  113510. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  113511. * @param info parameters that determine what views will be created for accessing the underlying buffer
  113512. * @return the views described by info providing access to the underlying buffer
  113513. */
  113514. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  113515. /**
  113516. * Uploads the texture info contained in the env file to the GPU.
  113517. * @param texture defines the internal texture to upload to
  113518. * @param arrayBuffer defines the buffer cotaining the data to load
  113519. * @param info defines the texture info retrieved through the GetEnvInfo method
  113520. * @returns a promise
  113521. */
  113522. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  113523. private static _OnImageReadyAsync;
  113524. /**
  113525. * Uploads the levels of image data to the GPU.
  113526. * @param texture defines the internal texture to upload to
  113527. * @param imageData defines the array buffer views of image data [mipmap][face]
  113528. * @returns a promise
  113529. */
  113530. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  113531. /**
  113532. * Uploads spherical polynomials information to the texture.
  113533. * @param texture defines the texture we are trying to upload the information to
  113534. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  113535. */
  113536. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  113537. /** @hidden */
  113538. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  113539. }
  113540. }
  113541. declare module BABYLON {
  113542. /**
  113543. * Contains position and normal vectors for a vertex
  113544. */
  113545. export class PositionNormalVertex {
  113546. /** the position of the vertex (defaut: 0,0,0) */
  113547. position: Vector3;
  113548. /** the normal of the vertex (defaut: 0,1,0) */
  113549. normal: Vector3;
  113550. /**
  113551. * Creates a PositionNormalVertex
  113552. * @param position the position of the vertex (defaut: 0,0,0)
  113553. * @param normal the normal of the vertex (defaut: 0,1,0)
  113554. */
  113555. constructor(
  113556. /** the position of the vertex (defaut: 0,0,0) */
  113557. position?: Vector3,
  113558. /** the normal of the vertex (defaut: 0,1,0) */
  113559. normal?: Vector3);
  113560. /**
  113561. * Clones the PositionNormalVertex
  113562. * @returns the cloned PositionNormalVertex
  113563. */
  113564. clone(): PositionNormalVertex;
  113565. }
  113566. /**
  113567. * Contains position, normal and uv vectors for a vertex
  113568. */
  113569. export class PositionNormalTextureVertex {
  113570. /** the position of the vertex (defaut: 0,0,0) */
  113571. position: Vector3;
  113572. /** the normal of the vertex (defaut: 0,1,0) */
  113573. normal: Vector3;
  113574. /** the uv of the vertex (default: 0,0) */
  113575. uv: Vector2;
  113576. /**
  113577. * Creates a PositionNormalTextureVertex
  113578. * @param position the position of the vertex (defaut: 0,0,0)
  113579. * @param normal the normal of the vertex (defaut: 0,1,0)
  113580. * @param uv the uv of the vertex (default: 0,0)
  113581. */
  113582. constructor(
  113583. /** the position of the vertex (defaut: 0,0,0) */
  113584. position?: Vector3,
  113585. /** the normal of the vertex (defaut: 0,1,0) */
  113586. normal?: Vector3,
  113587. /** the uv of the vertex (default: 0,0) */
  113588. uv?: Vector2);
  113589. /**
  113590. * Clones the PositionNormalTextureVertex
  113591. * @returns the cloned PositionNormalTextureVertex
  113592. */
  113593. clone(): PositionNormalTextureVertex;
  113594. }
  113595. }
  113596. declare module BABYLON {
  113597. /** @hidden */
  113598. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  113599. private _genericAttributeLocation;
  113600. private _varyingLocationCount;
  113601. private _varyingLocationMap;
  113602. private _replacements;
  113603. private _textureCount;
  113604. private _uniforms;
  113605. lineProcessor(line: string): string;
  113606. attributeProcessor(attribute: string): string;
  113607. varyingProcessor(varying: string, isFragment: boolean): string;
  113608. uniformProcessor(uniform: string): string;
  113609. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  113610. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  113611. }
  113612. }
  113613. declare module BABYLON {
  113614. /**
  113615. * Container for accessors for natively-stored mesh data buffers.
  113616. */
  113617. class NativeDataBuffer extends DataBuffer {
  113618. /**
  113619. * Accessor value used to identify/retrieve a natively-stored index buffer.
  113620. */
  113621. nativeIndexBuffer?: any;
  113622. /**
  113623. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  113624. */
  113625. nativeVertexBuffer?: any;
  113626. }
  113627. /** @hidden */
  113628. class NativeTexture extends InternalTexture {
  113629. getInternalTexture(): InternalTexture;
  113630. getViewCount(): number;
  113631. }
  113632. /** @hidden */
  113633. export class NativeEngine extends Engine {
  113634. private readonly _native;
  113635. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  113636. private readonly INVALID_HANDLE;
  113637. getHardwareScalingLevel(): number;
  113638. constructor();
  113639. /**
  113640. * Can be used to override the current requestAnimationFrame requester.
  113641. * @hidden
  113642. */
  113643. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  113644. /**
  113645. * Override default engine behavior.
  113646. * @param color
  113647. * @param backBuffer
  113648. * @param depth
  113649. * @param stencil
  113650. */
  113651. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  113652. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  113653. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  113654. createVertexBuffer(data: DataArray): NativeDataBuffer;
  113655. recordVertexArrayObject(vertexBuffers: {
  113656. [key: string]: VertexBuffer;
  113657. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  113658. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  113659. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  113660. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113661. /**
  113662. * Draw a list of indexed primitives
  113663. * @param fillMode defines the primitive to use
  113664. * @param indexStart defines the starting index
  113665. * @param indexCount defines the number of index to draw
  113666. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113667. */
  113668. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113669. /**
  113670. * Draw a list of unindexed primitives
  113671. * @param fillMode defines the primitive to use
  113672. * @param verticesStart defines the index of first vertex to draw
  113673. * @param verticesCount defines the count of vertices to draw
  113674. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113675. */
  113676. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113677. createPipelineContext(): IPipelineContext;
  113678. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  113679. /** @hidden */
  113680. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  113681. /** @hidden */
  113682. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  113683. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  113684. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  113685. protected _setProgram(program: WebGLProgram): void;
  113686. _releaseEffect(effect: Effect): void;
  113687. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  113688. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  113689. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  113690. bindSamplers(effect: Effect): void;
  113691. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  113692. getRenderWidth(useScreen?: boolean): number;
  113693. getRenderHeight(useScreen?: boolean): number;
  113694. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  113695. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113696. /**
  113697. * Set the z offset to apply to current rendering
  113698. * @param value defines the offset to apply
  113699. */
  113700. setZOffset(value: number): void;
  113701. /**
  113702. * Gets the current value of the zOffset
  113703. * @returns the current zOffset state
  113704. */
  113705. getZOffset(): number;
  113706. /**
  113707. * Enable or disable depth buffering
  113708. * @param enable defines the state to set
  113709. */
  113710. setDepthBuffer(enable: boolean): void;
  113711. /**
  113712. * Gets a boolean indicating if depth writing is enabled
  113713. * @returns the current depth writing state
  113714. */
  113715. getDepthWrite(): boolean;
  113716. /**
  113717. * Enable or disable depth writing
  113718. * @param enable defines the state to set
  113719. */
  113720. setDepthWrite(enable: boolean): void;
  113721. /**
  113722. * Enable or disable color writing
  113723. * @param enable defines the state to set
  113724. */
  113725. setColorWrite(enable: boolean): void;
  113726. /**
  113727. * Gets a boolean indicating if color writing is enabled
  113728. * @returns the current color writing state
  113729. */
  113730. getColorWrite(): boolean;
  113731. /**
  113732. * Sets alpha constants used by some alpha blending modes
  113733. * @param r defines the red component
  113734. * @param g defines the green component
  113735. * @param b defines the blue component
  113736. * @param a defines the alpha component
  113737. */
  113738. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  113739. /**
  113740. * Sets the current alpha mode
  113741. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  113742. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113743. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113744. */
  113745. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113746. /**
  113747. * Gets the current alpha mode
  113748. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113749. * @returns the current alpha mode
  113750. */
  113751. getAlphaMode(): number;
  113752. setInt(uniform: WebGLUniformLocation, int: number): void;
  113753. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  113754. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  113755. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  113756. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  113757. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  113758. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  113759. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  113760. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  113761. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  113762. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  113763. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  113764. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  113765. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  113766. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113767. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113768. setFloat(uniform: WebGLUniformLocation, value: number): void;
  113769. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  113770. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  113771. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  113772. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  113773. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  113774. wipeCaches(bruteForce?: boolean): void;
  113775. _createTexture(): WebGLTexture;
  113776. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  113777. /**
  113778. * Usually called from BABYLON.Texture.ts.
  113779. * Passed information to create a WebGLTexture
  113780. * @param urlArg defines a value which contains one of the following:
  113781. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113782. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113783. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113784. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113785. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  113786. * @param scene needed for loading to the correct scene
  113787. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  113788. * @param onLoad optional callback to be called upon successful completion
  113789. * @param onError optional callback to be called upon failure
  113790. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  113791. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113792. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113793. * @param forcedExtension defines the extension to use to pick the right loader
  113794. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113795. */
  113796. 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;
  113797. /**
  113798. * Creates a cube texture
  113799. * @param rootUrl defines the url where the files to load is located
  113800. * @param scene defines the current scene
  113801. * @param files defines the list of files to load (1 per face)
  113802. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  113803. * @param onLoad defines an optional callback raised when the texture is loaded
  113804. * @param onError defines an optional callback raised if there is an issue to load the texture
  113805. * @param format defines the format of the data
  113806. * @param forcedExtension defines the extension to use to pick the right loader
  113807. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  113808. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  113809. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  113810. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  113811. * @returns the cube texture as an InternalTexture
  113812. */
  113813. 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;
  113814. private _getSamplingFilter;
  113815. private static _GetNativeTextureFormat;
  113816. createRenderTargetTexture(size: number | {
  113817. width: number;
  113818. height: number;
  113819. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  113820. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  113821. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  113822. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  113823. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  113824. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  113825. /**
  113826. * Updates a dynamic vertex buffer.
  113827. * @param vertexBuffer the vertex buffer to update
  113828. * @param data the data used to update the vertex buffer
  113829. * @param byteOffset the byte offset of the data (optional)
  113830. * @param byteLength the byte length of the data (optional)
  113831. */
  113832. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  113833. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  113834. private _updateAnisotropicLevel;
  113835. private _getAddressMode;
  113836. /** @hidden */
  113837. _bindTexture(channel: number, texture: InternalTexture): void;
  113838. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  113839. releaseEffects(): void;
  113840. /** @hidden */
  113841. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113842. /** @hidden */
  113843. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113844. /** @hidden */
  113845. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113846. /** @hidden */
  113847. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  113848. }
  113849. }
  113850. declare module BABYLON {
  113851. /**
  113852. * Gather the list of clipboard event types as constants.
  113853. */
  113854. export class ClipboardEventTypes {
  113855. /**
  113856. * The clipboard event is fired when a copy command is active (pressed).
  113857. */
  113858. static readonly COPY: number;
  113859. /**
  113860. * The clipboard event is fired when a cut command is active (pressed).
  113861. */
  113862. static readonly CUT: number;
  113863. /**
  113864. * The clipboard event is fired when a paste command is active (pressed).
  113865. */
  113866. static readonly PASTE: number;
  113867. }
  113868. /**
  113869. * This class is used to store clipboard related info for the onClipboardObservable event.
  113870. */
  113871. export class ClipboardInfo {
  113872. /**
  113873. * Defines the type of event (BABYLON.ClipboardEventTypes)
  113874. */
  113875. type: number;
  113876. /**
  113877. * Defines the related dom event
  113878. */
  113879. event: ClipboardEvent;
  113880. /**
  113881. *Creates an instance of ClipboardInfo.
  113882. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  113883. * @param event Defines the related dom event
  113884. */
  113885. constructor(
  113886. /**
  113887. * Defines the type of event (BABYLON.ClipboardEventTypes)
  113888. */
  113889. type: number,
  113890. /**
  113891. * Defines the related dom event
  113892. */
  113893. event: ClipboardEvent);
  113894. /**
  113895. * Get the clipboard event's type from the keycode.
  113896. * @param keyCode Defines the keyCode for the current keyboard event.
  113897. * @return {number}
  113898. */
  113899. static GetTypeFromCharacter(keyCode: number): number;
  113900. }
  113901. }
  113902. declare module BABYLON {
  113903. /**
  113904. * Google Daydream controller
  113905. */
  113906. export class DaydreamController extends WebVRController {
  113907. /**
  113908. * Base Url for the controller model.
  113909. */
  113910. static MODEL_BASE_URL: string;
  113911. /**
  113912. * File name for the controller model.
  113913. */
  113914. static MODEL_FILENAME: string;
  113915. /**
  113916. * Gamepad Id prefix used to identify Daydream Controller.
  113917. */
  113918. static readonly GAMEPAD_ID_PREFIX: string;
  113919. /**
  113920. * Creates a new DaydreamController from a gamepad
  113921. * @param vrGamepad the gamepad that the controller should be created from
  113922. */
  113923. constructor(vrGamepad: any);
  113924. /**
  113925. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113926. * @param scene scene in which to add meshes
  113927. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113928. */
  113929. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113930. /**
  113931. * Called once for each button that changed state since the last frame
  113932. * @param buttonIdx Which button index changed
  113933. * @param state New state of the button
  113934. * @param changes Which properties on the state changed since last frame
  113935. */
  113936. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113937. }
  113938. }
  113939. declare module BABYLON {
  113940. /**
  113941. * Gear VR Controller
  113942. */
  113943. export class GearVRController extends WebVRController {
  113944. /**
  113945. * Base Url for the controller model.
  113946. */
  113947. static MODEL_BASE_URL: string;
  113948. /**
  113949. * File name for the controller model.
  113950. */
  113951. static MODEL_FILENAME: string;
  113952. /**
  113953. * Gamepad Id prefix used to identify this controller.
  113954. */
  113955. static readonly GAMEPAD_ID_PREFIX: string;
  113956. private readonly _buttonIndexToObservableNameMap;
  113957. /**
  113958. * Creates a new GearVRController from a gamepad
  113959. * @param vrGamepad the gamepad that the controller should be created from
  113960. */
  113961. constructor(vrGamepad: any);
  113962. /**
  113963. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113964. * @param scene scene in which to add meshes
  113965. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113966. */
  113967. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113968. /**
  113969. * Called once for each button that changed state since the last frame
  113970. * @param buttonIdx Which button index changed
  113971. * @param state New state of the button
  113972. * @param changes Which properties on the state changed since last frame
  113973. */
  113974. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113975. }
  113976. }
  113977. declare module BABYLON {
  113978. /**
  113979. * Class containing static functions to help procedurally build meshes
  113980. */
  113981. export class PolyhedronBuilder {
  113982. /**
  113983. * Creates a polyhedron mesh
  113984. * * 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
  113985. * * The parameter `size` (positive float, default 1) sets the polygon size
  113986. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  113987. * * 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`
  113988. * * 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
  113989. * * 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)`)
  113990. * * 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
  113991. * * 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
  113992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113993. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113995. * @param name defines the name of the mesh
  113996. * @param options defines the options used to create the mesh
  113997. * @param scene defines the hosting scene
  113998. * @returns the polyhedron mesh
  113999. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  114000. */
  114001. static CreatePolyhedron(name: string, options: {
  114002. type?: number;
  114003. size?: number;
  114004. sizeX?: number;
  114005. sizeY?: number;
  114006. sizeZ?: number;
  114007. custom?: any;
  114008. faceUV?: Vector4[];
  114009. faceColors?: Color4[];
  114010. flat?: boolean;
  114011. updatable?: boolean;
  114012. sideOrientation?: number;
  114013. frontUVs?: Vector4;
  114014. backUVs?: Vector4;
  114015. }, scene?: Nullable<Scene>): Mesh;
  114016. }
  114017. }
  114018. declare module BABYLON {
  114019. /**
  114020. * Gizmo that enables scaling a mesh along 3 axis
  114021. */
  114022. export class ScaleGizmo extends Gizmo {
  114023. /**
  114024. * Internal gizmo used for interactions on the x axis
  114025. */
  114026. xGizmo: AxisScaleGizmo;
  114027. /**
  114028. * Internal gizmo used for interactions on the y axis
  114029. */
  114030. yGizmo: AxisScaleGizmo;
  114031. /**
  114032. * Internal gizmo used for interactions on the z axis
  114033. */
  114034. zGizmo: AxisScaleGizmo;
  114035. /**
  114036. * Internal gizmo used to scale all axis equally
  114037. */
  114038. uniformScaleGizmo: AxisScaleGizmo;
  114039. private _meshAttached;
  114040. private _updateGizmoRotationToMatchAttachedMesh;
  114041. private _snapDistance;
  114042. private _scaleRatio;
  114043. private _uniformScalingMesh;
  114044. private _octahedron;
  114045. /** Fires an event when any of it's sub gizmos are dragged */
  114046. onDragStartObservable: Observable<unknown>;
  114047. /** Fires an event when any of it's sub gizmos are released from dragging */
  114048. onDragEndObservable: Observable<unknown>;
  114049. attachedMesh: Nullable<AbstractMesh>;
  114050. /**
  114051. * Creates a ScaleGizmo
  114052. * @param gizmoLayer The utility layer the gizmo will be added to
  114053. */
  114054. constructor(gizmoLayer?: UtilityLayerRenderer);
  114055. updateGizmoRotationToMatchAttachedMesh: boolean;
  114056. /**
  114057. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114058. */
  114059. snapDistance: number;
  114060. /**
  114061. * Ratio for the scale of the gizmo (Default: 1)
  114062. */
  114063. scaleRatio: number;
  114064. /**
  114065. * Disposes of the gizmo
  114066. */
  114067. dispose(): void;
  114068. }
  114069. }
  114070. declare module BABYLON {
  114071. /**
  114072. * Single axis scale gizmo
  114073. */
  114074. export class AxisScaleGizmo extends Gizmo {
  114075. /**
  114076. * Drag behavior responsible for the gizmos dragging interactions
  114077. */
  114078. dragBehavior: PointerDragBehavior;
  114079. private _pointerObserver;
  114080. /**
  114081. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114082. */
  114083. snapDistance: number;
  114084. /**
  114085. * Event that fires each time the gizmo snaps to a new location.
  114086. * * snapDistance is the the change in distance
  114087. */
  114088. onSnapObservable: Observable<{
  114089. snapDistance: number;
  114090. }>;
  114091. /**
  114092. * If the scaling operation should be done on all axis (default: false)
  114093. */
  114094. uniformScaling: boolean;
  114095. private _isEnabled;
  114096. private _parent;
  114097. private _arrow;
  114098. private _coloredMaterial;
  114099. private _hoverMaterial;
  114100. /**
  114101. * Creates an AxisScaleGizmo
  114102. * @param gizmoLayer The utility layer the gizmo will be added to
  114103. * @param dragAxis The axis which the gizmo will be able to scale on
  114104. * @param color The color of the gizmo
  114105. */
  114106. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  114107. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114108. /**
  114109. * If the gizmo is enabled
  114110. */
  114111. isEnabled: boolean;
  114112. /**
  114113. * Disposes of the gizmo
  114114. */
  114115. dispose(): void;
  114116. /**
  114117. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  114118. * @param mesh The mesh to replace the default mesh of the gizmo
  114119. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  114120. */
  114121. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  114122. }
  114123. }
  114124. declare module BABYLON {
  114125. /**
  114126. * Bounding box gizmo
  114127. */
  114128. export class BoundingBoxGizmo extends Gizmo {
  114129. private _lineBoundingBox;
  114130. private _rotateSpheresParent;
  114131. private _scaleBoxesParent;
  114132. private _boundingDimensions;
  114133. private _renderObserver;
  114134. private _pointerObserver;
  114135. private _scaleDragSpeed;
  114136. private _tmpQuaternion;
  114137. private _tmpVector;
  114138. private _tmpRotationMatrix;
  114139. /**
  114140. * 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)
  114141. */
  114142. ignoreChildren: boolean;
  114143. /**
  114144. * 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)
  114145. */
  114146. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  114147. /**
  114148. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  114149. */
  114150. rotationSphereSize: number;
  114151. /**
  114152. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  114153. */
  114154. scaleBoxSize: number;
  114155. /**
  114156. * 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)
  114157. */
  114158. fixedDragMeshScreenSize: boolean;
  114159. /**
  114160. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  114161. */
  114162. fixedDragMeshScreenSizeDistanceFactor: number;
  114163. /**
  114164. * Fired when a rotation sphere or scale box is dragged
  114165. */
  114166. onDragStartObservable: Observable<{}>;
  114167. /**
  114168. * Fired when a scale box is dragged
  114169. */
  114170. onScaleBoxDragObservable: Observable<{}>;
  114171. /**
  114172. * Fired when a scale box drag is ended
  114173. */
  114174. onScaleBoxDragEndObservable: Observable<{}>;
  114175. /**
  114176. * Fired when a rotation sphere is dragged
  114177. */
  114178. onRotationSphereDragObservable: Observable<{}>;
  114179. /**
  114180. * Fired when a rotation sphere drag is ended
  114181. */
  114182. onRotationSphereDragEndObservable: Observable<{}>;
  114183. /**
  114184. * 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)
  114185. */
  114186. scalePivot: Nullable<Vector3>;
  114187. /**
  114188. * Mesh used as a pivot to rotate the attached mesh
  114189. */
  114190. private _anchorMesh;
  114191. private _existingMeshScale;
  114192. private _dragMesh;
  114193. private pointerDragBehavior;
  114194. private coloredMaterial;
  114195. private hoverColoredMaterial;
  114196. /**
  114197. * Sets the color of the bounding box gizmo
  114198. * @param color the color to set
  114199. */
  114200. setColor(color: Color3): void;
  114201. /**
  114202. * Creates an BoundingBoxGizmo
  114203. * @param gizmoLayer The utility layer the gizmo will be added to
  114204. * @param color The color of the gizmo
  114205. */
  114206. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  114207. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114208. private _selectNode;
  114209. /**
  114210. * Updates the bounding box information for the Gizmo
  114211. */
  114212. updateBoundingBox(): void;
  114213. private _updateRotationSpheres;
  114214. private _updateScaleBoxes;
  114215. /**
  114216. * Enables rotation on the specified axis and disables rotation on the others
  114217. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  114218. */
  114219. setEnabledRotationAxis(axis: string): void;
  114220. /**
  114221. * Enables/disables scaling
  114222. * @param enable if scaling should be enabled
  114223. */
  114224. setEnabledScaling(enable: boolean): void;
  114225. private _updateDummy;
  114226. /**
  114227. * Enables a pointer drag behavior on the bounding box of the gizmo
  114228. */
  114229. enableDragBehavior(): void;
  114230. /**
  114231. * Disposes of the gizmo
  114232. */
  114233. dispose(): void;
  114234. /**
  114235. * 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)
  114236. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  114237. * @returns the bounding box mesh with the passed in mesh as a child
  114238. */
  114239. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  114240. /**
  114241. * CustomMeshes are not supported by this gizmo
  114242. * @param mesh The mesh to replace the default mesh of the gizmo
  114243. */
  114244. setCustomMesh(mesh: Mesh): void;
  114245. }
  114246. }
  114247. declare module BABYLON {
  114248. /**
  114249. * Single plane rotation gizmo
  114250. */
  114251. export class PlaneRotationGizmo extends Gizmo {
  114252. /**
  114253. * Drag behavior responsible for the gizmos dragging interactions
  114254. */
  114255. dragBehavior: PointerDragBehavior;
  114256. private _pointerObserver;
  114257. /**
  114258. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  114259. */
  114260. snapDistance: number;
  114261. /**
  114262. * Event that fires each time the gizmo snaps to a new location.
  114263. * * snapDistance is the the change in distance
  114264. */
  114265. onSnapObservable: Observable<{
  114266. snapDistance: number;
  114267. }>;
  114268. private _isEnabled;
  114269. private _parent;
  114270. /**
  114271. * Creates a PlaneRotationGizmo
  114272. * @param gizmoLayer The utility layer the gizmo will be added to
  114273. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  114274. * @param color The color of the gizmo
  114275. * @param tessellation Amount of tessellation to be used when creating rotation circles
  114276. * @param useEulerRotation Use and update Euler angle instead of quaternion
  114277. */
  114278. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  114279. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114280. /**
  114281. * If the gizmo is enabled
  114282. */
  114283. isEnabled: boolean;
  114284. /**
  114285. * Disposes of the gizmo
  114286. */
  114287. dispose(): void;
  114288. }
  114289. }
  114290. declare module BABYLON {
  114291. /**
  114292. * Gizmo that enables rotating a mesh along 3 axis
  114293. */
  114294. export class RotationGizmo extends Gizmo {
  114295. /**
  114296. * Internal gizmo used for interactions on the x axis
  114297. */
  114298. xGizmo: PlaneRotationGizmo;
  114299. /**
  114300. * Internal gizmo used for interactions on the y axis
  114301. */
  114302. yGizmo: PlaneRotationGizmo;
  114303. /**
  114304. * Internal gizmo used for interactions on the z axis
  114305. */
  114306. zGizmo: PlaneRotationGizmo;
  114307. /** Fires an event when any of it's sub gizmos are dragged */
  114308. onDragStartObservable: Observable<unknown>;
  114309. /** Fires an event when any of it's sub gizmos are released from dragging */
  114310. onDragEndObservable: Observable<unknown>;
  114311. private _meshAttached;
  114312. attachedMesh: Nullable<AbstractMesh>;
  114313. /**
  114314. * Creates a RotationGizmo
  114315. * @param gizmoLayer The utility layer the gizmo will be added to
  114316. * @param tessellation Amount of tessellation to be used when creating rotation circles
  114317. * @param useEulerRotation Use and update Euler angle instead of quaternion
  114318. */
  114319. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  114320. updateGizmoRotationToMatchAttachedMesh: boolean;
  114321. /**
  114322. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114323. */
  114324. snapDistance: number;
  114325. /**
  114326. * Ratio for the scale of the gizmo (Default: 1)
  114327. */
  114328. scaleRatio: number;
  114329. /**
  114330. * Disposes of the gizmo
  114331. */
  114332. dispose(): void;
  114333. /**
  114334. * CustomMeshes are not supported by this gizmo
  114335. * @param mesh The mesh to replace the default mesh of the gizmo
  114336. */
  114337. setCustomMesh(mesh: Mesh): void;
  114338. }
  114339. }
  114340. declare module BABYLON {
  114341. /**
  114342. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  114343. */
  114344. export class GizmoManager implements IDisposable {
  114345. private scene;
  114346. /**
  114347. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  114348. */
  114349. gizmos: {
  114350. positionGizmo: Nullable<PositionGizmo>;
  114351. rotationGizmo: Nullable<RotationGizmo>;
  114352. scaleGizmo: Nullable<ScaleGizmo>;
  114353. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  114354. };
  114355. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  114356. clearGizmoOnEmptyPointerEvent: boolean;
  114357. /** Fires an event when the manager is attached to a mesh */
  114358. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  114359. private _gizmosEnabled;
  114360. private _pointerObserver;
  114361. private _attachedMesh;
  114362. private _boundingBoxColor;
  114363. private _defaultUtilityLayer;
  114364. private _defaultKeepDepthUtilityLayer;
  114365. /**
  114366. * When bounding box gizmo is enabled, this can be used to track drag/end events
  114367. */
  114368. boundingBoxDragBehavior: SixDofDragBehavior;
  114369. /**
  114370. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  114371. */
  114372. attachableMeshes: Nullable<Array<AbstractMesh>>;
  114373. /**
  114374. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  114375. */
  114376. usePointerToAttachGizmos: boolean;
  114377. /**
  114378. * Utility layer that the bounding box gizmo belongs to
  114379. */
  114380. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  114381. /**
  114382. * Utility layer that all gizmos besides bounding box belong to
  114383. */
  114384. readonly utilityLayer: UtilityLayerRenderer;
  114385. /**
  114386. * Instatiates a gizmo manager
  114387. * @param scene the scene to overlay the gizmos on top of
  114388. */
  114389. constructor(scene: Scene);
  114390. /**
  114391. * Attaches a set of gizmos to the specified mesh
  114392. * @param mesh The mesh the gizmo's should be attached to
  114393. */
  114394. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  114395. /**
  114396. * If the position gizmo is enabled
  114397. */
  114398. positionGizmoEnabled: boolean;
  114399. /**
  114400. * If the rotation gizmo is enabled
  114401. */
  114402. rotationGizmoEnabled: boolean;
  114403. /**
  114404. * If the scale gizmo is enabled
  114405. */
  114406. scaleGizmoEnabled: boolean;
  114407. /**
  114408. * If the boundingBox gizmo is enabled
  114409. */
  114410. boundingBoxGizmoEnabled: boolean;
  114411. /**
  114412. * Disposes of the gizmo manager
  114413. */
  114414. dispose(): void;
  114415. }
  114416. }
  114417. declare module BABYLON {
  114418. /**
  114419. * A directional light is defined by a direction (what a surprise!).
  114420. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  114421. * 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.
  114422. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114423. */
  114424. export class DirectionalLight extends ShadowLight {
  114425. private _shadowFrustumSize;
  114426. /**
  114427. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  114428. */
  114429. /**
  114430. * Specifies a fix frustum size for the shadow generation.
  114431. */
  114432. shadowFrustumSize: number;
  114433. private _shadowOrthoScale;
  114434. /**
  114435. * Gets the shadow projection scale against the optimal computed one.
  114436. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  114437. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  114438. */
  114439. /**
  114440. * Sets the shadow projection scale against the optimal computed one.
  114441. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  114442. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  114443. */
  114444. shadowOrthoScale: number;
  114445. /**
  114446. * Automatically compute the projection matrix to best fit (including all the casters)
  114447. * on each frame.
  114448. */
  114449. autoUpdateExtends: boolean;
  114450. private _orthoLeft;
  114451. private _orthoRight;
  114452. private _orthoTop;
  114453. private _orthoBottom;
  114454. /**
  114455. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  114456. * The directional light is emitted from everywhere in the given direction.
  114457. * It can cast shadows.
  114458. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114459. * @param name The friendly name of the light
  114460. * @param direction The direction of the light
  114461. * @param scene The scene the light belongs to
  114462. */
  114463. constructor(name: string, direction: Vector3, scene: Scene);
  114464. /**
  114465. * Returns the string "DirectionalLight".
  114466. * @return The class name
  114467. */
  114468. getClassName(): string;
  114469. /**
  114470. * Returns the integer 1.
  114471. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114472. */
  114473. getTypeID(): number;
  114474. /**
  114475. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  114476. * Returns the DirectionalLight Shadow projection matrix.
  114477. */
  114478. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114479. /**
  114480. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  114481. * Returns the DirectionalLight Shadow projection matrix.
  114482. */
  114483. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  114484. /**
  114485. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  114486. * Returns the DirectionalLight Shadow projection matrix.
  114487. */
  114488. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114489. protected _buildUniformLayout(): void;
  114490. /**
  114491. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  114492. * @param effect The effect to update
  114493. * @param lightIndex The index of the light in the effect to update
  114494. * @returns The directional light
  114495. */
  114496. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  114497. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  114498. /**
  114499. * Gets the minZ used for shadow according to both the scene and the light.
  114500. *
  114501. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114502. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114503. * @param activeCamera The camera we are returning the min for
  114504. * @returns the depth min z
  114505. */
  114506. getDepthMinZ(activeCamera: Camera): number;
  114507. /**
  114508. * Gets the maxZ used for shadow according to both the scene and the light.
  114509. *
  114510. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114511. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114512. * @param activeCamera The camera we are returning the max for
  114513. * @returns the depth max z
  114514. */
  114515. getDepthMaxZ(activeCamera: Camera): number;
  114516. /**
  114517. * Prepares the list of defines specific to the light type.
  114518. * @param defines the list of defines
  114519. * @param lightIndex defines the index of the light for the effect
  114520. */
  114521. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114522. }
  114523. }
  114524. declare module BABYLON {
  114525. /**
  114526. * Class containing static functions to help procedurally build meshes
  114527. */
  114528. export class HemisphereBuilder {
  114529. /**
  114530. * Creates a hemisphere mesh
  114531. * @param name defines the name of the mesh
  114532. * @param options defines the options used to create the mesh
  114533. * @param scene defines the hosting scene
  114534. * @returns the hemisphere mesh
  114535. */
  114536. static CreateHemisphere(name: string, options: {
  114537. segments?: number;
  114538. diameter?: number;
  114539. sideOrientation?: number;
  114540. }, scene: any): Mesh;
  114541. }
  114542. }
  114543. declare module BABYLON {
  114544. /**
  114545. * A spot light is defined by a position, a direction, an angle, and an exponent.
  114546. * These values define a cone of light starting from the position, emitting toward the direction.
  114547. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  114548. * and the exponent defines the speed of the decay of the light with distance (reach).
  114549. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114550. */
  114551. export class SpotLight extends ShadowLight {
  114552. private _angle;
  114553. private _innerAngle;
  114554. private _cosHalfAngle;
  114555. private _lightAngleScale;
  114556. private _lightAngleOffset;
  114557. /**
  114558. * Gets the cone angle of the spot light in Radians.
  114559. */
  114560. /**
  114561. * Sets the cone angle of the spot light in Radians.
  114562. */
  114563. angle: number;
  114564. /**
  114565. * Only used in gltf falloff mode, this defines the angle where
  114566. * the directional falloff will start before cutting at angle which could be seen
  114567. * as outer angle.
  114568. */
  114569. /**
  114570. * Only used in gltf falloff mode, this defines the angle where
  114571. * the directional falloff will start before cutting at angle which could be seen
  114572. * as outer angle.
  114573. */
  114574. innerAngle: number;
  114575. private _shadowAngleScale;
  114576. /**
  114577. * Allows scaling the angle of the light for shadow generation only.
  114578. */
  114579. /**
  114580. * Allows scaling the angle of the light for shadow generation only.
  114581. */
  114582. shadowAngleScale: number;
  114583. /**
  114584. * The light decay speed with the distance from the emission spot.
  114585. */
  114586. exponent: number;
  114587. private _projectionTextureMatrix;
  114588. /**
  114589. * Allows reading the projecton texture
  114590. */
  114591. readonly projectionTextureMatrix: Matrix;
  114592. protected _projectionTextureLightNear: number;
  114593. /**
  114594. * Gets the near clip of the Spotlight for texture projection.
  114595. */
  114596. /**
  114597. * Sets the near clip of the Spotlight for texture projection.
  114598. */
  114599. projectionTextureLightNear: number;
  114600. protected _projectionTextureLightFar: number;
  114601. /**
  114602. * Gets the far clip of the Spotlight for texture projection.
  114603. */
  114604. /**
  114605. * Sets the far clip of the Spotlight for texture projection.
  114606. */
  114607. projectionTextureLightFar: number;
  114608. protected _projectionTextureUpDirection: Vector3;
  114609. /**
  114610. * Gets the Up vector of the Spotlight for texture projection.
  114611. */
  114612. /**
  114613. * Sets the Up vector of the Spotlight for texture projection.
  114614. */
  114615. projectionTextureUpDirection: Vector3;
  114616. private _projectionTexture;
  114617. /**
  114618. * Gets the projection texture of the light.
  114619. */
  114620. /**
  114621. * Sets the projection texture of the light.
  114622. */
  114623. projectionTexture: Nullable<BaseTexture>;
  114624. private _projectionTextureViewLightDirty;
  114625. private _projectionTextureProjectionLightDirty;
  114626. private _projectionTextureDirty;
  114627. private _projectionTextureViewTargetVector;
  114628. private _projectionTextureViewLightMatrix;
  114629. private _projectionTextureProjectionLightMatrix;
  114630. private _projectionTextureScalingMatrix;
  114631. /**
  114632. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  114633. * It can cast shadows.
  114634. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114635. * @param name The light friendly name
  114636. * @param position The position of the spot light in the scene
  114637. * @param direction The direction of the light in the scene
  114638. * @param angle The cone angle of the light in Radians
  114639. * @param exponent The light decay speed with the distance from the emission spot
  114640. * @param scene The scene the lights belongs to
  114641. */
  114642. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  114643. /**
  114644. * Returns the string "SpotLight".
  114645. * @returns the class name
  114646. */
  114647. getClassName(): string;
  114648. /**
  114649. * Returns the integer 2.
  114650. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114651. */
  114652. getTypeID(): number;
  114653. /**
  114654. * Overrides the direction setter to recompute the projection texture view light Matrix.
  114655. */
  114656. protected _setDirection(value: Vector3): void;
  114657. /**
  114658. * Overrides the position setter to recompute the projection texture view light Matrix.
  114659. */
  114660. protected _setPosition(value: Vector3): void;
  114661. /**
  114662. * 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.
  114663. * Returns the SpotLight.
  114664. */
  114665. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114666. protected _computeProjectionTextureViewLightMatrix(): void;
  114667. protected _computeProjectionTextureProjectionLightMatrix(): void;
  114668. /**
  114669. * Main function for light texture projection matrix computing.
  114670. */
  114671. protected _computeProjectionTextureMatrix(): void;
  114672. protected _buildUniformLayout(): void;
  114673. private _computeAngleValues;
  114674. /**
  114675. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  114676. * @param effect The effect to update
  114677. * @param lightIndex The index of the light in the effect to update
  114678. * @returns The spot light
  114679. */
  114680. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  114681. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  114682. /**
  114683. * Disposes the light and the associated resources.
  114684. */
  114685. dispose(): void;
  114686. /**
  114687. * Prepares the list of defines specific to the light type.
  114688. * @param defines the list of defines
  114689. * @param lightIndex defines the index of the light for the effect
  114690. */
  114691. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114692. }
  114693. }
  114694. declare module BABYLON {
  114695. /**
  114696. * Gizmo that enables viewing a light
  114697. */
  114698. export class LightGizmo extends Gizmo {
  114699. private _lightMesh;
  114700. private _material;
  114701. private _cachedPosition;
  114702. private _cachedForward;
  114703. private _attachedMeshParent;
  114704. /**
  114705. * Creates a LightGizmo
  114706. * @param gizmoLayer The utility layer the gizmo will be added to
  114707. */
  114708. constructor(gizmoLayer?: UtilityLayerRenderer);
  114709. private _light;
  114710. /**
  114711. * The light that the gizmo is attached to
  114712. */
  114713. light: Nullable<Light>;
  114714. /**
  114715. * Gets the material used to render the light gizmo
  114716. */
  114717. readonly material: StandardMaterial;
  114718. /**
  114719. * @hidden
  114720. * Updates the gizmo to match the attached mesh's position/rotation
  114721. */
  114722. protected _update(): void;
  114723. private static _Scale;
  114724. /**
  114725. * Creates the lines for a light mesh
  114726. */
  114727. private static _CreateLightLines;
  114728. /**
  114729. * Disposes of the light gizmo
  114730. */
  114731. dispose(): void;
  114732. private static _CreateHemisphericLightMesh;
  114733. private static _CreatePointLightMesh;
  114734. private static _CreateSpotLightMesh;
  114735. private static _CreateDirectionalLightMesh;
  114736. }
  114737. }
  114738. declare module BABYLON {
  114739. /** @hidden */
  114740. export var backgroundFragmentDeclaration: {
  114741. name: string;
  114742. shader: string;
  114743. };
  114744. }
  114745. declare module BABYLON {
  114746. /** @hidden */
  114747. export var backgroundUboDeclaration: {
  114748. name: string;
  114749. shader: string;
  114750. };
  114751. }
  114752. declare module BABYLON {
  114753. /** @hidden */
  114754. export var backgroundPixelShader: {
  114755. name: string;
  114756. shader: string;
  114757. };
  114758. }
  114759. declare module BABYLON {
  114760. /** @hidden */
  114761. export var backgroundVertexDeclaration: {
  114762. name: string;
  114763. shader: string;
  114764. };
  114765. }
  114766. declare module BABYLON {
  114767. /** @hidden */
  114768. export var backgroundVertexShader: {
  114769. name: string;
  114770. shader: string;
  114771. };
  114772. }
  114773. declare module BABYLON {
  114774. /**
  114775. * Background material used to create an efficient environement around your scene.
  114776. */
  114777. export class BackgroundMaterial extends PushMaterial {
  114778. /**
  114779. * Standard reflectance value at parallel view angle.
  114780. */
  114781. static StandardReflectance0: number;
  114782. /**
  114783. * Standard reflectance value at grazing angle.
  114784. */
  114785. static StandardReflectance90: number;
  114786. protected _primaryColor: Color3;
  114787. /**
  114788. * Key light Color (multiply against the environement texture)
  114789. */
  114790. primaryColor: Color3;
  114791. protected __perceptualColor: Nullable<Color3>;
  114792. /**
  114793. * Experimental Internal Use Only.
  114794. *
  114795. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  114796. * This acts as a helper to set the primary color to a more "human friendly" value.
  114797. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  114798. * output color as close as possible from the chosen value.
  114799. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  114800. * part of lighting setup.)
  114801. */
  114802. _perceptualColor: Nullable<Color3>;
  114803. protected _primaryColorShadowLevel: float;
  114804. /**
  114805. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  114806. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  114807. */
  114808. primaryColorShadowLevel: float;
  114809. protected _primaryColorHighlightLevel: float;
  114810. /**
  114811. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  114812. * The primary color is used at the level chosen to define what the white area would look.
  114813. */
  114814. primaryColorHighlightLevel: float;
  114815. protected _reflectionTexture: Nullable<BaseTexture>;
  114816. /**
  114817. * Reflection Texture used in the material.
  114818. * Should be author in a specific way for the best result (refer to the documentation).
  114819. */
  114820. reflectionTexture: Nullable<BaseTexture>;
  114821. protected _reflectionBlur: float;
  114822. /**
  114823. * Reflection Texture level of blur.
  114824. *
  114825. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  114826. * texture twice.
  114827. */
  114828. reflectionBlur: float;
  114829. protected _diffuseTexture: Nullable<BaseTexture>;
  114830. /**
  114831. * Diffuse Texture used in the material.
  114832. * Should be author in a specific way for the best result (refer to the documentation).
  114833. */
  114834. diffuseTexture: Nullable<BaseTexture>;
  114835. protected _shadowLights: Nullable<IShadowLight[]>;
  114836. /**
  114837. * Specify the list of lights casting shadow on the material.
  114838. * All scene shadow lights will be included if null.
  114839. */
  114840. shadowLights: Nullable<IShadowLight[]>;
  114841. protected _shadowLevel: float;
  114842. /**
  114843. * Helps adjusting the shadow to a softer level if required.
  114844. * 0 means black shadows and 1 means no shadows.
  114845. */
  114846. shadowLevel: float;
  114847. protected _sceneCenter: Vector3;
  114848. /**
  114849. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  114850. * It is usually zero but might be interesting to modify according to your setup.
  114851. */
  114852. sceneCenter: Vector3;
  114853. protected _opacityFresnel: boolean;
  114854. /**
  114855. * This helps specifying that the material is falling off to the sky box at grazing angle.
  114856. * This helps ensuring a nice transition when the camera goes under the ground.
  114857. */
  114858. opacityFresnel: boolean;
  114859. protected _reflectionFresnel: boolean;
  114860. /**
  114861. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  114862. * This helps adding a mirror texture on the ground.
  114863. */
  114864. reflectionFresnel: boolean;
  114865. protected _reflectionFalloffDistance: number;
  114866. /**
  114867. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  114868. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  114869. */
  114870. reflectionFalloffDistance: number;
  114871. protected _reflectionAmount: number;
  114872. /**
  114873. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  114874. */
  114875. reflectionAmount: number;
  114876. protected _reflectionReflectance0: number;
  114877. /**
  114878. * This specifies the weight of the reflection at grazing angle.
  114879. */
  114880. reflectionReflectance0: number;
  114881. protected _reflectionReflectance90: number;
  114882. /**
  114883. * This specifies the weight of the reflection at a perpendicular point of view.
  114884. */
  114885. reflectionReflectance90: number;
  114886. /**
  114887. * Sets the reflection reflectance fresnel values according to the default standard
  114888. * empirically know to work well :-)
  114889. */
  114890. reflectionStandardFresnelWeight: number;
  114891. protected _useRGBColor: boolean;
  114892. /**
  114893. * Helps to directly use the maps channels instead of their level.
  114894. */
  114895. useRGBColor: boolean;
  114896. protected _enableNoise: boolean;
  114897. /**
  114898. * This helps reducing the banding effect that could occur on the background.
  114899. */
  114900. enableNoise: boolean;
  114901. /**
  114902. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114903. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  114904. * Recommended to be keep at 1.0 except for special cases.
  114905. */
  114906. fovMultiplier: number;
  114907. private _fovMultiplier;
  114908. /**
  114909. * Enable the FOV adjustment feature controlled by fovMultiplier.
  114910. */
  114911. useEquirectangularFOV: boolean;
  114912. private _maxSimultaneousLights;
  114913. /**
  114914. * Number of Simultaneous lights allowed on the material.
  114915. */
  114916. maxSimultaneousLights: int;
  114917. /**
  114918. * Default configuration related to image processing available in the Background Material.
  114919. */
  114920. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114921. /**
  114922. * Keep track of the image processing observer to allow dispose and replace.
  114923. */
  114924. private _imageProcessingObserver;
  114925. /**
  114926. * Attaches a new image processing configuration to the PBR Material.
  114927. * @param configuration (if null the scene configuration will be use)
  114928. */
  114929. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114930. /**
  114931. * Gets the image processing configuration used either in this material.
  114932. */
  114933. /**
  114934. * Sets the Default image processing configuration used either in the this material.
  114935. *
  114936. * If sets to null, the scene one is in use.
  114937. */
  114938. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  114939. /**
  114940. * Gets wether the color curves effect is enabled.
  114941. */
  114942. /**
  114943. * Sets wether the color curves effect is enabled.
  114944. */
  114945. cameraColorCurvesEnabled: boolean;
  114946. /**
  114947. * Gets wether the color grading effect is enabled.
  114948. */
  114949. /**
  114950. * Gets wether the color grading effect is enabled.
  114951. */
  114952. cameraColorGradingEnabled: boolean;
  114953. /**
  114954. * Gets wether tonemapping is enabled or not.
  114955. */
  114956. /**
  114957. * Sets wether tonemapping is enabled or not
  114958. */
  114959. cameraToneMappingEnabled: boolean;
  114960. /**
  114961. * The camera exposure used on this material.
  114962. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114963. * This corresponds to a photographic exposure.
  114964. */
  114965. /**
  114966. * The camera exposure used on this material.
  114967. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114968. * This corresponds to a photographic exposure.
  114969. */
  114970. cameraExposure: float;
  114971. /**
  114972. * Gets The camera contrast used on this material.
  114973. */
  114974. /**
  114975. * Sets The camera contrast used on this material.
  114976. */
  114977. cameraContrast: float;
  114978. /**
  114979. * Gets the Color Grading 2D Lookup Texture.
  114980. */
  114981. /**
  114982. * Sets the Color Grading 2D Lookup Texture.
  114983. */
  114984. cameraColorGradingTexture: Nullable<BaseTexture>;
  114985. /**
  114986. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114987. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114988. * 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;
  114989. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114990. */
  114991. /**
  114992. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114993. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114994. * 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;
  114995. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114996. */
  114997. cameraColorCurves: Nullable<ColorCurves>;
  114998. /**
  114999. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  115000. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  115001. */
  115002. switchToBGR: boolean;
  115003. private _renderTargets;
  115004. private _reflectionControls;
  115005. private _white;
  115006. private _primaryShadowColor;
  115007. private _primaryHighlightColor;
  115008. /**
  115009. * Instantiates a Background Material in the given scene
  115010. * @param name The friendly name of the material
  115011. * @param scene The scene to add the material to
  115012. */
  115013. constructor(name: string, scene: Scene);
  115014. /**
  115015. * Gets a boolean indicating that current material needs to register RTT
  115016. */
  115017. readonly hasRenderTargetTextures: boolean;
  115018. /**
  115019. * The entire material has been created in order to prevent overdraw.
  115020. * @returns false
  115021. */
  115022. needAlphaTesting(): boolean;
  115023. /**
  115024. * The entire material has been created in order to prevent overdraw.
  115025. * @returns true if blending is enable
  115026. */
  115027. needAlphaBlending(): boolean;
  115028. /**
  115029. * Checks wether the material is ready to be rendered for a given mesh.
  115030. * @param mesh The mesh to render
  115031. * @param subMesh The submesh to check against
  115032. * @param useInstances Specify wether or not the material is used with instances
  115033. * @returns true if all the dependencies are ready (Textures, Effects...)
  115034. */
  115035. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115036. /**
  115037. * Compute the primary color according to the chosen perceptual color.
  115038. */
  115039. private _computePrimaryColorFromPerceptualColor;
  115040. /**
  115041. * Compute the highlights and shadow colors according to their chosen levels.
  115042. */
  115043. private _computePrimaryColors;
  115044. /**
  115045. * Build the uniform buffer used in the material.
  115046. */
  115047. buildUniformLayout(): void;
  115048. /**
  115049. * Unbind the material.
  115050. */
  115051. unbind(): void;
  115052. /**
  115053. * Bind only the world matrix to the material.
  115054. * @param world The world matrix to bind.
  115055. */
  115056. bindOnlyWorldMatrix(world: Matrix): void;
  115057. /**
  115058. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  115059. * @param world The world matrix to bind.
  115060. * @param subMesh The submesh to bind for.
  115061. */
  115062. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115063. /**
  115064. * Checks to see if a texture is used in the material.
  115065. * @param texture - Base texture to use.
  115066. * @returns - Boolean specifying if a texture is used in the material.
  115067. */
  115068. hasTexture(texture: BaseTexture): boolean;
  115069. /**
  115070. * Dispose the material.
  115071. * @param forceDisposeEffect Force disposal of the associated effect.
  115072. * @param forceDisposeTextures Force disposal of the associated textures.
  115073. */
  115074. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  115075. /**
  115076. * Clones the material.
  115077. * @param name The cloned name.
  115078. * @returns The cloned material.
  115079. */
  115080. clone(name: string): BackgroundMaterial;
  115081. /**
  115082. * Serializes the current material to its JSON representation.
  115083. * @returns The JSON representation.
  115084. */
  115085. serialize(): any;
  115086. /**
  115087. * Gets the class name of the material
  115088. * @returns "BackgroundMaterial"
  115089. */
  115090. getClassName(): string;
  115091. /**
  115092. * Parse a JSON input to create back a background material.
  115093. * @param source The JSON data to parse
  115094. * @param scene The scene to create the parsed material in
  115095. * @param rootUrl The root url of the assets the material depends upon
  115096. * @returns the instantiated BackgroundMaterial.
  115097. */
  115098. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  115099. }
  115100. }
  115101. declare module BABYLON {
  115102. /**
  115103. * Represents the different options available during the creation of
  115104. * a Environment helper.
  115105. *
  115106. * This can control the default ground, skybox and image processing setup of your scene.
  115107. */
  115108. export interface IEnvironmentHelperOptions {
  115109. /**
  115110. * Specifies wether or not to create a ground.
  115111. * True by default.
  115112. */
  115113. createGround: boolean;
  115114. /**
  115115. * Specifies the ground size.
  115116. * 15 by default.
  115117. */
  115118. groundSize: number;
  115119. /**
  115120. * The texture used on the ground for the main color.
  115121. * Comes from the BabylonJS CDN by default.
  115122. *
  115123. * Remarks: Can be either a texture or a url.
  115124. */
  115125. groundTexture: string | BaseTexture;
  115126. /**
  115127. * The color mixed in the ground texture by default.
  115128. * BabylonJS clearColor by default.
  115129. */
  115130. groundColor: Color3;
  115131. /**
  115132. * Specifies the ground opacity.
  115133. * 1 by default.
  115134. */
  115135. groundOpacity: number;
  115136. /**
  115137. * Enables the ground to receive shadows.
  115138. * True by default.
  115139. */
  115140. enableGroundShadow: boolean;
  115141. /**
  115142. * Helps preventing the shadow to be fully black on the ground.
  115143. * 0.5 by default.
  115144. */
  115145. groundShadowLevel: number;
  115146. /**
  115147. * Creates a mirror texture attach to the ground.
  115148. * false by default.
  115149. */
  115150. enableGroundMirror: boolean;
  115151. /**
  115152. * Specifies the ground mirror size ratio.
  115153. * 0.3 by default as the default kernel is 64.
  115154. */
  115155. groundMirrorSizeRatio: number;
  115156. /**
  115157. * Specifies the ground mirror blur kernel size.
  115158. * 64 by default.
  115159. */
  115160. groundMirrorBlurKernel: number;
  115161. /**
  115162. * Specifies the ground mirror visibility amount.
  115163. * 1 by default
  115164. */
  115165. groundMirrorAmount: number;
  115166. /**
  115167. * Specifies the ground mirror reflectance weight.
  115168. * This uses the standard weight of the background material to setup the fresnel effect
  115169. * of the mirror.
  115170. * 1 by default.
  115171. */
  115172. groundMirrorFresnelWeight: number;
  115173. /**
  115174. * Specifies the ground mirror Falloff distance.
  115175. * This can helps reducing the size of the reflection.
  115176. * 0 by Default.
  115177. */
  115178. groundMirrorFallOffDistance: number;
  115179. /**
  115180. * Specifies the ground mirror texture type.
  115181. * Unsigned Int by Default.
  115182. */
  115183. groundMirrorTextureType: number;
  115184. /**
  115185. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  115186. * the shown objects.
  115187. */
  115188. groundYBias: number;
  115189. /**
  115190. * Specifies wether or not to create a skybox.
  115191. * True by default.
  115192. */
  115193. createSkybox: boolean;
  115194. /**
  115195. * Specifies the skybox size.
  115196. * 20 by default.
  115197. */
  115198. skyboxSize: number;
  115199. /**
  115200. * The texture used on the skybox for the main color.
  115201. * Comes from the BabylonJS CDN by default.
  115202. *
  115203. * Remarks: Can be either a texture or a url.
  115204. */
  115205. skyboxTexture: string | BaseTexture;
  115206. /**
  115207. * The color mixed in the skybox texture by default.
  115208. * BabylonJS clearColor by default.
  115209. */
  115210. skyboxColor: Color3;
  115211. /**
  115212. * The background rotation around the Y axis of the scene.
  115213. * This helps aligning the key lights of your scene with the background.
  115214. * 0 by default.
  115215. */
  115216. backgroundYRotation: number;
  115217. /**
  115218. * Compute automatically the size of the elements to best fit with the scene.
  115219. */
  115220. sizeAuto: boolean;
  115221. /**
  115222. * Default position of the rootMesh if autoSize is not true.
  115223. */
  115224. rootPosition: Vector3;
  115225. /**
  115226. * Sets up the image processing in the scene.
  115227. * true by default.
  115228. */
  115229. setupImageProcessing: boolean;
  115230. /**
  115231. * The texture used as your environment texture in the scene.
  115232. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  115233. *
  115234. * Remarks: Can be either a texture or a url.
  115235. */
  115236. environmentTexture: string | BaseTexture;
  115237. /**
  115238. * The value of the exposure to apply to the scene.
  115239. * 0.6 by default if setupImageProcessing is true.
  115240. */
  115241. cameraExposure: number;
  115242. /**
  115243. * The value of the contrast to apply to the scene.
  115244. * 1.6 by default if setupImageProcessing is true.
  115245. */
  115246. cameraContrast: number;
  115247. /**
  115248. * Specifies wether or not tonemapping should be enabled in the scene.
  115249. * true by default if setupImageProcessing is true.
  115250. */
  115251. toneMappingEnabled: boolean;
  115252. }
  115253. /**
  115254. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  115255. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  115256. * It also helps with the default setup of your imageProcessing configuration.
  115257. */
  115258. export class EnvironmentHelper {
  115259. /**
  115260. * Default ground texture URL.
  115261. */
  115262. private static _groundTextureCDNUrl;
  115263. /**
  115264. * Default skybox texture URL.
  115265. */
  115266. private static _skyboxTextureCDNUrl;
  115267. /**
  115268. * Default environment texture URL.
  115269. */
  115270. private static _environmentTextureCDNUrl;
  115271. /**
  115272. * Creates the default options for the helper.
  115273. */
  115274. private static _getDefaultOptions;
  115275. private _rootMesh;
  115276. /**
  115277. * Gets the root mesh created by the helper.
  115278. */
  115279. readonly rootMesh: Mesh;
  115280. private _skybox;
  115281. /**
  115282. * Gets the skybox created by the helper.
  115283. */
  115284. readonly skybox: Nullable<Mesh>;
  115285. private _skyboxTexture;
  115286. /**
  115287. * Gets the skybox texture created by the helper.
  115288. */
  115289. readonly skyboxTexture: Nullable<BaseTexture>;
  115290. private _skyboxMaterial;
  115291. /**
  115292. * Gets the skybox material created by the helper.
  115293. */
  115294. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  115295. private _ground;
  115296. /**
  115297. * Gets the ground mesh created by the helper.
  115298. */
  115299. readonly ground: Nullable<Mesh>;
  115300. private _groundTexture;
  115301. /**
  115302. * Gets the ground texture created by the helper.
  115303. */
  115304. readonly groundTexture: Nullable<BaseTexture>;
  115305. private _groundMirror;
  115306. /**
  115307. * Gets the ground mirror created by the helper.
  115308. */
  115309. readonly groundMirror: Nullable<MirrorTexture>;
  115310. /**
  115311. * Gets the ground mirror render list to helps pushing the meshes
  115312. * you wish in the ground reflection.
  115313. */
  115314. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  115315. private _groundMaterial;
  115316. /**
  115317. * Gets the ground material created by the helper.
  115318. */
  115319. readonly groundMaterial: Nullable<BackgroundMaterial>;
  115320. /**
  115321. * Stores the creation options.
  115322. */
  115323. private readonly _scene;
  115324. private _options;
  115325. /**
  115326. * This observable will be notified with any error during the creation of the environment,
  115327. * mainly texture creation errors.
  115328. */
  115329. onErrorObservable: Observable<{
  115330. message?: string;
  115331. exception?: any;
  115332. }>;
  115333. /**
  115334. * constructor
  115335. * @param options Defines the options we want to customize the helper
  115336. * @param scene The scene to add the material to
  115337. */
  115338. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  115339. /**
  115340. * Updates the background according to the new options
  115341. * @param options
  115342. */
  115343. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  115344. /**
  115345. * Sets the primary color of all the available elements.
  115346. * @param color the main color to affect to the ground and the background
  115347. */
  115348. setMainColor(color: Color3): void;
  115349. /**
  115350. * Setup the image processing according to the specified options.
  115351. */
  115352. private _setupImageProcessing;
  115353. /**
  115354. * Setup the environment texture according to the specified options.
  115355. */
  115356. private _setupEnvironmentTexture;
  115357. /**
  115358. * Setup the background according to the specified options.
  115359. */
  115360. private _setupBackground;
  115361. /**
  115362. * Get the scene sizes according to the setup.
  115363. */
  115364. private _getSceneSize;
  115365. /**
  115366. * Setup the ground according to the specified options.
  115367. */
  115368. private _setupGround;
  115369. /**
  115370. * Setup the ground material according to the specified options.
  115371. */
  115372. private _setupGroundMaterial;
  115373. /**
  115374. * Setup the ground diffuse texture according to the specified options.
  115375. */
  115376. private _setupGroundDiffuseTexture;
  115377. /**
  115378. * Setup the ground mirror texture according to the specified options.
  115379. */
  115380. private _setupGroundMirrorTexture;
  115381. /**
  115382. * Setup the ground to receive the mirror texture.
  115383. */
  115384. private _setupMirrorInGroundMaterial;
  115385. /**
  115386. * Setup the skybox according to the specified options.
  115387. */
  115388. private _setupSkybox;
  115389. /**
  115390. * Setup the skybox material according to the specified options.
  115391. */
  115392. private _setupSkyboxMaterial;
  115393. /**
  115394. * Setup the skybox reflection texture according to the specified options.
  115395. */
  115396. private _setupSkyboxReflectionTexture;
  115397. private _errorHandler;
  115398. /**
  115399. * Dispose all the elements created by the Helper.
  115400. */
  115401. dispose(): void;
  115402. }
  115403. }
  115404. declare module BABYLON {
  115405. /**
  115406. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  115407. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  115408. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  115409. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115410. */
  115411. export class PhotoDome extends TransformNode {
  115412. /**
  115413. * Define the image as a Monoscopic panoramic 360 image.
  115414. */
  115415. static readonly MODE_MONOSCOPIC: number;
  115416. /**
  115417. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  115418. */
  115419. static readonly MODE_TOPBOTTOM: number;
  115420. /**
  115421. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  115422. */
  115423. static readonly MODE_SIDEBYSIDE: number;
  115424. private _useDirectMapping;
  115425. /**
  115426. * The texture being displayed on the sphere
  115427. */
  115428. protected _photoTexture: Texture;
  115429. /**
  115430. * Gets or sets the texture being displayed on the sphere
  115431. */
  115432. photoTexture: Texture;
  115433. /**
  115434. * Observable raised when an error occured while loading the 360 image
  115435. */
  115436. onLoadErrorObservable: Observable<string>;
  115437. /**
  115438. * The skybox material
  115439. */
  115440. protected _material: BackgroundMaterial;
  115441. /**
  115442. * The surface used for the skybox
  115443. */
  115444. protected _mesh: Mesh;
  115445. /**
  115446. * Gets the mesh used for the skybox.
  115447. */
  115448. readonly mesh: Mesh;
  115449. /**
  115450. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115451. * Also see the options.resolution property.
  115452. */
  115453. fovMultiplier: number;
  115454. private _imageMode;
  115455. /**
  115456. * Gets or set the current video mode for the video. It can be:
  115457. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  115458. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  115459. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  115460. */
  115461. imageMode: number;
  115462. /**
  115463. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  115464. * @param name Element's name, child elements will append suffixes for their own names.
  115465. * @param urlsOfPhoto defines the url of the photo to display
  115466. * @param options defines an object containing optional or exposed sub element properties
  115467. * @param onError defines a callback called when an error occured while loading the texture
  115468. */
  115469. constructor(name: string, urlOfPhoto: string, options: {
  115470. resolution?: number;
  115471. size?: number;
  115472. useDirectMapping?: boolean;
  115473. faceForward?: boolean;
  115474. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  115475. private _onBeforeCameraRenderObserver;
  115476. private _changeImageMode;
  115477. /**
  115478. * Releases resources associated with this node.
  115479. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115480. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115481. */
  115482. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115483. }
  115484. }
  115485. declare module BABYLON {
  115486. /**
  115487. * Class used to host RGBD texture specific utilities
  115488. */
  115489. export class RGBDTextureTools {
  115490. /**
  115491. * Expand the RGBD Texture from RGBD to Half Float if possible.
  115492. * @param texture the texture to expand.
  115493. */
  115494. static ExpandRGBDTexture(texture: Texture): void;
  115495. }
  115496. }
  115497. declare module BABYLON {
  115498. /**
  115499. * Class used to host texture specific utilities
  115500. */
  115501. export class BRDFTextureTools {
  115502. /**
  115503. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  115504. * @param scene defines the hosting scene
  115505. * @returns the environment BRDF texture
  115506. */
  115507. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  115508. private static _environmentBRDFBase64Texture;
  115509. }
  115510. }
  115511. declare module BABYLON {
  115512. /**
  115513. * @hidden
  115514. */
  115515. export interface IMaterialClearCoatDefines {
  115516. CLEARCOAT: boolean;
  115517. CLEARCOAT_DEFAULTIOR: boolean;
  115518. CLEARCOAT_TEXTURE: boolean;
  115519. CLEARCOAT_TEXTUREDIRECTUV: number;
  115520. CLEARCOAT_BUMP: boolean;
  115521. CLEARCOAT_BUMPDIRECTUV: number;
  115522. CLEARCOAT_TINT: boolean;
  115523. CLEARCOAT_TINT_TEXTURE: boolean;
  115524. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  115525. /** @hidden */
  115526. _areTexturesDirty: boolean;
  115527. }
  115528. /**
  115529. * Define the code related to the clear coat parameters of the pbr material.
  115530. */
  115531. export class PBRClearCoatConfiguration {
  115532. /**
  115533. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  115534. * The default fits with a polyurethane material.
  115535. */
  115536. private static readonly _DefaultIndexOfRefraction;
  115537. private _isEnabled;
  115538. /**
  115539. * Defines if the clear coat is enabled in the material.
  115540. */
  115541. isEnabled: boolean;
  115542. /**
  115543. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  115544. */
  115545. intensity: number;
  115546. /**
  115547. * Defines the clear coat layer roughness.
  115548. */
  115549. roughness: number;
  115550. private _indexOfRefraction;
  115551. /**
  115552. * Defines the index of refraction of the clear coat.
  115553. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  115554. * The default fits with a polyurethane material.
  115555. * Changing the default value is more performance intensive.
  115556. */
  115557. indexOfRefraction: number;
  115558. private _texture;
  115559. /**
  115560. * Stores the clear coat values in a texture.
  115561. */
  115562. texture: Nullable<BaseTexture>;
  115563. private _bumpTexture;
  115564. /**
  115565. * Define the clear coat specific bump texture.
  115566. */
  115567. bumpTexture: Nullable<BaseTexture>;
  115568. private _isTintEnabled;
  115569. /**
  115570. * Defines if the clear coat tint is enabled in the material.
  115571. */
  115572. isTintEnabled: boolean;
  115573. /**
  115574. * Defines the clear coat tint of the material.
  115575. * This is only use if tint is enabled
  115576. */
  115577. tintColor: Color3;
  115578. /**
  115579. * Defines the distance at which the tint color should be found in the
  115580. * clear coat media.
  115581. * This is only use if tint is enabled
  115582. */
  115583. tintColorAtDistance: number;
  115584. /**
  115585. * Defines the clear coat layer thickness.
  115586. * This is only use if tint is enabled
  115587. */
  115588. tintThickness: number;
  115589. private _tintTexture;
  115590. /**
  115591. * Stores the clear tint values in a texture.
  115592. * rgb is tint
  115593. * a is a thickness factor
  115594. */
  115595. tintTexture: Nullable<BaseTexture>;
  115596. /** @hidden */
  115597. private _internalMarkAllSubMeshesAsTexturesDirty;
  115598. /** @hidden */
  115599. _markAllSubMeshesAsTexturesDirty(): void;
  115600. /**
  115601. * Instantiate a new istance of clear coat configuration.
  115602. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115603. */
  115604. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115605. /**
  115606. * Gets wehter the submesh is ready to be used or not.
  115607. * @param defines the list of "defines" to update.
  115608. * @param scene defines the scene the material belongs to.
  115609. * @param engine defines the engine the material belongs to.
  115610. * @param disableBumpMap defines wether the material disables bump or not.
  115611. * @returns - boolean indicating that the submesh is ready or not.
  115612. */
  115613. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  115614. /**
  115615. * Checks to see if a texture is used in the material.
  115616. * @param defines the list of "defines" to update.
  115617. * @param scene defines the scene to the material belongs to.
  115618. */
  115619. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  115620. /**
  115621. * Binds the material data.
  115622. * @param uniformBuffer defines the Uniform buffer to fill in.
  115623. * @param scene defines the scene the material belongs to.
  115624. * @param engine defines the engine the material belongs to.
  115625. * @param disableBumpMap defines wether the material disables bump or not.
  115626. * @param isFrozen defines wether the material is frozen or not.
  115627. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  115628. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  115629. */
  115630. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  115631. /**
  115632. * Checks to see if a texture is used in the material.
  115633. * @param texture - Base texture to use.
  115634. * @returns - Boolean specifying if a texture is used in the material.
  115635. */
  115636. hasTexture(texture: BaseTexture): boolean;
  115637. /**
  115638. * Returns an array of the actively used textures.
  115639. * @param activeTextures Array of BaseTextures
  115640. */
  115641. getActiveTextures(activeTextures: BaseTexture[]): void;
  115642. /**
  115643. * Returns the animatable textures.
  115644. * @param animatables Array of animatable textures.
  115645. */
  115646. getAnimatables(animatables: IAnimatable[]): void;
  115647. /**
  115648. * Disposes the resources of the material.
  115649. * @param forceDisposeTextures - Forces the disposal of all textures.
  115650. */
  115651. dispose(forceDisposeTextures?: boolean): void;
  115652. /**
  115653. * Get the current class name of the texture useful for serialization or dynamic coding.
  115654. * @returns "PBRClearCoatConfiguration"
  115655. */
  115656. getClassName(): string;
  115657. /**
  115658. * Add fallbacks to the effect fallbacks list.
  115659. * @param defines defines the Base texture to use.
  115660. * @param fallbacks defines the current fallback list.
  115661. * @param currentRank defines the current fallback rank.
  115662. * @returns the new fallback rank.
  115663. */
  115664. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115665. /**
  115666. * Add the required uniforms to the current list.
  115667. * @param uniforms defines the current uniform list.
  115668. */
  115669. static AddUniforms(uniforms: string[]): 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. * Add the required uniforms to the current buffer.
  115677. * @param uniformBuffer defines the current uniform buffer.
  115678. */
  115679. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115680. /**
  115681. * Makes a duplicate of the current configuration into another one.
  115682. * @param clearCoatConfiguration define the config where to copy the info
  115683. */
  115684. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  115685. /**
  115686. * Serializes this clear coat configuration.
  115687. * @returns - An object with the serialized config.
  115688. */
  115689. serialize(): any;
  115690. /**
  115691. * Parses a anisotropy Configuration from a serialized object.
  115692. * @param source - Serialized object.
  115693. * @param scene Defines the scene we are parsing for
  115694. * @param rootUrl Defines the rootUrl to load from
  115695. */
  115696. parse(source: any, scene: Scene, rootUrl: string): void;
  115697. }
  115698. }
  115699. declare module BABYLON {
  115700. /**
  115701. * @hidden
  115702. */
  115703. export interface IMaterialAnisotropicDefines {
  115704. ANISOTROPIC: boolean;
  115705. ANISOTROPIC_TEXTURE: boolean;
  115706. ANISOTROPIC_TEXTUREDIRECTUV: number;
  115707. MAINUV1: boolean;
  115708. _areTexturesDirty: boolean;
  115709. _needUVs: boolean;
  115710. }
  115711. /**
  115712. * Define the code related to the anisotropic parameters of the pbr material.
  115713. */
  115714. export class PBRAnisotropicConfiguration {
  115715. private _isEnabled;
  115716. /**
  115717. * Defines if the anisotropy is enabled in the material.
  115718. */
  115719. isEnabled: boolean;
  115720. /**
  115721. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  115722. */
  115723. intensity: number;
  115724. /**
  115725. * Defines if the effect is along the tangents, bitangents or in between.
  115726. * By default, the effect is "strectching" the highlights along the tangents.
  115727. */
  115728. direction: Vector2;
  115729. private _texture;
  115730. /**
  115731. * Stores the anisotropy values in a texture.
  115732. * rg is direction (like normal from -1 to 1)
  115733. * b is a intensity
  115734. */
  115735. texture: Nullable<BaseTexture>;
  115736. /** @hidden */
  115737. private _internalMarkAllSubMeshesAsTexturesDirty;
  115738. /** @hidden */
  115739. _markAllSubMeshesAsTexturesDirty(): void;
  115740. /**
  115741. * Instantiate a new istance of anisotropy configuration.
  115742. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115743. */
  115744. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115745. /**
  115746. * Specifies that the submesh is ready to be used.
  115747. * @param defines the list of "defines" to update.
  115748. * @param scene defines the scene the material belongs to.
  115749. * @returns - boolean indicating that the submesh is ready or not.
  115750. */
  115751. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  115752. /**
  115753. * Checks to see if a texture is used in the material.
  115754. * @param defines the list of "defines" to update.
  115755. * @param mesh the mesh we are preparing the defines for.
  115756. * @param scene defines the scene the material belongs to.
  115757. */
  115758. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  115759. /**
  115760. * Binds the material data.
  115761. * @param uniformBuffer defines the Uniform buffer to fill in.
  115762. * @param scene defines the scene the material belongs to.
  115763. * @param isFrozen defines wether the material is frozen or not.
  115764. */
  115765. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  115766. /**
  115767. * Checks to see if a texture is used in the material.
  115768. * @param texture - Base texture to use.
  115769. * @returns - Boolean specifying if a texture is used in the material.
  115770. */
  115771. hasTexture(texture: BaseTexture): boolean;
  115772. /**
  115773. * Returns an array of the actively used textures.
  115774. * @param activeTextures Array of BaseTextures
  115775. */
  115776. getActiveTextures(activeTextures: BaseTexture[]): void;
  115777. /**
  115778. * Returns the animatable textures.
  115779. * @param animatables Array of animatable textures.
  115780. */
  115781. getAnimatables(animatables: IAnimatable[]): void;
  115782. /**
  115783. * Disposes the resources of the material.
  115784. * @param forceDisposeTextures - Forces the disposal of all textures.
  115785. */
  115786. dispose(forceDisposeTextures?: boolean): void;
  115787. /**
  115788. * Get the current class name of the texture useful for serialization or dynamic coding.
  115789. * @returns "PBRAnisotropicConfiguration"
  115790. */
  115791. getClassName(): string;
  115792. /**
  115793. * Add fallbacks to the effect fallbacks list.
  115794. * @param defines defines the Base texture to use.
  115795. * @param fallbacks defines the current fallback list.
  115796. * @param currentRank defines the current fallback rank.
  115797. * @returns the new fallback rank.
  115798. */
  115799. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115800. /**
  115801. * Add the required uniforms to the current list.
  115802. * @param uniforms defines the current uniform list.
  115803. */
  115804. static AddUniforms(uniforms: string[]): void;
  115805. /**
  115806. * Add the required uniforms to the current buffer.
  115807. * @param uniformBuffer defines the current uniform buffer.
  115808. */
  115809. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115810. /**
  115811. * Add the required samplers to the current list.
  115812. * @param samplers defines the current sampler list.
  115813. */
  115814. static AddSamplers(samplers: string[]): void;
  115815. /**
  115816. * Makes a duplicate of the current configuration into another one.
  115817. * @param anisotropicConfiguration define the config where to copy the info
  115818. */
  115819. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  115820. /**
  115821. * Serializes this anisotropy configuration.
  115822. * @returns - An object with the serialized config.
  115823. */
  115824. serialize(): any;
  115825. /**
  115826. * Parses a anisotropy Configuration from a serialized object.
  115827. * @param source - Serialized object.
  115828. * @param scene Defines the scene we are parsing for
  115829. * @param rootUrl Defines the rootUrl to load from
  115830. */
  115831. parse(source: any, scene: Scene, rootUrl: string): void;
  115832. }
  115833. }
  115834. declare module BABYLON {
  115835. /**
  115836. * @hidden
  115837. */
  115838. export interface IMaterialBRDFDefines {
  115839. BRDF_V_HEIGHT_CORRELATED: boolean;
  115840. MS_BRDF_ENERGY_CONSERVATION: boolean;
  115841. SPHERICAL_HARMONICS: boolean;
  115842. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  115843. /** @hidden */
  115844. _areMiscDirty: boolean;
  115845. }
  115846. /**
  115847. * Define the code related to the BRDF parameters of the pbr material.
  115848. */
  115849. export class PBRBRDFConfiguration {
  115850. /**
  115851. * Default value used for the energy conservation.
  115852. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  115853. */
  115854. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  115855. /**
  115856. * Default value used for the Smith Visibility Height Correlated mode.
  115857. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  115858. */
  115859. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  115860. /**
  115861. * Default value used for the IBL diffuse part.
  115862. * This can help switching back to the polynomials mode globally which is a tiny bit
  115863. * less GPU intensive at the drawback of a lower quality.
  115864. */
  115865. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  115866. /**
  115867. * Default value used for activating energy conservation for the specular workflow.
  115868. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  115869. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  115870. */
  115871. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  115872. private _useEnergyConservation;
  115873. /**
  115874. * Defines if the material uses energy conservation.
  115875. */
  115876. useEnergyConservation: boolean;
  115877. private _useSmithVisibilityHeightCorrelated;
  115878. /**
  115879. * LEGACY Mode set to false
  115880. * Defines if the material uses height smith correlated visibility term.
  115881. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  115882. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  115883. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  115884. * Not relying on height correlated will also disable energy conservation.
  115885. */
  115886. useSmithVisibilityHeightCorrelated: boolean;
  115887. private _useSphericalHarmonics;
  115888. /**
  115889. * LEGACY Mode set to false
  115890. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  115891. * diffuse part of the IBL.
  115892. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  115893. * to the ground truth.
  115894. */
  115895. useSphericalHarmonics: boolean;
  115896. private _useSpecularGlossinessInputEnergyConservation;
  115897. /**
  115898. * Defines if the material uses energy conservation, when the specular workflow is active.
  115899. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  115900. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  115901. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  115902. */
  115903. useSpecularGlossinessInputEnergyConservation: boolean;
  115904. /** @hidden */
  115905. private _internalMarkAllSubMeshesAsMiscDirty;
  115906. /** @hidden */
  115907. _markAllSubMeshesAsMiscDirty(): void;
  115908. /**
  115909. * Instantiate a new istance of clear coat configuration.
  115910. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  115911. */
  115912. constructor(markAllSubMeshesAsMiscDirty: () => void);
  115913. /**
  115914. * Checks to see if a texture is used in the material.
  115915. * @param defines the list of "defines" to update.
  115916. */
  115917. prepareDefines(defines: IMaterialBRDFDefines): void;
  115918. /**
  115919. * Get the current class name of the texture useful for serialization or dynamic coding.
  115920. * @returns "PBRClearCoatConfiguration"
  115921. */
  115922. getClassName(): string;
  115923. /**
  115924. * Makes a duplicate of the current configuration into another one.
  115925. * @param brdfConfiguration define the config where to copy the info
  115926. */
  115927. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  115928. /**
  115929. * Serializes this BRDF configuration.
  115930. * @returns - An object with the serialized config.
  115931. */
  115932. serialize(): any;
  115933. /**
  115934. * Parses a anisotropy Configuration from a serialized object.
  115935. * @param source - Serialized object.
  115936. * @param scene Defines the scene we are parsing for
  115937. * @param rootUrl Defines the rootUrl to load from
  115938. */
  115939. parse(source: any, scene: Scene, rootUrl: string): void;
  115940. }
  115941. }
  115942. declare module BABYLON {
  115943. /**
  115944. * @hidden
  115945. */
  115946. export interface IMaterialSheenDefines {
  115947. SHEEN: boolean;
  115948. SHEEN_TEXTURE: boolean;
  115949. SHEEN_TEXTUREDIRECTUV: number;
  115950. SHEEN_LINKWITHALBEDO: boolean;
  115951. /** @hidden */
  115952. _areTexturesDirty: boolean;
  115953. }
  115954. /**
  115955. * Define the code related to the Sheen parameters of the pbr material.
  115956. */
  115957. export class PBRSheenConfiguration {
  115958. private _isEnabled;
  115959. /**
  115960. * Defines if the material uses sheen.
  115961. */
  115962. isEnabled: boolean;
  115963. private _linkSheenWithAlbedo;
  115964. /**
  115965. * Defines if the sheen is linked to the sheen color.
  115966. */
  115967. linkSheenWithAlbedo: boolean;
  115968. /**
  115969. * Defines the sheen intensity.
  115970. */
  115971. intensity: number;
  115972. /**
  115973. * Defines the sheen color.
  115974. */
  115975. color: Color3;
  115976. private _texture;
  115977. /**
  115978. * Stores the sheen tint values in a texture.
  115979. * rgb is tint
  115980. * a is a intensity
  115981. */
  115982. texture: Nullable<BaseTexture>;
  115983. /** @hidden */
  115984. private _internalMarkAllSubMeshesAsTexturesDirty;
  115985. /** @hidden */
  115986. _markAllSubMeshesAsTexturesDirty(): void;
  115987. /**
  115988. * Instantiate a new istance of clear coat configuration.
  115989. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115990. */
  115991. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115992. /**
  115993. * Specifies that the submesh is ready to be used.
  115994. * @param defines the list of "defines" to update.
  115995. * @param scene defines the scene the material belongs to.
  115996. * @returns - boolean indicating that the submesh is ready or not.
  115997. */
  115998. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  115999. /**
  116000. * Checks to see if a texture is used in the material.
  116001. * @param defines the list of "defines" to update.
  116002. * @param scene defines the scene the material belongs to.
  116003. */
  116004. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  116005. /**
  116006. * Binds the material data.
  116007. * @param uniformBuffer defines the Uniform buffer to fill in.
  116008. * @param scene defines the scene the material belongs to.
  116009. * @param isFrozen defines wether the material is frozen or not.
  116010. */
  116011. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  116012. /**
  116013. * Checks to see if a texture is used in the material.
  116014. * @param texture - Base texture to use.
  116015. * @returns - Boolean specifying if a texture is used in the material.
  116016. */
  116017. hasTexture(texture: BaseTexture): boolean;
  116018. /**
  116019. * Returns an array of the actively used textures.
  116020. * @param activeTextures Array of BaseTextures
  116021. */
  116022. getActiveTextures(activeTextures: BaseTexture[]): void;
  116023. /**
  116024. * Returns the animatable textures.
  116025. * @param animatables Array of animatable textures.
  116026. */
  116027. getAnimatables(animatables: IAnimatable[]): void;
  116028. /**
  116029. * Disposes the resources of the material.
  116030. * @param forceDisposeTextures - Forces the disposal of all textures.
  116031. */
  116032. dispose(forceDisposeTextures?: boolean): void;
  116033. /**
  116034. * Get the current class name of the texture useful for serialization or dynamic coding.
  116035. * @returns "PBRSheenConfiguration"
  116036. */
  116037. getClassName(): string;
  116038. /**
  116039. * Add fallbacks to the effect fallbacks list.
  116040. * @param defines defines the Base texture to use.
  116041. * @param fallbacks defines the current fallback list.
  116042. * @param currentRank defines the current fallback rank.
  116043. * @returns the new fallback rank.
  116044. */
  116045. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116046. /**
  116047. * Add the required uniforms to the current list.
  116048. * @param uniforms defines the current uniform list.
  116049. */
  116050. static AddUniforms(uniforms: string[]): void;
  116051. /**
  116052. * Add the required uniforms to the current buffer.
  116053. * @param uniformBuffer defines the current uniform buffer.
  116054. */
  116055. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116056. /**
  116057. * Add the required samplers to the current list.
  116058. * @param samplers defines the current sampler list.
  116059. */
  116060. static AddSamplers(samplers: string[]): void;
  116061. /**
  116062. * Makes a duplicate of the current configuration into another one.
  116063. * @param sheenConfiguration define the config where to copy the info
  116064. */
  116065. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  116066. /**
  116067. * Serializes this BRDF configuration.
  116068. * @returns - An object with the serialized config.
  116069. */
  116070. serialize(): any;
  116071. /**
  116072. * Parses a anisotropy Configuration from a serialized object.
  116073. * @param source - Serialized object.
  116074. * @param scene Defines the scene we are parsing for
  116075. * @param rootUrl Defines the rootUrl to load from
  116076. */
  116077. parse(source: any, scene: Scene, rootUrl: string): void;
  116078. }
  116079. }
  116080. declare module BABYLON {
  116081. /**
  116082. * @hidden
  116083. */
  116084. export interface IMaterialSubSurfaceDefines {
  116085. SUBSURFACE: boolean;
  116086. SS_REFRACTION: boolean;
  116087. SS_TRANSLUCENCY: boolean;
  116088. SS_SCATERRING: boolean;
  116089. SS_THICKNESSANDMASK_TEXTURE: boolean;
  116090. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  116091. SS_REFRACTIONMAP_3D: boolean;
  116092. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  116093. SS_LODINREFRACTIONALPHA: boolean;
  116094. SS_GAMMAREFRACTION: boolean;
  116095. SS_RGBDREFRACTION: boolean;
  116096. SS_LINEARSPECULARREFRACTION: boolean;
  116097. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  116098. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  116099. /** @hidden */
  116100. _areTexturesDirty: boolean;
  116101. }
  116102. /**
  116103. * Define the code related to the sub surface parameters of the pbr material.
  116104. */
  116105. export class PBRSubSurfaceConfiguration {
  116106. private _isRefractionEnabled;
  116107. /**
  116108. * Defines if the refraction is enabled in the material.
  116109. */
  116110. isRefractionEnabled: boolean;
  116111. private _isTranslucencyEnabled;
  116112. /**
  116113. * Defines if the translucency is enabled in the material.
  116114. */
  116115. isTranslucencyEnabled: boolean;
  116116. private _isScatteringEnabled;
  116117. /**
  116118. * Defines the refraction intensity of the material.
  116119. * The refraction when enabled replaces the Diffuse part of the material.
  116120. * The intensity helps transitionning between diffuse and refraction.
  116121. */
  116122. refractionIntensity: number;
  116123. /**
  116124. * Defines the translucency intensity of the material.
  116125. * When translucency has been enabled, this defines how much of the "translucency"
  116126. * is addded to the diffuse part of the material.
  116127. */
  116128. translucencyIntensity: number;
  116129. /**
  116130. * Defines the scattering intensity of the material.
  116131. * When scattering has been enabled, this defines how much of the "scattered light"
  116132. * is addded to the diffuse part of the material.
  116133. */
  116134. scatteringIntensity: number;
  116135. private _thicknessTexture;
  116136. /**
  116137. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  116138. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  116139. * 0 would mean minimumThickness
  116140. * 1 would mean maximumThickness
  116141. * The other channels might be use as a mask to vary the different effects intensity.
  116142. */
  116143. thicknessTexture: Nullable<BaseTexture>;
  116144. private _refractionTexture;
  116145. /**
  116146. * Defines the texture to use for refraction.
  116147. */
  116148. refractionTexture: Nullable<BaseTexture>;
  116149. private _indexOfRefraction;
  116150. /**
  116151. * Defines the index of refraction used in the material.
  116152. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  116153. */
  116154. indexOfRefraction: number;
  116155. private _invertRefractionY;
  116156. /**
  116157. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  116158. */
  116159. invertRefractionY: boolean;
  116160. private _linkRefractionWithTransparency;
  116161. /**
  116162. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  116163. * Materials half opaque for instance using refraction could benefit from this control.
  116164. */
  116165. linkRefractionWithTransparency: boolean;
  116166. /**
  116167. * Defines the minimum thickness stored in the thickness map.
  116168. * If no thickness map is defined, this value will be used to simulate thickness.
  116169. */
  116170. minimumThickness: number;
  116171. /**
  116172. * Defines the maximum thickness stored in the thickness map.
  116173. */
  116174. maximumThickness: number;
  116175. /**
  116176. * Defines the volume tint of the material.
  116177. * This is used for both translucency and scattering.
  116178. */
  116179. tintColor: Color3;
  116180. /**
  116181. * Defines the distance at which the tint color should be found in the media.
  116182. * This is used for refraction only.
  116183. */
  116184. tintColorAtDistance: number;
  116185. /**
  116186. * Defines how far each channel transmit through the media.
  116187. * It is defined as a color to simplify it selection.
  116188. */
  116189. diffusionDistance: Color3;
  116190. private _useMaskFromThicknessTexture;
  116191. /**
  116192. * Stores the intensity of the different subsurface effects in the thickness texture.
  116193. * * the green channel is the translucency intensity.
  116194. * * the blue channel is the scattering intensity.
  116195. * * the alpha channel is the refraction intensity.
  116196. */
  116197. useMaskFromThicknessTexture: boolean;
  116198. /** @hidden */
  116199. private _internalMarkAllSubMeshesAsTexturesDirty;
  116200. /** @hidden */
  116201. _markAllSubMeshesAsTexturesDirty(): void;
  116202. /**
  116203. * Instantiate a new istance of sub surface configuration.
  116204. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116205. */
  116206. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116207. /**
  116208. * Gets wehter the submesh is ready to be used or not.
  116209. * @param defines the list of "defines" to update.
  116210. * @param scene defines the scene the material belongs to.
  116211. * @returns - boolean indicating that the submesh is ready or not.
  116212. */
  116213. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  116214. /**
  116215. * Checks to see if a texture is used in the material.
  116216. * @param defines the list of "defines" to update.
  116217. * @param scene defines the scene to the material belongs to.
  116218. */
  116219. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  116220. /**
  116221. * Binds the material data.
  116222. * @param uniformBuffer defines the Uniform buffer to fill in.
  116223. * @param scene defines the scene the material belongs to.
  116224. * @param engine defines the engine the material belongs to.
  116225. * @param isFrozen defines wether the material is frozen or not.
  116226. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  116227. */
  116228. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  116229. /**
  116230. * Unbinds the material from the mesh.
  116231. * @param activeEffect defines the effect that should be unbound from.
  116232. * @returns true if unbound, otherwise false
  116233. */
  116234. unbind(activeEffect: Effect): boolean;
  116235. /**
  116236. * Returns the texture used for refraction or null if none is used.
  116237. * @param scene defines the scene the material belongs to.
  116238. * @returns - Refraction texture if present. If no refraction texture and refraction
  116239. * is linked with transparency, returns environment texture. Otherwise, returns null.
  116240. */
  116241. private _getRefractionTexture;
  116242. /**
  116243. * Returns true if alpha blending should be disabled.
  116244. */
  116245. readonly disableAlphaBlending: boolean;
  116246. /**
  116247. * Fills the list of render target textures.
  116248. * @param renderTargets the list of render targets to update
  116249. */
  116250. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  116251. /**
  116252. * Checks to see if a texture is used in the material.
  116253. * @param texture - Base texture to use.
  116254. * @returns - Boolean specifying if a texture is used in the material.
  116255. */
  116256. hasTexture(texture: BaseTexture): boolean;
  116257. /**
  116258. * Gets a boolean indicating that current material needs to register RTT
  116259. * @returns true if this uses a render target otherwise false.
  116260. */
  116261. hasRenderTargetTextures(): boolean;
  116262. /**
  116263. * Returns an array of the actively used textures.
  116264. * @param activeTextures Array of BaseTextures
  116265. */
  116266. getActiveTextures(activeTextures: BaseTexture[]): void;
  116267. /**
  116268. * Returns the animatable textures.
  116269. * @param animatables Array of animatable textures.
  116270. */
  116271. getAnimatables(animatables: IAnimatable[]): void;
  116272. /**
  116273. * Disposes the resources of the material.
  116274. * @param forceDisposeTextures - Forces the disposal of all textures.
  116275. */
  116276. dispose(forceDisposeTextures?: boolean): void;
  116277. /**
  116278. * Get the current class name of the texture useful for serialization or dynamic coding.
  116279. * @returns "PBRSubSurfaceConfiguration"
  116280. */
  116281. getClassName(): string;
  116282. /**
  116283. * Add fallbacks to the effect fallbacks list.
  116284. * @param defines defines the Base texture to use.
  116285. * @param fallbacks defines the current fallback list.
  116286. * @param currentRank defines the current fallback rank.
  116287. * @returns the new fallback rank.
  116288. */
  116289. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116290. /**
  116291. * Add the required uniforms to the current list.
  116292. * @param uniforms defines the current uniform list.
  116293. */
  116294. static AddUniforms(uniforms: string[]): void;
  116295. /**
  116296. * Add the required samplers to the current list.
  116297. * @param samplers defines the current sampler list.
  116298. */
  116299. static AddSamplers(samplers: string[]): void;
  116300. /**
  116301. * Add the required uniforms to the current buffer.
  116302. * @param uniformBuffer defines the current uniform buffer.
  116303. */
  116304. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116305. /**
  116306. * Makes a duplicate of the current configuration into another one.
  116307. * @param configuration define the config where to copy the info
  116308. */
  116309. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  116310. /**
  116311. * Serializes this Sub Surface configuration.
  116312. * @returns - An object with the serialized config.
  116313. */
  116314. serialize(): any;
  116315. /**
  116316. * Parses a anisotropy Configuration from a serialized object.
  116317. * @param source - Serialized object.
  116318. * @param scene Defines the scene we are parsing for
  116319. * @param rootUrl Defines the rootUrl to load from
  116320. */
  116321. parse(source: any, scene: Scene, rootUrl: string): void;
  116322. }
  116323. }
  116324. declare module BABYLON {
  116325. /** @hidden */
  116326. export var pbrFragmentDeclaration: {
  116327. name: string;
  116328. shader: string;
  116329. };
  116330. }
  116331. declare module BABYLON {
  116332. /** @hidden */
  116333. export var pbrUboDeclaration: {
  116334. name: string;
  116335. shader: string;
  116336. };
  116337. }
  116338. declare module BABYLON {
  116339. /** @hidden */
  116340. export var pbrFragmentExtraDeclaration: {
  116341. name: string;
  116342. shader: string;
  116343. };
  116344. }
  116345. declare module BABYLON {
  116346. /** @hidden */
  116347. export var pbrFragmentSamplersDeclaration: {
  116348. name: string;
  116349. shader: string;
  116350. };
  116351. }
  116352. declare module BABYLON {
  116353. /** @hidden */
  116354. export var pbrHelperFunctions: {
  116355. name: string;
  116356. shader: string;
  116357. };
  116358. }
  116359. declare module BABYLON {
  116360. /** @hidden */
  116361. export var harmonicsFunctions: {
  116362. name: string;
  116363. shader: string;
  116364. };
  116365. }
  116366. declare module BABYLON {
  116367. /** @hidden */
  116368. export var pbrDirectLightingSetupFunctions: {
  116369. name: string;
  116370. shader: string;
  116371. };
  116372. }
  116373. declare module BABYLON {
  116374. /** @hidden */
  116375. export var pbrDirectLightingFalloffFunctions: {
  116376. name: string;
  116377. shader: string;
  116378. };
  116379. }
  116380. declare module BABYLON {
  116381. /** @hidden */
  116382. export var pbrBRDFFunctions: {
  116383. name: string;
  116384. shader: string;
  116385. };
  116386. }
  116387. declare module BABYLON {
  116388. /** @hidden */
  116389. export var pbrDirectLightingFunctions: {
  116390. name: string;
  116391. shader: string;
  116392. };
  116393. }
  116394. declare module BABYLON {
  116395. /** @hidden */
  116396. export var pbrIBLFunctions: {
  116397. name: string;
  116398. shader: string;
  116399. };
  116400. }
  116401. declare module BABYLON {
  116402. /** @hidden */
  116403. export var pbrDebug: {
  116404. name: string;
  116405. shader: string;
  116406. };
  116407. }
  116408. declare module BABYLON {
  116409. /** @hidden */
  116410. export var pbrPixelShader: {
  116411. name: string;
  116412. shader: string;
  116413. };
  116414. }
  116415. declare module BABYLON {
  116416. /** @hidden */
  116417. export var pbrVertexDeclaration: {
  116418. name: string;
  116419. shader: string;
  116420. };
  116421. }
  116422. declare module BABYLON {
  116423. /** @hidden */
  116424. export var pbrVertexShader: {
  116425. name: string;
  116426. shader: string;
  116427. };
  116428. }
  116429. declare module BABYLON {
  116430. /**
  116431. * Manages the defines for the PBR Material.
  116432. * @hidden
  116433. */
  116434. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  116435. PBR: boolean;
  116436. MAINUV1: boolean;
  116437. MAINUV2: boolean;
  116438. UV1: boolean;
  116439. UV2: boolean;
  116440. ALBEDO: boolean;
  116441. ALBEDODIRECTUV: number;
  116442. VERTEXCOLOR: boolean;
  116443. AMBIENT: boolean;
  116444. AMBIENTDIRECTUV: number;
  116445. AMBIENTINGRAYSCALE: boolean;
  116446. OPACITY: boolean;
  116447. VERTEXALPHA: boolean;
  116448. OPACITYDIRECTUV: number;
  116449. OPACITYRGB: boolean;
  116450. ALPHATEST: boolean;
  116451. DEPTHPREPASS: boolean;
  116452. ALPHABLEND: boolean;
  116453. ALPHAFROMALBEDO: boolean;
  116454. ALPHATESTVALUE: string;
  116455. SPECULAROVERALPHA: boolean;
  116456. RADIANCEOVERALPHA: boolean;
  116457. ALPHAFRESNEL: boolean;
  116458. LINEARALPHAFRESNEL: boolean;
  116459. PREMULTIPLYALPHA: boolean;
  116460. EMISSIVE: boolean;
  116461. EMISSIVEDIRECTUV: number;
  116462. REFLECTIVITY: boolean;
  116463. REFLECTIVITYDIRECTUV: number;
  116464. SPECULARTERM: boolean;
  116465. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  116466. MICROSURFACEAUTOMATIC: boolean;
  116467. LODBASEDMICROSFURACE: boolean;
  116468. MICROSURFACEMAP: boolean;
  116469. MICROSURFACEMAPDIRECTUV: number;
  116470. METALLICWORKFLOW: boolean;
  116471. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  116472. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  116473. METALLNESSSTOREINMETALMAPBLUE: boolean;
  116474. AOSTOREINMETALMAPRED: boolean;
  116475. METALLICF0FACTORFROMMETALLICMAP: boolean;
  116476. ENVIRONMENTBRDF: boolean;
  116477. ENVIRONMENTBRDF_RGBD: boolean;
  116478. NORMAL: boolean;
  116479. TANGENT: boolean;
  116480. BUMP: boolean;
  116481. BUMPDIRECTUV: number;
  116482. OBJECTSPACE_NORMALMAP: boolean;
  116483. PARALLAX: boolean;
  116484. PARALLAXOCCLUSION: boolean;
  116485. NORMALXYSCALE: boolean;
  116486. LIGHTMAP: boolean;
  116487. LIGHTMAPDIRECTUV: number;
  116488. USELIGHTMAPASSHADOWMAP: boolean;
  116489. GAMMALIGHTMAP: boolean;
  116490. RGBDLIGHTMAP: boolean;
  116491. REFLECTION: boolean;
  116492. REFLECTIONMAP_3D: boolean;
  116493. REFLECTIONMAP_SPHERICAL: boolean;
  116494. REFLECTIONMAP_PLANAR: boolean;
  116495. REFLECTIONMAP_CUBIC: boolean;
  116496. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  116497. REFLECTIONMAP_PROJECTION: boolean;
  116498. REFLECTIONMAP_SKYBOX: boolean;
  116499. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  116500. REFLECTIONMAP_EXPLICIT: boolean;
  116501. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  116502. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  116503. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  116504. INVERTCUBICMAP: boolean;
  116505. USESPHERICALFROMREFLECTIONMAP: boolean;
  116506. USEIRRADIANCEMAP: boolean;
  116507. SPHERICAL_HARMONICS: boolean;
  116508. USESPHERICALINVERTEX: boolean;
  116509. REFLECTIONMAP_OPPOSITEZ: boolean;
  116510. LODINREFLECTIONALPHA: boolean;
  116511. GAMMAREFLECTION: boolean;
  116512. RGBDREFLECTION: boolean;
  116513. LINEARSPECULARREFLECTION: boolean;
  116514. RADIANCEOCCLUSION: boolean;
  116515. HORIZONOCCLUSION: boolean;
  116516. INSTANCES: boolean;
  116517. NUM_BONE_INFLUENCERS: number;
  116518. BonesPerMesh: number;
  116519. BONETEXTURE: boolean;
  116520. NONUNIFORMSCALING: boolean;
  116521. MORPHTARGETS: boolean;
  116522. MORPHTARGETS_NORMAL: boolean;
  116523. MORPHTARGETS_TANGENT: boolean;
  116524. MORPHTARGETS_UV: boolean;
  116525. NUM_MORPH_INFLUENCERS: number;
  116526. IMAGEPROCESSING: boolean;
  116527. VIGNETTE: boolean;
  116528. VIGNETTEBLENDMODEMULTIPLY: boolean;
  116529. VIGNETTEBLENDMODEOPAQUE: boolean;
  116530. TONEMAPPING: boolean;
  116531. TONEMAPPING_ACES: boolean;
  116532. CONTRAST: boolean;
  116533. COLORCURVES: boolean;
  116534. COLORGRADING: boolean;
  116535. COLORGRADING3D: boolean;
  116536. SAMPLER3DGREENDEPTH: boolean;
  116537. SAMPLER3DBGRMAP: boolean;
  116538. IMAGEPROCESSINGPOSTPROCESS: boolean;
  116539. EXPOSURE: boolean;
  116540. MULTIVIEW: boolean;
  116541. USEPHYSICALLIGHTFALLOFF: boolean;
  116542. USEGLTFLIGHTFALLOFF: boolean;
  116543. TWOSIDEDLIGHTING: boolean;
  116544. SHADOWFLOAT: boolean;
  116545. CLIPPLANE: boolean;
  116546. CLIPPLANE2: boolean;
  116547. CLIPPLANE3: boolean;
  116548. CLIPPLANE4: boolean;
  116549. POINTSIZE: boolean;
  116550. FOG: boolean;
  116551. LOGARITHMICDEPTH: boolean;
  116552. FORCENORMALFORWARD: boolean;
  116553. SPECULARAA: boolean;
  116554. CLEARCOAT: boolean;
  116555. CLEARCOAT_DEFAULTIOR: boolean;
  116556. CLEARCOAT_TEXTURE: boolean;
  116557. CLEARCOAT_TEXTUREDIRECTUV: number;
  116558. CLEARCOAT_BUMP: boolean;
  116559. CLEARCOAT_BUMPDIRECTUV: number;
  116560. CLEARCOAT_TINT: boolean;
  116561. CLEARCOAT_TINT_TEXTURE: boolean;
  116562. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  116563. ANISOTROPIC: boolean;
  116564. ANISOTROPIC_TEXTURE: boolean;
  116565. ANISOTROPIC_TEXTUREDIRECTUV: number;
  116566. BRDF_V_HEIGHT_CORRELATED: boolean;
  116567. MS_BRDF_ENERGY_CONSERVATION: boolean;
  116568. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  116569. SHEEN: boolean;
  116570. SHEEN_TEXTURE: boolean;
  116571. SHEEN_TEXTUREDIRECTUV: number;
  116572. SHEEN_LINKWITHALBEDO: boolean;
  116573. SUBSURFACE: boolean;
  116574. SS_REFRACTION: boolean;
  116575. SS_TRANSLUCENCY: boolean;
  116576. SS_SCATERRING: boolean;
  116577. SS_THICKNESSANDMASK_TEXTURE: boolean;
  116578. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  116579. SS_REFRACTIONMAP_3D: boolean;
  116580. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  116581. SS_LODINREFRACTIONALPHA: boolean;
  116582. SS_GAMMAREFRACTION: boolean;
  116583. SS_RGBDREFRACTION: boolean;
  116584. SS_LINEARSPECULARREFRACTION: boolean;
  116585. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  116586. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  116587. UNLIT: boolean;
  116588. DEBUGMODE: number;
  116589. /**
  116590. * Initializes the PBR Material defines.
  116591. */
  116592. constructor();
  116593. /**
  116594. * Resets the PBR Material defines.
  116595. */
  116596. reset(): void;
  116597. }
  116598. /**
  116599. * The Physically based material base class of BJS.
  116600. *
  116601. * This offers the main features of a standard PBR material.
  116602. * For more information, please refer to the documentation :
  116603. * https://doc.babylonjs.com/how_to/physically_based_rendering
  116604. */
  116605. export abstract class PBRBaseMaterial extends PushMaterial {
  116606. /**
  116607. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  116608. */
  116609. static readonly PBRMATERIAL_OPAQUE: number;
  116610. /**
  116611. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  116612. */
  116613. static readonly PBRMATERIAL_ALPHATEST: number;
  116614. /**
  116615. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116616. */
  116617. static readonly PBRMATERIAL_ALPHABLEND: number;
  116618. /**
  116619. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116620. * They are also discarded below the alpha cutoff threshold to improve performances.
  116621. */
  116622. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  116623. /**
  116624. * Defines the default value of how much AO map is occluding the analytical lights
  116625. * (point spot...).
  116626. */
  116627. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  116628. /**
  116629. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  116630. */
  116631. static readonly LIGHTFALLOFF_PHYSICAL: number;
  116632. /**
  116633. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  116634. * to enhance interoperability with other engines.
  116635. */
  116636. static readonly LIGHTFALLOFF_GLTF: number;
  116637. /**
  116638. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  116639. * to enhance interoperability with other materials.
  116640. */
  116641. static readonly LIGHTFALLOFF_STANDARD: number;
  116642. /**
  116643. * Intensity of the direct lights e.g. the four lights available in your scene.
  116644. * This impacts both the direct diffuse and specular highlights.
  116645. */
  116646. protected _directIntensity: number;
  116647. /**
  116648. * Intensity of the emissive part of the material.
  116649. * This helps controlling the emissive effect without modifying the emissive color.
  116650. */
  116651. protected _emissiveIntensity: number;
  116652. /**
  116653. * Intensity of the environment e.g. how much the environment will light the object
  116654. * either through harmonics for rough material or through the refelction for shiny ones.
  116655. */
  116656. protected _environmentIntensity: number;
  116657. /**
  116658. * This is a special control allowing the reduction of the specular highlights coming from the
  116659. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  116660. */
  116661. protected _specularIntensity: number;
  116662. /**
  116663. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  116664. */
  116665. private _lightingInfos;
  116666. /**
  116667. * Debug Control allowing disabling the bump map on this material.
  116668. */
  116669. protected _disableBumpMap: boolean;
  116670. /**
  116671. * AKA Diffuse Texture in standard nomenclature.
  116672. */
  116673. protected _albedoTexture: Nullable<BaseTexture>;
  116674. /**
  116675. * AKA Occlusion Texture in other nomenclature.
  116676. */
  116677. protected _ambientTexture: Nullable<BaseTexture>;
  116678. /**
  116679. * AKA Occlusion Texture Intensity in other nomenclature.
  116680. */
  116681. protected _ambientTextureStrength: number;
  116682. /**
  116683. * Defines how much the AO map is occluding the analytical lights (point spot...).
  116684. * 1 means it completely occludes it
  116685. * 0 mean it has no impact
  116686. */
  116687. protected _ambientTextureImpactOnAnalyticalLights: number;
  116688. /**
  116689. * Stores the alpha values in a texture.
  116690. */
  116691. protected _opacityTexture: Nullable<BaseTexture>;
  116692. /**
  116693. * Stores the reflection values in a texture.
  116694. */
  116695. protected _reflectionTexture: Nullable<BaseTexture>;
  116696. /**
  116697. * Stores the emissive values in a texture.
  116698. */
  116699. protected _emissiveTexture: Nullable<BaseTexture>;
  116700. /**
  116701. * AKA Specular texture in other nomenclature.
  116702. */
  116703. protected _reflectivityTexture: Nullable<BaseTexture>;
  116704. /**
  116705. * Used to switch from specular/glossiness to metallic/roughness workflow.
  116706. */
  116707. protected _metallicTexture: Nullable<BaseTexture>;
  116708. /**
  116709. * Specifies the metallic scalar of the metallic/roughness workflow.
  116710. * Can also be used to scale the metalness values of the metallic texture.
  116711. */
  116712. protected _metallic: Nullable<number>;
  116713. /**
  116714. * Specifies the roughness scalar of the metallic/roughness workflow.
  116715. * Can also be used to scale the roughness values of the metallic texture.
  116716. */
  116717. protected _roughness: Nullable<number>;
  116718. /**
  116719. * Specifies the an F0 factor to help configuring the material F0.
  116720. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  116721. * to 0.5 the previously hard coded value stays the same.
  116722. * Can also be used to scale the F0 values of the metallic texture.
  116723. */
  116724. protected _metallicF0Factor: number;
  116725. /**
  116726. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  116727. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  116728. * your expectation as it multiplies with the texture data.
  116729. */
  116730. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  116731. /**
  116732. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  116733. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  116734. */
  116735. protected _microSurfaceTexture: Nullable<BaseTexture>;
  116736. /**
  116737. * Stores surface normal data used to displace a mesh in a texture.
  116738. */
  116739. protected _bumpTexture: Nullable<BaseTexture>;
  116740. /**
  116741. * Stores the pre-calculated light information of a mesh in a texture.
  116742. */
  116743. protected _lightmapTexture: Nullable<BaseTexture>;
  116744. /**
  116745. * The color of a material in ambient lighting.
  116746. */
  116747. protected _ambientColor: Color3;
  116748. /**
  116749. * AKA Diffuse Color in other nomenclature.
  116750. */
  116751. protected _albedoColor: Color3;
  116752. /**
  116753. * AKA Specular Color in other nomenclature.
  116754. */
  116755. protected _reflectivityColor: Color3;
  116756. /**
  116757. * The color applied when light is reflected from a material.
  116758. */
  116759. protected _reflectionColor: Color3;
  116760. /**
  116761. * The color applied when light is emitted from a material.
  116762. */
  116763. protected _emissiveColor: Color3;
  116764. /**
  116765. * AKA Glossiness in other nomenclature.
  116766. */
  116767. protected _microSurface: number;
  116768. /**
  116769. * Specifies that the material will use the light map as a show map.
  116770. */
  116771. protected _useLightmapAsShadowmap: boolean;
  116772. /**
  116773. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  116774. * makes the reflect vector face the model (under horizon).
  116775. */
  116776. protected _useHorizonOcclusion: boolean;
  116777. /**
  116778. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  116779. * too much the area relying on ambient texture to define their ambient occlusion.
  116780. */
  116781. protected _useRadianceOcclusion: boolean;
  116782. /**
  116783. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  116784. */
  116785. protected _useAlphaFromAlbedoTexture: boolean;
  116786. /**
  116787. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  116788. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  116789. */
  116790. protected _useSpecularOverAlpha: boolean;
  116791. /**
  116792. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  116793. */
  116794. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  116795. /**
  116796. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  116797. */
  116798. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  116799. /**
  116800. * Specifies if the metallic texture contains the roughness information in its green channel.
  116801. */
  116802. protected _useRoughnessFromMetallicTextureGreen: boolean;
  116803. /**
  116804. * Specifies if the metallic texture contains the metallness information in its blue channel.
  116805. */
  116806. protected _useMetallnessFromMetallicTextureBlue: boolean;
  116807. /**
  116808. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  116809. */
  116810. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  116811. /**
  116812. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  116813. */
  116814. protected _useAmbientInGrayScale: boolean;
  116815. /**
  116816. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  116817. * The material will try to infer what glossiness each pixel should be.
  116818. */
  116819. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  116820. /**
  116821. * Defines the falloff type used in this material.
  116822. * It by default is Physical.
  116823. */
  116824. protected _lightFalloff: number;
  116825. /**
  116826. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  116827. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  116828. */
  116829. protected _useRadianceOverAlpha: boolean;
  116830. /**
  116831. * Allows using an object space normal map (instead of tangent space).
  116832. */
  116833. protected _useObjectSpaceNormalMap: boolean;
  116834. /**
  116835. * Allows using the bump map in parallax mode.
  116836. */
  116837. protected _useParallax: boolean;
  116838. /**
  116839. * Allows using the bump map in parallax occlusion mode.
  116840. */
  116841. protected _useParallaxOcclusion: boolean;
  116842. /**
  116843. * Controls the scale bias of the parallax mode.
  116844. */
  116845. protected _parallaxScaleBias: number;
  116846. /**
  116847. * If sets to true, disables all the lights affecting the material.
  116848. */
  116849. protected _disableLighting: boolean;
  116850. /**
  116851. * Number of Simultaneous lights allowed on the material.
  116852. */
  116853. protected _maxSimultaneousLights: number;
  116854. /**
  116855. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  116856. */
  116857. protected _invertNormalMapX: boolean;
  116858. /**
  116859. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  116860. */
  116861. protected _invertNormalMapY: boolean;
  116862. /**
  116863. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116864. */
  116865. protected _twoSidedLighting: boolean;
  116866. /**
  116867. * Defines the alpha limits in alpha test mode.
  116868. */
  116869. protected _alphaCutOff: number;
  116870. /**
  116871. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  116872. */
  116873. protected _forceAlphaTest: boolean;
  116874. /**
  116875. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116876. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  116877. */
  116878. protected _useAlphaFresnel: boolean;
  116879. /**
  116880. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116881. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  116882. */
  116883. protected _useLinearAlphaFresnel: boolean;
  116884. /**
  116885. * The transparency mode of the material.
  116886. */
  116887. protected _transparencyMode: Nullable<number>;
  116888. /**
  116889. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  116890. * from cos thetav and roughness:
  116891. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  116892. */
  116893. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  116894. /**
  116895. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  116896. */
  116897. protected _forceIrradianceInFragment: boolean;
  116898. /**
  116899. * Force normal to face away from face.
  116900. */
  116901. protected _forceNormalForward: boolean;
  116902. /**
  116903. * Enables specular anti aliasing in the PBR shader.
  116904. * It will both interacts on the Geometry for analytical and IBL lighting.
  116905. * It also prefilter the roughness map based on the bump values.
  116906. */
  116907. protected _enableSpecularAntiAliasing: boolean;
  116908. /**
  116909. * Default configuration related to image processing available in the PBR Material.
  116910. */
  116911. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116912. /**
  116913. * Keep track of the image processing observer to allow dispose and replace.
  116914. */
  116915. private _imageProcessingObserver;
  116916. /**
  116917. * Attaches a new image processing configuration to the PBR Material.
  116918. * @param configuration
  116919. */
  116920. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  116921. /**
  116922. * Stores the available render targets.
  116923. */
  116924. private _renderTargets;
  116925. /**
  116926. * Sets the global ambient color for the material used in lighting calculations.
  116927. */
  116928. private _globalAmbientColor;
  116929. /**
  116930. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  116931. */
  116932. private _useLogarithmicDepth;
  116933. /**
  116934. * If set to true, no lighting calculations will be applied.
  116935. */
  116936. private _unlit;
  116937. private _debugMode;
  116938. /**
  116939. * @hidden
  116940. * This is reserved for the inspector.
  116941. * Defines the material debug mode.
  116942. * It helps seeing only some components of the material while troubleshooting.
  116943. */
  116944. debugMode: number;
  116945. /**
  116946. * @hidden
  116947. * This is reserved for the inspector.
  116948. * Specify from where on screen the debug mode should start.
  116949. * The value goes from -1 (full screen) to 1 (not visible)
  116950. * It helps with side by side comparison against the final render
  116951. * This defaults to -1
  116952. */
  116953. private debugLimit;
  116954. /**
  116955. * @hidden
  116956. * This is reserved for the inspector.
  116957. * As the default viewing range might not be enough (if the ambient is really small for instance)
  116958. * You can use the factor to better multiply the final value.
  116959. */
  116960. private debugFactor;
  116961. /**
  116962. * Defines the clear coat layer parameters for the material.
  116963. */
  116964. readonly clearCoat: PBRClearCoatConfiguration;
  116965. /**
  116966. * Defines the anisotropic parameters for the material.
  116967. */
  116968. readonly anisotropy: PBRAnisotropicConfiguration;
  116969. /**
  116970. * Defines the BRDF parameters for the material.
  116971. */
  116972. readonly brdf: PBRBRDFConfiguration;
  116973. /**
  116974. * Defines the Sheen parameters for the material.
  116975. */
  116976. readonly sheen: PBRSheenConfiguration;
  116977. /**
  116978. * Defines the SubSurface parameters for the material.
  116979. */
  116980. readonly subSurface: PBRSubSurfaceConfiguration;
  116981. /**
  116982. * Custom callback helping to override the default shader used in the material.
  116983. */
  116984. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  116985. protected _rebuildInParallel: boolean;
  116986. /**
  116987. * Instantiates a new PBRMaterial instance.
  116988. *
  116989. * @param name The material name
  116990. * @param scene The scene the material will be use in.
  116991. */
  116992. constructor(name: string, scene: Scene);
  116993. /**
  116994. * Gets a boolean indicating that current material needs to register RTT
  116995. */
  116996. readonly hasRenderTargetTextures: boolean;
  116997. /**
  116998. * Gets the name of the material class.
  116999. */
  117000. getClassName(): string;
  117001. /**
  117002. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  117003. */
  117004. /**
  117005. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  117006. */
  117007. useLogarithmicDepth: boolean;
  117008. /**
  117009. * Gets the current transparency mode.
  117010. */
  117011. /**
  117012. * Sets the transparency mode of the material.
  117013. *
  117014. * | Value | Type | Description |
  117015. * | ----- | ----------------------------------- | ----------- |
  117016. * | 0 | OPAQUE | |
  117017. * | 1 | ALPHATEST | |
  117018. * | 2 | ALPHABLEND | |
  117019. * | 3 | ALPHATESTANDBLEND | |
  117020. *
  117021. */
  117022. transparencyMode: Nullable<number>;
  117023. /**
  117024. * Returns true if alpha blending should be disabled.
  117025. */
  117026. private readonly _disableAlphaBlending;
  117027. /**
  117028. * Specifies whether or not this material should be rendered in alpha blend mode.
  117029. */
  117030. needAlphaBlending(): boolean;
  117031. /**
  117032. * Specifies if the mesh will require alpha blending.
  117033. * @param mesh - BJS mesh.
  117034. */
  117035. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  117036. /**
  117037. * Specifies whether or not this material should be rendered in alpha test mode.
  117038. */
  117039. needAlphaTesting(): boolean;
  117040. /**
  117041. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  117042. */
  117043. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  117044. /**
  117045. * Gets the texture used for the alpha test.
  117046. */
  117047. getAlphaTestTexture(): Nullable<BaseTexture>;
  117048. /**
  117049. * Specifies that the submesh is ready to be used.
  117050. * @param mesh - BJS mesh.
  117051. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  117052. * @param useInstances - Specifies that instances should be used.
  117053. * @returns - boolean indicating that the submesh is ready or not.
  117054. */
  117055. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  117056. /**
  117057. * Specifies if the material uses metallic roughness workflow.
  117058. * @returns boolean specifiying if the material uses metallic roughness workflow.
  117059. */
  117060. isMetallicWorkflow(): boolean;
  117061. private _prepareEffect;
  117062. private _prepareDefines;
  117063. /**
  117064. * Force shader compilation
  117065. */
  117066. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  117067. /**
  117068. * Initializes the uniform buffer layout for the shader.
  117069. */
  117070. buildUniformLayout(): void;
  117071. /**
  117072. * Unbinds the material from the mesh
  117073. */
  117074. unbind(): void;
  117075. /**
  117076. * Binds the submesh data.
  117077. * @param world - The world matrix.
  117078. * @param mesh - The BJS mesh.
  117079. * @param subMesh - A submesh of the BJS mesh.
  117080. */
  117081. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  117082. /**
  117083. * Returns the animatable textures.
  117084. * @returns - Array of animatable textures.
  117085. */
  117086. getAnimatables(): IAnimatable[];
  117087. /**
  117088. * Returns the texture used for reflections.
  117089. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  117090. */
  117091. private _getReflectionTexture;
  117092. /**
  117093. * Returns an array of the actively used textures.
  117094. * @returns - Array of BaseTextures
  117095. */
  117096. getActiveTextures(): BaseTexture[];
  117097. /**
  117098. * Checks to see if a texture is used in the material.
  117099. * @param texture - Base texture to use.
  117100. * @returns - Boolean specifying if a texture is used in the material.
  117101. */
  117102. hasTexture(texture: BaseTexture): boolean;
  117103. /**
  117104. * Disposes the resources of the material.
  117105. * @param forceDisposeEffect - Forces the disposal of effects.
  117106. * @param forceDisposeTextures - Forces the disposal of all textures.
  117107. */
  117108. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  117109. }
  117110. }
  117111. declare module BABYLON {
  117112. /**
  117113. * The Physically based material of BJS.
  117114. *
  117115. * This offers the main features of a standard PBR material.
  117116. * For more information, please refer to the documentation :
  117117. * https://doc.babylonjs.com/how_to/physically_based_rendering
  117118. */
  117119. export class PBRMaterial extends PBRBaseMaterial {
  117120. /**
  117121. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  117122. */
  117123. static readonly PBRMATERIAL_OPAQUE: number;
  117124. /**
  117125. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  117126. */
  117127. static readonly PBRMATERIAL_ALPHATEST: number;
  117128. /**
  117129. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117130. */
  117131. static readonly PBRMATERIAL_ALPHABLEND: number;
  117132. /**
  117133. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117134. * They are also discarded below the alpha cutoff threshold to improve performances.
  117135. */
  117136. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  117137. /**
  117138. * Defines the default value of how much AO map is occluding the analytical lights
  117139. * (point spot...).
  117140. */
  117141. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  117142. /**
  117143. * Intensity of the direct lights e.g. the four lights available in your scene.
  117144. * This impacts both the direct diffuse and specular highlights.
  117145. */
  117146. directIntensity: number;
  117147. /**
  117148. * Intensity of the emissive part of the material.
  117149. * This helps controlling the emissive effect without modifying the emissive color.
  117150. */
  117151. emissiveIntensity: number;
  117152. /**
  117153. * Intensity of the environment e.g. how much the environment will light the object
  117154. * either through harmonics for rough material or through the refelction for shiny ones.
  117155. */
  117156. environmentIntensity: number;
  117157. /**
  117158. * This is a special control allowing the reduction of the specular highlights coming from the
  117159. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  117160. */
  117161. specularIntensity: number;
  117162. /**
  117163. * Debug Control allowing disabling the bump map on this material.
  117164. */
  117165. disableBumpMap: boolean;
  117166. /**
  117167. * AKA Diffuse Texture in standard nomenclature.
  117168. */
  117169. albedoTexture: BaseTexture;
  117170. /**
  117171. * AKA Occlusion Texture in other nomenclature.
  117172. */
  117173. ambientTexture: BaseTexture;
  117174. /**
  117175. * AKA Occlusion Texture Intensity in other nomenclature.
  117176. */
  117177. ambientTextureStrength: number;
  117178. /**
  117179. * Defines how much the AO map is occluding the analytical lights (point spot...).
  117180. * 1 means it completely occludes it
  117181. * 0 mean it has no impact
  117182. */
  117183. ambientTextureImpactOnAnalyticalLights: number;
  117184. /**
  117185. * Stores the alpha values in a texture.
  117186. */
  117187. opacityTexture: BaseTexture;
  117188. /**
  117189. * Stores the reflection values in a texture.
  117190. */
  117191. reflectionTexture: Nullable<BaseTexture>;
  117192. /**
  117193. * Stores the emissive values in a texture.
  117194. */
  117195. emissiveTexture: BaseTexture;
  117196. /**
  117197. * AKA Specular texture in other nomenclature.
  117198. */
  117199. reflectivityTexture: BaseTexture;
  117200. /**
  117201. * Used to switch from specular/glossiness to metallic/roughness workflow.
  117202. */
  117203. metallicTexture: BaseTexture;
  117204. /**
  117205. * Specifies the metallic scalar of the metallic/roughness workflow.
  117206. * Can also be used to scale the metalness values of the metallic texture.
  117207. */
  117208. metallic: Nullable<number>;
  117209. /**
  117210. * Specifies the roughness scalar of the metallic/roughness workflow.
  117211. * Can also be used to scale the roughness values of the metallic texture.
  117212. */
  117213. roughness: Nullable<number>;
  117214. /**
  117215. * Specifies the an F0 factor to help configuring the material F0.
  117216. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  117217. * to 0.5 the previously hard coded value stays the same.
  117218. * Can also be used to scale the F0 values of the metallic texture.
  117219. */
  117220. metallicF0Factor: number;
  117221. /**
  117222. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  117223. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  117224. * your expectation as it multiplies with the texture data.
  117225. */
  117226. useMetallicF0FactorFromMetallicTexture: boolean;
  117227. /**
  117228. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  117229. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  117230. */
  117231. microSurfaceTexture: BaseTexture;
  117232. /**
  117233. * Stores surface normal data used to displace a mesh in a texture.
  117234. */
  117235. bumpTexture: BaseTexture;
  117236. /**
  117237. * Stores the pre-calculated light information of a mesh in a texture.
  117238. */
  117239. lightmapTexture: BaseTexture;
  117240. /**
  117241. * Stores the refracted light information in a texture.
  117242. */
  117243. refractionTexture: Nullable<BaseTexture>;
  117244. /**
  117245. * The color of a material in ambient lighting.
  117246. */
  117247. ambientColor: Color3;
  117248. /**
  117249. * AKA Diffuse Color in other nomenclature.
  117250. */
  117251. albedoColor: Color3;
  117252. /**
  117253. * AKA Specular Color in other nomenclature.
  117254. */
  117255. reflectivityColor: Color3;
  117256. /**
  117257. * The color reflected from the material.
  117258. */
  117259. reflectionColor: Color3;
  117260. /**
  117261. * The color emitted from the material.
  117262. */
  117263. emissiveColor: Color3;
  117264. /**
  117265. * AKA Glossiness in other nomenclature.
  117266. */
  117267. microSurface: number;
  117268. /**
  117269. * source material index of refraction (IOR)' / 'destination material IOR.
  117270. */
  117271. indexOfRefraction: number;
  117272. /**
  117273. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  117274. */
  117275. invertRefractionY: boolean;
  117276. /**
  117277. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  117278. * Materials half opaque for instance using refraction could benefit from this control.
  117279. */
  117280. linkRefractionWithTransparency: boolean;
  117281. /**
  117282. * If true, the light map contains occlusion information instead of lighting info.
  117283. */
  117284. useLightmapAsShadowmap: boolean;
  117285. /**
  117286. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  117287. */
  117288. useAlphaFromAlbedoTexture: boolean;
  117289. /**
  117290. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  117291. */
  117292. forceAlphaTest: boolean;
  117293. /**
  117294. * Defines the alpha limits in alpha test mode.
  117295. */
  117296. alphaCutOff: number;
  117297. /**
  117298. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  117299. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  117300. */
  117301. useSpecularOverAlpha: boolean;
  117302. /**
  117303. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  117304. */
  117305. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  117306. /**
  117307. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  117308. */
  117309. useRoughnessFromMetallicTextureAlpha: boolean;
  117310. /**
  117311. * Specifies if the metallic texture contains the roughness information in its green channel.
  117312. */
  117313. useRoughnessFromMetallicTextureGreen: boolean;
  117314. /**
  117315. * Specifies if the metallic texture contains the metallness information in its blue channel.
  117316. */
  117317. useMetallnessFromMetallicTextureBlue: boolean;
  117318. /**
  117319. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  117320. */
  117321. useAmbientOcclusionFromMetallicTextureRed: boolean;
  117322. /**
  117323. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  117324. */
  117325. useAmbientInGrayScale: boolean;
  117326. /**
  117327. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  117328. * The material will try to infer what glossiness each pixel should be.
  117329. */
  117330. useAutoMicroSurfaceFromReflectivityMap: boolean;
  117331. /**
  117332. * BJS is using an harcoded light falloff based on a manually sets up range.
  117333. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  117334. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  117335. */
  117336. /**
  117337. * BJS is using an harcoded light falloff based on a manually sets up range.
  117338. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  117339. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  117340. */
  117341. usePhysicalLightFalloff: boolean;
  117342. /**
  117343. * In order to support the falloff compatibility with gltf, a special mode has been added
  117344. * to reproduce the gltf light falloff.
  117345. */
  117346. /**
  117347. * In order to support the falloff compatibility with gltf, a special mode has been added
  117348. * to reproduce the gltf light falloff.
  117349. */
  117350. useGLTFLightFalloff: boolean;
  117351. /**
  117352. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  117353. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  117354. */
  117355. useRadianceOverAlpha: boolean;
  117356. /**
  117357. * Allows using an object space normal map (instead of tangent space).
  117358. */
  117359. useObjectSpaceNormalMap: boolean;
  117360. /**
  117361. * Allows using the bump map in parallax mode.
  117362. */
  117363. useParallax: boolean;
  117364. /**
  117365. * Allows using the bump map in parallax occlusion mode.
  117366. */
  117367. useParallaxOcclusion: boolean;
  117368. /**
  117369. * Controls the scale bias of the parallax mode.
  117370. */
  117371. parallaxScaleBias: number;
  117372. /**
  117373. * If sets to true, disables all the lights affecting the material.
  117374. */
  117375. disableLighting: boolean;
  117376. /**
  117377. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  117378. */
  117379. forceIrradianceInFragment: boolean;
  117380. /**
  117381. * Number of Simultaneous lights allowed on the material.
  117382. */
  117383. maxSimultaneousLights: number;
  117384. /**
  117385. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  117386. */
  117387. invertNormalMapX: boolean;
  117388. /**
  117389. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  117390. */
  117391. invertNormalMapY: boolean;
  117392. /**
  117393. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  117394. */
  117395. twoSidedLighting: boolean;
  117396. /**
  117397. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117398. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  117399. */
  117400. useAlphaFresnel: boolean;
  117401. /**
  117402. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117403. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  117404. */
  117405. useLinearAlphaFresnel: boolean;
  117406. /**
  117407. * Let user defines the brdf lookup texture used for IBL.
  117408. * A default 8bit version is embedded but you could point at :
  117409. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  117410. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  117411. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  117412. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  117413. */
  117414. environmentBRDFTexture: Nullable<BaseTexture>;
  117415. /**
  117416. * Force normal to face away from face.
  117417. */
  117418. forceNormalForward: boolean;
  117419. /**
  117420. * Enables specular anti aliasing in the PBR shader.
  117421. * It will both interacts on the Geometry for analytical and IBL lighting.
  117422. * It also prefilter the roughness map based on the bump values.
  117423. */
  117424. enableSpecularAntiAliasing: boolean;
  117425. /**
  117426. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  117427. * makes the reflect vector face the model (under horizon).
  117428. */
  117429. useHorizonOcclusion: boolean;
  117430. /**
  117431. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  117432. * too much the area relying on ambient texture to define their ambient occlusion.
  117433. */
  117434. useRadianceOcclusion: boolean;
  117435. /**
  117436. * If set to true, no lighting calculations will be applied.
  117437. */
  117438. unlit: boolean;
  117439. /**
  117440. * Gets the image processing configuration used either in this material.
  117441. */
  117442. /**
  117443. * Sets the Default image processing configuration used either in the this material.
  117444. *
  117445. * If sets to null, the scene one is in use.
  117446. */
  117447. imageProcessingConfiguration: ImageProcessingConfiguration;
  117448. /**
  117449. * Gets wether the color curves effect is enabled.
  117450. */
  117451. /**
  117452. * Sets wether the color curves effect is enabled.
  117453. */
  117454. cameraColorCurvesEnabled: boolean;
  117455. /**
  117456. * Gets wether the color grading effect is enabled.
  117457. */
  117458. /**
  117459. * Gets wether the color grading effect is enabled.
  117460. */
  117461. cameraColorGradingEnabled: boolean;
  117462. /**
  117463. * Gets wether tonemapping is enabled or not.
  117464. */
  117465. /**
  117466. * Sets wether tonemapping is enabled or not
  117467. */
  117468. cameraToneMappingEnabled: boolean;
  117469. /**
  117470. * The camera exposure used on this material.
  117471. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  117472. * This corresponds to a photographic exposure.
  117473. */
  117474. /**
  117475. * The camera exposure used on this material.
  117476. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  117477. * This corresponds to a photographic exposure.
  117478. */
  117479. cameraExposure: number;
  117480. /**
  117481. * Gets The camera contrast used on this material.
  117482. */
  117483. /**
  117484. * Sets The camera contrast used on this material.
  117485. */
  117486. cameraContrast: number;
  117487. /**
  117488. * Gets the Color Grading 2D Lookup Texture.
  117489. */
  117490. /**
  117491. * Sets the Color Grading 2D Lookup Texture.
  117492. */
  117493. cameraColorGradingTexture: Nullable<BaseTexture>;
  117494. /**
  117495. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117496. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117497. * 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;
  117498. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117499. */
  117500. /**
  117501. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117502. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117503. * 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;
  117504. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117505. */
  117506. cameraColorCurves: Nullable<ColorCurves>;
  117507. /**
  117508. * Instantiates a new PBRMaterial instance.
  117509. *
  117510. * @param name The material name
  117511. * @param scene The scene the material will be use in.
  117512. */
  117513. constructor(name: string, scene: Scene);
  117514. /**
  117515. * Returns the name of this material class.
  117516. */
  117517. getClassName(): string;
  117518. /**
  117519. * Makes a duplicate of the current material.
  117520. * @param name - name to use for the new material.
  117521. */
  117522. clone(name: string): PBRMaterial;
  117523. /**
  117524. * Serializes this PBR Material.
  117525. * @returns - An object with the serialized material.
  117526. */
  117527. serialize(): any;
  117528. /**
  117529. * Parses a PBR Material from a serialized object.
  117530. * @param source - Serialized object.
  117531. * @param scene - BJS scene instance.
  117532. * @param rootUrl - url for the scene object
  117533. * @returns - PBRMaterial
  117534. */
  117535. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  117536. }
  117537. }
  117538. declare module BABYLON {
  117539. /**
  117540. * Direct draw surface info
  117541. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  117542. */
  117543. export interface DDSInfo {
  117544. /**
  117545. * Width of the texture
  117546. */
  117547. width: number;
  117548. /**
  117549. * Width of the texture
  117550. */
  117551. height: number;
  117552. /**
  117553. * Number of Mipmaps for the texture
  117554. * @see https://en.wikipedia.org/wiki/Mipmap
  117555. */
  117556. mipmapCount: number;
  117557. /**
  117558. * If the textures format is a known fourCC format
  117559. * @see https://www.fourcc.org/
  117560. */
  117561. isFourCC: boolean;
  117562. /**
  117563. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  117564. */
  117565. isRGB: boolean;
  117566. /**
  117567. * If the texture is a lumincance format
  117568. */
  117569. isLuminance: boolean;
  117570. /**
  117571. * If this is a cube texture
  117572. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  117573. */
  117574. isCube: boolean;
  117575. /**
  117576. * If the texture is a compressed format eg. FOURCC_DXT1
  117577. */
  117578. isCompressed: boolean;
  117579. /**
  117580. * The dxgiFormat of the texture
  117581. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  117582. */
  117583. dxgiFormat: number;
  117584. /**
  117585. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  117586. */
  117587. textureType: number;
  117588. /**
  117589. * Sphericle polynomial created for the dds texture
  117590. */
  117591. sphericalPolynomial?: SphericalPolynomial;
  117592. }
  117593. /**
  117594. * Class used to provide DDS decompression tools
  117595. */
  117596. export class DDSTools {
  117597. /**
  117598. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  117599. */
  117600. static StoreLODInAlphaChannel: boolean;
  117601. /**
  117602. * Gets DDS information from an array buffer
  117603. * @param arrayBuffer defines the array buffer to read data from
  117604. * @returns the DDS information
  117605. */
  117606. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  117607. private static _FloatView;
  117608. private static _Int32View;
  117609. private static _ToHalfFloat;
  117610. private static _FromHalfFloat;
  117611. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  117612. private static _GetHalfFloatRGBAArrayBuffer;
  117613. private static _GetFloatRGBAArrayBuffer;
  117614. private static _GetFloatAsUIntRGBAArrayBuffer;
  117615. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  117616. private static _GetRGBAArrayBuffer;
  117617. private static _ExtractLongWordOrder;
  117618. private static _GetRGBArrayBuffer;
  117619. private static _GetLuminanceArrayBuffer;
  117620. /**
  117621. * Uploads DDS Levels to a Babylon Texture
  117622. * @hidden
  117623. */
  117624. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  117625. }
  117626. interface ThinEngine {
  117627. /**
  117628. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  117629. * @param rootUrl defines the url where the file to load is located
  117630. * @param scene defines the current scene
  117631. * @param lodScale defines scale to apply to the mip map selection
  117632. * @param lodOffset defines offset to apply to the mip map selection
  117633. * @param onLoad defines an optional callback raised when the texture is loaded
  117634. * @param onError defines an optional callback raised if there is an issue to load the texture
  117635. * @param format defines the format of the data
  117636. * @param forcedExtension defines the extension to use to pick the right loader
  117637. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  117638. * @returns the cube texture as an InternalTexture
  117639. */
  117640. 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;
  117641. }
  117642. }
  117643. declare module BABYLON {
  117644. /**
  117645. * Implementation of the DDS Texture Loader.
  117646. * @hidden
  117647. */
  117648. export class _DDSTextureLoader implements IInternalTextureLoader {
  117649. /**
  117650. * Defines wether the loader supports cascade loading the different faces.
  117651. */
  117652. readonly supportCascades: boolean;
  117653. /**
  117654. * This returns if the loader support the current file information.
  117655. * @param extension defines the file extension of the file being loaded
  117656. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117657. * @param fallback defines the fallback internal texture if any
  117658. * @param isBase64 defines whether the texture is encoded as a base64
  117659. * @param isBuffer defines whether the texture data are stored as a buffer
  117660. * @returns true if the loader can load the specified file
  117661. */
  117662. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117663. /**
  117664. * Transform the url before loading if required.
  117665. * @param rootUrl the url of the texture
  117666. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117667. * @returns the transformed texture
  117668. */
  117669. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117670. /**
  117671. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117672. * @param rootUrl the url of the texture
  117673. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117674. * @returns the fallback texture
  117675. */
  117676. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117677. /**
  117678. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117679. * @param data contains the texture data
  117680. * @param texture defines the BabylonJS internal texture
  117681. * @param createPolynomials will be true if polynomials have been requested
  117682. * @param onLoad defines the callback to trigger once the texture is ready
  117683. * @param onError defines the callback to trigger in case of error
  117684. */
  117685. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117686. /**
  117687. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117688. * @param data contains the texture data
  117689. * @param texture defines the BabylonJS internal texture
  117690. * @param callback defines the method to call once ready to upload
  117691. */
  117692. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117693. }
  117694. }
  117695. declare module BABYLON {
  117696. /**
  117697. * Implementation of the ENV Texture Loader.
  117698. * @hidden
  117699. */
  117700. export class _ENVTextureLoader 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) => void): void;
  117745. }
  117746. }
  117747. declare module BABYLON {
  117748. /**
  117749. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  117750. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  117751. */
  117752. export class KhronosTextureContainer {
  117753. /** contents of the KTX container file */
  117754. arrayBuffer: any;
  117755. private static HEADER_LEN;
  117756. private static COMPRESSED_2D;
  117757. private static COMPRESSED_3D;
  117758. private static TEX_2D;
  117759. private static TEX_3D;
  117760. /**
  117761. * Gets the openGL type
  117762. */
  117763. glType: number;
  117764. /**
  117765. * Gets the openGL type size
  117766. */
  117767. glTypeSize: number;
  117768. /**
  117769. * Gets the openGL format
  117770. */
  117771. glFormat: number;
  117772. /**
  117773. * Gets the openGL internal format
  117774. */
  117775. glInternalFormat: number;
  117776. /**
  117777. * Gets the base internal format
  117778. */
  117779. glBaseInternalFormat: number;
  117780. /**
  117781. * Gets image width in pixel
  117782. */
  117783. pixelWidth: number;
  117784. /**
  117785. * Gets image height in pixel
  117786. */
  117787. pixelHeight: number;
  117788. /**
  117789. * Gets image depth in pixels
  117790. */
  117791. pixelDepth: number;
  117792. /**
  117793. * Gets the number of array elements
  117794. */
  117795. numberOfArrayElements: number;
  117796. /**
  117797. * Gets the number of faces
  117798. */
  117799. numberOfFaces: number;
  117800. /**
  117801. * Gets the number of mipmap levels
  117802. */
  117803. numberOfMipmapLevels: number;
  117804. /**
  117805. * Gets the bytes of key value data
  117806. */
  117807. bytesOfKeyValueData: number;
  117808. /**
  117809. * Gets the load type
  117810. */
  117811. loadType: number;
  117812. /**
  117813. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  117814. */
  117815. isInvalid: boolean;
  117816. /**
  117817. * Creates a new KhronosTextureContainer
  117818. * @param arrayBuffer contents of the KTX container file
  117819. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  117820. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  117821. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  117822. */
  117823. constructor(
  117824. /** contents of the KTX container file */
  117825. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  117826. /**
  117827. * Uploads KTX content to a Babylon Texture.
  117828. * It is assumed that the texture has already been created & is currently bound
  117829. * @hidden
  117830. */
  117831. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  117832. private _upload2DCompressedLevels;
  117833. }
  117834. }
  117835. declare module BABYLON {
  117836. /**
  117837. * Implementation of the KTX Texture Loader.
  117838. * @hidden
  117839. */
  117840. export class _KTXTextureLoader implements IInternalTextureLoader {
  117841. /**
  117842. * Defines wether the loader supports cascade loading the different faces.
  117843. */
  117844. readonly supportCascades: boolean;
  117845. /**
  117846. * This returns if the loader support the current file information.
  117847. * @param extension defines the file extension of the file being loaded
  117848. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117849. * @param fallback defines the fallback internal texture if any
  117850. * @param isBase64 defines whether the texture is encoded as a base64
  117851. * @param isBuffer defines whether the texture data are stored as a buffer
  117852. * @returns true if the loader can load the specified file
  117853. */
  117854. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117855. /**
  117856. * Transform the url before loading if required.
  117857. * @param rootUrl the url of the texture
  117858. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117859. * @returns the transformed texture
  117860. */
  117861. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117862. /**
  117863. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117864. * @param rootUrl the url of the texture
  117865. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117866. * @returns the fallback texture
  117867. */
  117868. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117869. /**
  117870. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117871. * @param data contains the texture data
  117872. * @param texture defines the BabylonJS internal texture
  117873. * @param createPolynomials will be true if polynomials have been requested
  117874. * @param onLoad defines the callback to trigger once the texture is ready
  117875. * @param onError defines the callback to trigger in case of error
  117876. */
  117877. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117878. /**
  117879. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117880. * @param data contains the texture data
  117881. * @param texture defines the BabylonJS internal texture
  117882. * @param callback defines the method to call once ready to upload
  117883. */
  117884. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  117885. }
  117886. }
  117887. declare module BABYLON {
  117888. /** @hidden */
  117889. export var _forceSceneHelpersToBundle: boolean;
  117890. interface Scene {
  117891. /**
  117892. * Creates a default light for the scene.
  117893. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  117894. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  117895. */
  117896. createDefaultLight(replace?: boolean): void;
  117897. /**
  117898. * Creates a default camera for the scene.
  117899. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  117900. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  117901. * @param replace has default false, when true replaces the active camera in the scene
  117902. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  117903. */
  117904. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  117905. /**
  117906. * Creates a default camera and a default light.
  117907. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  117908. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  117909. * @param replace has the default false, when true replaces the active camera/light in the scene
  117910. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  117911. */
  117912. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  117913. /**
  117914. * Creates a new sky box
  117915. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  117916. * @param environmentTexture defines the texture to use as environment texture
  117917. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  117918. * @param scale defines the overall scale of the skybox
  117919. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  117920. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  117921. * @returns a new mesh holding the sky box
  117922. */
  117923. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  117924. /**
  117925. * Creates a new environment
  117926. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  117927. * @param options defines the options you can use to configure the environment
  117928. * @returns the new EnvironmentHelper
  117929. */
  117930. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  117931. /**
  117932. * Creates a new VREXperienceHelper
  117933. * @see http://doc.babylonjs.com/how_to/webvr_helper
  117934. * @param webVROptions defines the options used to create the new VREXperienceHelper
  117935. * @returns a new VREXperienceHelper
  117936. */
  117937. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  117938. /**
  117939. * Creates a new WebXRDefaultExperience
  117940. * @see http://doc.babylonjs.com/how_to/webxr
  117941. * @param options experience options
  117942. * @returns a promise for a new WebXRDefaultExperience
  117943. */
  117944. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117945. }
  117946. }
  117947. declare module BABYLON {
  117948. /**
  117949. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  117950. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  117951. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  117952. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  117953. */
  117954. export class VideoDome extends TransformNode {
  117955. /**
  117956. * Define the video source as a Monoscopic panoramic 360 video.
  117957. */
  117958. static readonly MODE_MONOSCOPIC: number;
  117959. /**
  117960. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  117961. */
  117962. static readonly MODE_TOPBOTTOM: number;
  117963. /**
  117964. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  117965. */
  117966. static readonly MODE_SIDEBYSIDE: number;
  117967. private _halfDome;
  117968. private _useDirectMapping;
  117969. /**
  117970. * The video texture being displayed on the sphere
  117971. */
  117972. protected _videoTexture: VideoTexture;
  117973. /**
  117974. * Gets the video texture being displayed on the sphere
  117975. */
  117976. readonly videoTexture: VideoTexture;
  117977. /**
  117978. * The skybox material
  117979. */
  117980. protected _material: BackgroundMaterial;
  117981. /**
  117982. * The surface used for the skybox
  117983. */
  117984. protected _mesh: Mesh;
  117985. /**
  117986. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  117987. */
  117988. private _halfDomeMask;
  117989. /**
  117990. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  117991. * Also see the options.resolution property.
  117992. */
  117993. fovMultiplier: number;
  117994. private _videoMode;
  117995. /**
  117996. * Gets or set the current video mode for the video. It can be:
  117997. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  117998. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  117999. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  118000. */
  118001. videoMode: number;
  118002. /**
  118003. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  118004. *
  118005. */
  118006. /**
  118007. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  118008. */
  118009. halfDome: boolean;
  118010. /**
  118011. * Oberserver used in Stereoscopic VR Mode.
  118012. */
  118013. private _onBeforeCameraRenderObserver;
  118014. /**
  118015. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  118016. * @param name Element's name, child elements will append suffixes for their own names.
  118017. * @param urlsOrVideo defines the url(s) or the video element to use
  118018. * @param options An object containing optional or exposed sub element properties
  118019. */
  118020. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  118021. resolution?: number;
  118022. clickToPlay?: boolean;
  118023. autoPlay?: boolean;
  118024. loop?: boolean;
  118025. size?: number;
  118026. poster?: string;
  118027. faceForward?: boolean;
  118028. useDirectMapping?: boolean;
  118029. halfDomeMode?: boolean;
  118030. }, scene: Scene);
  118031. private _changeVideoMode;
  118032. /**
  118033. * Releases resources associated with this node.
  118034. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  118035. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  118036. */
  118037. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  118038. }
  118039. }
  118040. declare module BABYLON {
  118041. /**
  118042. * This class can be used to get instrumentation data from a Babylon engine
  118043. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  118044. */
  118045. export class EngineInstrumentation implements IDisposable {
  118046. /**
  118047. * Define the instrumented engine.
  118048. */
  118049. engine: Engine;
  118050. private _captureGPUFrameTime;
  118051. private _gpuFrameTimeToken;
  118052. private _gpuFrameTime;
  118053. private _captureShaderCompilationTime;
  118054. private _shaderCompilationTime;
  118055. private _onBeginFrameObserver;
  118056. private _onEndFrameObserver;
  118057. private _onBeforeShaderCompilationObserver;
  118058. private _onAfterShaderCompilationObserver;
  118059. /**
  118060. * Gets the perf counter used for GPU frame time
  118061. */
  118062. readonly gpuFrameTimeCounter: PerfCounter;
  118063. /**
  118064. * Gets the GPU frame time capture status
  118065. */
  118066. /**
  118067. * Enable or disable the GPU frame time capture
  118068. */
  118069. captureGPUFrameTime: boolean;
  118070. /**
  118071. * Gets the perf counter used for shader compilation time
  118072. */
  118073. readonly shaderCompilationTimeCounter: PerfCounter;
  118074. /**
  118075. * Gets the shader compilation time capture status
  118076. */
  118077. /**
  118078. * Enable or disable the shader compilation time capture
  118079. */
  118080. captureShaderCompilationTime: boolean;
  118081. /**
  118082. * Instantiates a new engine instrumentation.
  118083. * This class can be used to get instrumentation data from a Babylon engine
  118084. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  118085. * @param engine Defines the engine to instrument
  118086. */
  118087. constructor(
  118088. /**
  118089. * Define the instrumented engine.
  118090. */
  118091. engine: Engine);
  118092. /**
  118093. * Dispose and release associated resources.
  118094. */
  118095. dispose(): void;
  118096. }
  118097. }
  118098. declare module BABYLON {
  118099. /**
  118100. * This class can be used to get instrumentation data from a Babylon engine
  118101. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  118102. */
  118103. export class SceneInstrumentation implements IDisposable {
  118104. /**
  118105. * Defines the scene to instrument
  118106. */
  118107. scene: Scene;
  118108. private _captureActiveMeshesEvaluationTime;
  118109. private _activeMeshesEvaluationTime;
  118110. private _captureRenderTargetsRenderTime;
  118111. private _renderTargetsRenderTime;
  118112. private _captureFrameTime;
  118113. private _frameTime;
  118114. private _captureRenderTime;
  118115. private _renderTime;
  118116. private _captureInterFrameTime;
  118117. private _interFrameTime;
  118118. private _captureParticlesRenderTime;
  118119. private _particlesRenderTime;
  118120. private _captureSpritesRenderTime;
  118121. private _spritesRenderTime;
  118122. private _capturePhysicsTime;
  118123. private _physicsTime;
  118124. private _captureAnimationsTime;
  118125. private _animationsTime;
  118126. private _captureCameraRenderTime;
  118127. private _cameraRenderTime;
  118128. private _onBeforeActiveMeshesEvaluationObserver;
  118129. private _onAfterActiveMeshesEvaluationObserver;
  118130. private _onBeforeRenderTargetsRenderObserver;
  118131. private _onAfterRenderTargetsRenderObserver;
  118132. private _onAfterRenderObserver;
  118133. private _onBeforeDrawPhaseObserver;
  118134. private _onAfterDrawPhaseObserver;
  118135. private _onBeforeAnimationsObserver;
  118136. private _onBeforeParticlesRenderingObserver;
  118137. private _onAfterParticlesRenderingObserver;
  118138. private _onBeforeSpritesRenderingObserver;
  118139. private _onAfterSpritesRenderingObserver;
  118140. private _onBeforePhysicsObserver;
  118141. private _onAfterPhysicsObserver;
  118142. private _onAfterAnimationsObserver;
  118143. private _onBeforeCameraRenderObserver;
  118144. private _onAfterCameraRenderObserver;
  118145. /**
  118146. * Gets the perf counter used for active meshes evaluation time
  118147. */
  118148. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  118149. /**
  118150. * Gets the active meshes evaluation time capture status
  118151. */
  118152. /**
  118153. * Enable or disable the active meshes evaluation time capture
  118154. */
  118155. captureActiveMeshesEvaluationTime: boolean;
  118156. /**
  118157. * Gets the perf counter used for render targets render time
  118158. */
  118159. readonly renderTargetsRenderTimeCounter: PerfCounter;
  118160. /**
  118161. * Gets the render targets render time capture status
  118162. */
  118163. /**
  118164. * Enable or disable the render targets render time capture
  118165. */
  118166. captureRenderTargetsRenderTime: boolean;
  118167. /**
  118168. * Gets the perf counter used for particles render time
  118169. */
  118170. readonly particlesRenderTimeCounter: PerfCounter;
  118171. /**
  118172. * Gets the particles render time capture status
  118173. */
  118174. /**
  118175. * Enable or disable the particles render time capture
  118176. */
  118177. captureParticlesRenderTime: boolean;
  118178. /**
  118179. * Gets the perf counter used for sprites render time
  118180. */
  118181. readonly spritesRenderTimeCounter: PerfCounter;
  118182. /**
  118183. * Gets the sprites render time capture status
  118184. */
  118185. /**
  118186. * Enable or disable the sprites render time capture
  118187. */
  118188. captureSpritesRenderTime: boolean;
  118189. /**
  118190. * Gets the perf counter used for physics time
  118191. */
  118192. readonly physicsTimeCounter: PerfCounter;
  118193. /**
  118194. * Gets the physics time capture status
  118195. */
  118196. /**
  118197. * Enable or disable the physics time capture
  118198. */
  118199. capturePhysicsTime: boolean;
  118200. /**
  118201. * Gets the perf counter used for animations time
  118202. */
  118203. readonly animationsTimeCounter: PerfCounter;
  118204. /**
  118205. * Gets the animations time capture status
  118206. */
  118207. /**
  118208. * Enable or disable the animations time capture
  118209. */
  118210. captureAnimationsTime: boolean;
  118211. /**
  118212. * Gets the perf counter used for frame time capture
  118213. */
  118214. readonly frameTimeCounter: PerfCounter;
  118215. /**
  118216. * Gets the frame time capture status
  118217. */
  118218. /**
  118219. * Enable or disable the frame time capture
  118220. */
  118221. captureFrameTime: boolean;
  118222. /**
  118223. * Gets the perf counter used for inter-frames time capture
  118224. */
  118225. readonly interFrameTimeCounter: PerfCounter;
  118226. /**
  118227. * Gets the inter-frames time capture status
  118228. */
  118229. /**
  118230. * Enable or disable the inter-frames time capture
  118231. */
  118232. captureInterFrameTime: boolean;
  118233. /**
  118234. * Gets the perf counter used for render time capture
  118235. */
  118236. readonly renderTimeCounter: PerfCounter;
  118237. /**
  118238. * Gets the render time capture status
  118239. */
  118240. /**
  118241. * Enable or disable the render time capture
  118242. */
  118243. captureRenderTime: boolean;
  118244. /**
  118245. * Gets the perf counter used for camera render time capture
  118246. */
  118247. readonly cameraRenderTimeCounter: PerfCounter;
  118248. /**
  118249. * Gets the camera render time capture status
  118250. */
  118251. /**
  118252. * Enable or disable the camera render time capture
  118253. */
  118254. captureCameraRenderTime: boolean;
  118255. /**
  118256. * Gets the perf counter used for draw calls
  118257. */
  118258. readonly drawCallsCounter: PerfCounter;
  118259. /**
  118260. * Instantiates a new scene instrumentation.
  118261. * This class can be used to get instrumentation data from a Babylon engine
  118262. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  118263. * @param scene Defines the scene to instrument
  118264. */
  118265. constructor(
  118266. /**
  118267. * Defines the scene to instrument
  118268. */
  118269. scene: Scene);
  118270. /**
  118271. * Dispose and release associated resources.
  118272. */
  118273. dispose(): void;
  118274. }
  118275. }
  118276. declare module BABYLON {
  118277. /** @hidden */
  118278. export var glowMapGenerationPixelShader: {
  118279. name: string;
  118280. shader: string;
  118281. };
  118282. }
  118283. declare module BABYLON {
  118284. /** @hidden */
  118285. export var glowMapGenerationVertexShader: {
  118286. name: string;
  118287. shader: string;
  118288. };
  118289. }
  118290. declare module BABYLON {
  118291. /**
  118292. * Effect layer options. This helps customizing the behaviour
  118293. * of the effect layer.
  118294. */
  118295. export interface IEffectLayerOptions {
  118296. /**
  118297. * Multiplication factor apply to the canvas size to compute the render target size
  118298. * used to generated the objects (the smaller the faster).
  118299. */
  118300. mainTextureRatio: number;
  118301. /**
  118302. * Enforces a fixed size texture to ensure effect stability across devices.
  118303. */
  118304. mainTextureFixedSize?: number;
  118305. /**
  118306. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  118307. */
  118308. alphaBlendingMode: number;
  118309. /**
  118310. * The camera attached to the layer.
  118311. */
  118312. camera: Nullable<Camera>;
  118313. /**
  118314. * The rendering group to draw the layer in.
  118315. */
  118316. renderingGroupId: number;
  118317. }
  118318. /**
  118319. * The effect layer Helps adding post process effect blended with the main pass.
  118320. *
  118321. * This can be for instance use to generate glow or higlight effects on the scene.
  118322. *
  118323. * The effect layer class can not be used directly and is intented to inherited from to be
  118324. * customized per effects.
  118325. */
  118326. export abstract class EffectLayer {
  118327. private _vertexBuffers;
  118328. private _indexBuffer;
  118329. private _cachedDefines;
  118330. private _effectLayerMapGenerationEffect;
  118331. private _effectLayerOptions;
  118332. private _mergeEffect;
  118333. protected _scene: Scene;
  118334. protected _engine: Engine;
  118335. protected _maxSize: number;
  118336. protected _mainTextureDesiredSize: ISize;
  118337. protected _mainTexture: RenderTargetTexture;
  118338. protected _shouldRender: boolean;
  118339. protected _postProcesses: PostProcess[];
  118340. protected _textures: BaseTexture[];
  118341. protected _emissiveTextureAndColor: {
  118342. texture: Nullable<BaseTexture>;
  118343. color: Color4;
  118344. };
  118345. /**
  118346. * The name of the layer
  118347. */
  118348. name: string;
  118349. /**
  118350. * The clear color of the texture used to generate the glow map.
  118351. */
  118352. neutralColor: Color4;
  118353. /**
  118354. * Specifies wether the highlight layer is enabled or not.
  118355. */
  118356. isEnabled: boolean;
  118357. /**
  118358. * Gets the camera attached to the layer.
  118359. */
  118360. readonly camera: Nullable<Camera>;
  118361. /**
  118362. * Gets the rendering group id the layer should render in.
  118363. */
  118364. renderingGroupId: number;
  118365. /**
  118366. * An event triggered when the effect layer has been disposed.
  118367. */
  118368. onDisposeObservable: Observable<EffectLayer>;
  118369. /**
  118370. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  118371. */
  118372. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  118373. /**
  118374. * An event triggered when the generated texture is being merged in the scene.
  118375. */
  118376. onBeforeComposeObservable: Observable<EffectLayer>;
  118377. /**
  118378. * An event triggered when the mesh is rendered into the effect render target.
  118379. */
  118380. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  118381. /**
  118382. * An event triggered after the mesh has been rendered into the effect render target.
  118383. */
  118384. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  118385. /**
  118386. * An event triggered when the generated texture has been merged in the scene.
  118387. */
  118388. onAfterComposeObservable: Observable<EffectLayer>;
  118389. /**
  118390. * An event triggered when the efffect layer changes its size.
  118391. */
  118392. onSizeChangedObservable: Observable<EffectLayer>;
  118393. /** @hidden */
  118394. static _SceneComponentInitialization: (scene: Scene) => void;
  118395. /**
  118396. * Instantiates a new effect Layer and references it in the scene.
  118397. * @param name The name of the layer
  118398. * @param scene The scene to use the layer in
  118399. */
  118400. constructor(
  118401. /** The Friendly of the effect in the scene */
  118402. name: string, scene: Scene);
  118403. /**
  118404. * Get the effect name of the layer.
  118405. * @return The effect name
  118406. */
  118407. abstract getEffectName(): string;
  118408. /**
  118409. * Checks for the readiness of the element composing the layer.
  118410. * @param subMesh the mesh to check for
  118411. * @param useInstances specify wether or not to use instances to render the mesh
  118412. * @return true if ready otherwise, false
  118413. */
  118414. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118415. /**
  118416. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118417. * @returns true if the effect requires stencil during the main canvas render pass.
  118418. */
  118419. abstract needStencil(): boolean;
  118420. /**
  118421. * Create the merge effect. This is the shader use to blit the information back
  118422. * to the main canvas at the end of the scene rendering.
  118423. * @returns The effect containing the shader used to merge the effect on the main canvas
  118424. */
  118425. protected abstract _createMergeEffect(): Effect;
  118426. /**
  118427. * Creates the render target textures and post processes used in the effect layer.
  118428. */
  118429. protected abstract _createTextureAndPostProcesses(): void;
  118430. /**
  118431. * Implementation specific of rendering the generating effect on the main canvas.
  118432. * @param effect The effect used to render through
  118433. */
  118434. protected abstract _internalRender(effect: Effect): void;
  118435. /**
  118436. * Sets the required values for both the emissive texture and and the main color.
  118437. */
  118438. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118439. /**
  118440. * Free any resources and references associated to a mesh.
  118441. * Internal use
  118442. * @param mesh The mesh to free.
  118443. */
  118444. abstract _disposeMesh(mesh: Mesh): void;
  118445. /**
  118446. * Serializes this layer (Glow or Highlight for example)
  118447. * @returns a serialized layer object
  118448. */
  118449. abstract serialize?(): any;
  118450. /**
  118451. * Initializes the effect layer with the required options.
  118452. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  118453. */
  118454. protected _init(options: Partial<IEffectLayerOptions>): void;
  118455. /**
  118456. * Generates the index buffer of the full screen quad blending to the main canvas.
  118457. */
  118458. private _generateIndexBuffer;
  118459. /**
  118460. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  118461. */
  118462. private _generateVertexBuffer;
  118463. /**
  118464. * Sets the main texture desired size which is the closest power of two
  118465. * of the engine canvas size.
  118466. */
  118467. private _setMainTextureSize;
  118468. /**
  118469. * Creates the main texture for the effect layer.
  118470. */
  118471. protected _createMainTexture(): void;
  118472. /**
  118473. * Adds specific effects defines.
  118474. * @param defines The defines to add specifics to.
  118475. */
  118476. protected _addCustomEffectDefines(defines: string[]): void;
  118477. /**
  118478. * Checks for the readiness of the element composing the layer.
  118479. * @param subMesh the mesh to check for
  118480. * @param useInstances specify wether or not to use instances to render the mesh
  118481. * @param emissiveTexture the associated emissive texture used to generate the glow
  118482. * @return true if ready otherwise, false
  118483. */
  118484. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  118485. /**
  118486. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  118487. */
  118488. render(): void;
  118489. /**
  118490. * Determine if a given mesh will be used in the current effect.
  118491. * @param mesh mesh to test
  118492. * @returns true if the mesh will be used
  118493. */
  118494. hasMesh(mesh: AbstractMesh): boolean;
  118495. /**
  118496. * Returns true if the layer contains information to display, otherwise false.
  118497. * @returns true if the glow layer should be rendered
  118498. */
  118499. shouldRender(): boolean;
  118500. /**
  118501. * Returns true if the mesh should render, otherwise false.
  118502. * @param mesh The mesh to render
  118503. * @returns true if it should render otherwise false
  118504. */
  118505. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  118506. /**
  118507. * Returns true if the mesh can be rendered, otherwise false.
  118508. * @param mesh The mesh to render
  118509. * @param material The material used on the mesh
  118510. * @returns true if it can be rendered otherwise false
  118511. */
  118512. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  118513. /**
  118514. * Returns true if the mesh should render, otherwise false.
  118515. * @param mesh The mesh to render
  118516. * @returns true if it should render otherwise false
  118517. */
  118518. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  118519. /**
  118520. * Renders the submesh passed in parameter to the generation map.
  118521. */
  118522. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  118523. /**
  118524. * Defines wether the current material of the mesh should be use to render the effect.
  118525. * @param mesh defines the current mesh to render
  118526. */
  118527. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  118528. /**
  118529. * Rebuild the required buffers.
  118530. * @hidden Internal use only.
  118531. */
  118532. _rebuild(): void;
  118533. /**
  118534. * Dispose only the render target textures and post process.
  118535. */
  118536. private _disposeTextureAndPostProcesses;
  118537. /**
  118538. * Dispose the highlight layer and free resources.
  118539. */
  118540. dispose(): void;
  118541. /**
  118542. * Gets the class name of the effect layer
  118543. * @returns the string with the class name of the effect layer
  118544. */
  118545. getClassName(): string;
  118546. /**
  118547. * Creates an effect layer from parsed effect layer data
  118548. * @param parsedEffectLayer defines effect layer data
  118549. * @param scene defines the current scene
  118550. * @param rootUrl defines the root URL containing the effect layer information
  118551. * @returns a parsed effect Layer
  118552. */
  118553. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  118554. }
  118555. }
  118556. declare module BABYLON {
  118557. interface AbstractScene {
  118558. /**
  118559. * The list of effect layers (highlights/glow) added to the scene
  118560. * @see http://doc.babylonjs.com/how_to/highlight_layer
  118561. * @see http://doc.babylonjs.com/how_to/glow_layer
  118562. */
  118563. effectLayers: Array<EffectLayer>;
  118564. /**
  118565. * Removes the given effect layer from this scene.
  118566. * @param toRemove defines the effect layer to remove
  118567. * @returns the index of the removed effect layer
  118568. */
  118569. removeEffectLayer(toRemove: EffectLayer): number;
  118570. /**
  118571. * Adds the given effect layer to this scene
  118572. * @param newEffectLayer defines the effect layer to add
  118573. */
  118574. addEffectLayer(newEffectLayer: EffectLayer): void;
  118575. }
  118576. /**
  118577. * Defines the layer scene component responsible to manage any effect layers
  118578. * in a given scene.
  118579. */
  118580. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  118581. /**
  118582. * The component name helpfull to identify the component in the list of scene components.
  118583. */
  118584. readonly name: string;
  118585. /**
  118586. * The scene the component belongs to.
  118587. */
  118588. scene: Scene;
  118589. private _engine;
  118590. private _renderEffects;
  118591. private _needStencil;
  118592. private _previousStencilState;
  118593. /**
  118594. * Creates a new instance of the component for the given scene
  118595. * @param scene Defines the scene to register the component in
  118596. */
  118597. constructor(scene: Scene);
  118598. /**
  118599. * Registers the component in a given scene
  118600. */
  118601. register(): void;
  118602. /**
  118603. * Rebuilds the elements related to this component in case of
  118604. * context lost for instance.
  118605. */
  118606. rebuild(): void;
  118607. /**
  118608. * Serializes the component data to the specified json object
  118609. * @param serializationObject The object to serialize to
  118610. */
  118611. serialize(serializationObject: any): void;
  118612. /**
  118613. * Adds all the elements from the container to the scene
  118614. * @param container the container holding the elements
  118615. */
  118616. addFromContainer(container: AbstractScene): void;
  118617. /**
  118618. * Removes all the elements in the container from the scene
  118619. * @param container contains the elements to remove
  118620. * @param dispose if the removed element should be disposed (default: false)
  118621. */
  118622. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118623. /**
  118624. * Disposes the component and the associated ressources.
  118625. */
  118626. dispose(): void;
  118627. private _isReadyForMesh;
  118628. private _renderMainTexture;
  118629. private _setStencil;
  118630. private _setStencilBack;
  118631. private _draw;
  118632. private _drawCamera;
  118633. private _drawRenderingGroup;
  118634. }
  118635. }
  118636. declare module BABYLON {
  118637. /** @hidden */
  118638. export var glowMapMergePixelShader: {
  118639. name: string;
  118640. shader: string;
  118641. };
  118642. }
  118643. declare module BABYLON {
  118644. /** @hidden */
  118645. export var glowMapMergeVertexShader: {
  118646. name: string;
  118647. shader: string;
  118648. };
  118649. }
  118650. declare module BABYLON {
  118651. interface AbstractScene {
  118652. /**
  118653. * Return a the first highlight layer of the scene with a given name.
  118654. * @param name The name of the highlight layer to look for.
  118655. * @return The highlight layer if found otherwise null.
  118656. */
  118657. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  118658. }
  118659. /**
  118660. * Glow layer options. This helps customizing the behaviour
  118661. * of the glow layer.
  118662. */
  118663. export interface IGlowLayerOptions {
  118664. /**
  118665. * Multiplication factor apply to the canvas size to compute the render target size
  118666. * used to generated the glowing objects (the smaller the faster).
  118667. */
  118668. mainTextureRatio: number;
  118669. /**
  118670. * Enforces a fixed size texture to ensure resize independant blur.
  118671. */
  118672. mainTextureFixedSize?: number;
  118673. /**
  118674. * How big is the kernel of the blur texture.
  118675. */
  118676. blurKernelSize: number;
  118677. /**
  118678. * The camera attached to the layer.
  118679. */
  118680. camera: Nullable<Camera>;
  118681. /**
  118682. * Enable MSAA by chosing the number of samples.
  118683. */
  118684. mainTextureSamples?: number;
  118685. /**
  118686. * The rendering group to draw the layer in.
  118687. */
  118688. renderingGroupId: number;
  118689. }
  118690. /**
  118691. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  118692. *
  118693. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  118694. *
  118695. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  118696. */
  118697. export class GlowLayer extends EffectLayer {
  118698. /**
  118699. * Effect Name of the layer.
  118700. */
  118701. static readonly EffectName: string;
  118702. /**
  118703. * The default blur kernel size used for the glow.
  118704. */
  118705. static DefaultBlurKernelSize: number;
  118706. /**
  118707. * The default texture size ratio used for the glow.
  118708. */
  118709. static DefaultTextureRatio: number;
  118710. /**
  118711. * Sets the kernel size of the blur.
  118712. */
  118713. /**
  118714. * Gets the kernel size of the blur.
  118715. */
  118716. blurKernelSize: number;
  118717. /**
  118718. * Sets the glow intensity.
  118719. */
  118720. /**
  118721. * Gets the glow intensity.
  118722. */
  118723. intensity: number;
  118724. private _options;
  118725. private _intensity;
  118726. private _horizontalBlurPostprocess1;
  118727. private _verticalBlurPostprocess1;
  118728. private _horizontalBlurPostprocess2;
  118729. private _verticalBlurPostprocess2;
  118730. private _blurTexture1;
  118731. private _blurTexture2;
  118732. private _postProcesses1;
  118733. private _postProcesses2;
  118734. private _includedOnlyMeshes;
  118735. private _excludedMeshes;
  118736. private _meshesUsingTheirOwnMaterials;
  118737. /**
  118738. * Callback used to let the user override the color selection on a per mesh basis
  118739. */
  118740. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  118741. /**
  118742. * Callback used to let the user override the texture selection on a per mesh basis
  118743. */
  118744. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  118745. /**
  118746. * Instantiates a new glow Layer and references it to the scene.
  118747. * @param name The name of the layer
  118748. * @param scene The scene to use the layer in
  118749. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  118750. */
  118751. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  118752. /**
  118753. * Get the effect name of the layer.
  118754. * @return The effect name
  118755. */
  118756. getEffectName(): string;
  118757. /**
  118758. * Create the merge effect. This is the shader use to blit the information back
  118759. * to the main canvas at the end of the scene rendering.
  118760. */
  118761. protected _createMergeEffect(): Effect;
  118762. /**
  118763. * Creates the render target textures and post processes used in the glow layer.
  118764. */
  118765. protected _createTextureAndPostProcesses(): void;
  118766. /**
  118767. * Checks for the readiness of the element composing the layer.
  118768. * @param subMesh the mesh to check for
  118769. * @param useInstances specify wether or not to use instances to render the mesh
  118770. * @param emissiveTexture the associated emissive texture used to generate the glow
  118771. * @return true if ready otherwise, false
  118772. */
  118773. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118774. /**
  118775. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118776. */
  118777. needStencil(): boolean;
  118778. /**
  118779. * Returns true if the mesh can be rendered, otherwise false.
  118780. * @param mesh The mesh to render
  118781. * @param material The material used on the mesh
  118782. * @returns true if it can be rendered otherwise false
  118783. */
  118784. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  118785. /**
  118786. * Implementation specific of rendering the generating effect on the main canvas.
  118787. * @param effect The effect used to render through
  118788. */
  118789. protected _internalRender(effect: Effect): void;
  118790. /**
  118791. * Sets the required values for both the emissive texture and and the main color.
  118792. */
  118793. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118794. /**
  118795. * Returns true if the mesh should render, otherwise false.
  118796. * @param mesh The mesh to render
  118797. * @returns true if it should render otherwise false
  118798. */
  118799. protected _shouldRenderMesh(mesh: Mesh): boolean;
  118800. /**
  118801. * Adds specific effects defines.
  118802. * @param defines The defines to add specifics to.
  118803. */
  118804. protected _addCustomEffectDefines(defines: string[]): void;
  118805. /**
  118806. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  118807. * @param mesh The mesh to exclude from the glow layer
  118808. */
  118809. addExcludedMesh(mesh: Mesh): void;
  118810. /**
  118811. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  118812. * @param mesh The mesh to remove
  118813. */
  118814. removeExcludedMesh(mesh: Mesh): void;
  118815. /**
  118816. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  118817. * @param mesh The mesh to include in the glow layer
  118818. */
  118819. addIncludedOnlyMesh(mesh: Mesh): void;
  118820. /**
  118821. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  118822. * @param mesh The mesh to remove
  118823. */
  118824. removeIncludedOnlyMesh(mesh: Mesh): void;
  118825. /**
  118826. * Determine if a given mesh will be used in the glow layer
  118827. * @param mesh The mesh to test
  118828. * @returns true if the mesh will be highlighted by the current glow layer
  118829. */
  118830. hasMesh(mesh: AbstractMesh): boolean;
  118831. /**
  118832. * Defines wether the current material of the mesh should be use to render the effect.
  118833. * @param mesh defines the current mesh to render
  118834. */
  118835. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  118836. /**
  118837. * Add a mesh to be rendered through its own material and not with emissive only.
  118838. * @param mesh The mesh for which we need to use its material
  118839. */
  118840. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  118841. /**
  118842. * Remove a mesh from being rendered through its own material and not with emissive only.
  118843. * @param mesh The mesh for which we need to not use its material
  118844. */
  118845. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  118846. /**
  118847. * Free any resources and references associated to a mesh.
  118848. * Internal use
  118849. * @param mesh The mesh to free.
  118850. * @hidden
  118851. */
  118852. _disposeMesh(mesh: Mesh): void;
  118853. /**
  118854. * Gets the class name of the effect layer
  118855. * @returns the string with the class name of the effect layer
  118856. */
  118857. getClassName(): string;
  118858. /**
  118859. * Serializes this glow layer
  118860. * @returns a serialized glow layer object
  118861. */
  118862. serialize(): any;
  118863. /**
  118864. * Creates a Glow Layer from parsed glow layer data
  118865. * @param parsedGlowLayer defines glow layer data
  118866. * @param scene defines the current scene
  118867. * @param rootUrl defines the root URL containing the glow layer information
  118868. * @returns a parsed Glow Layer
  118869. */
  118870. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  118871. }
  118872. }
  118873. declare module BABYLON {
  118874. /** @hidden */
  118875. export var glowBlurPostProcessPixelShader: {
  118876. name: string;
  118877. shader: string;
  118878. };
  118879. }
  118880. declare module BABYLON {
  118881. interface AbstractScene {
  118882. /**
  118883. * Return a the first highlight layer of the scene with a given name.
  118884. * @param name The name of the highlight layer to look for.
  118885. * @return The highlight layer if found otherwise null.
  118886. */
  118887. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  118888. }
  118889. /**
  118890. * Highlight layer options. This helps customizing the behaviour
  118891. * of the highlight layer.
  118892. */
  118893. export interface IHighlightLayerOptions {
  118894. /**
  118895. * Multiplication factor apply to the canvas size to compute the render target size
  118896. * used to generated the glowing objects (the smaller the faster).
  118897. */
  118898. mainTextureRatio: number;
  118899. /**
  118900. * Enforces a fixed size texture to ensure resize independant blur.
  118901. */
  118902. mainTextureFixedSize?: number;
  118903. /**
  118904. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  118905. * of the picture to blur (the smaller the faster).
  118906. */
  118907. blurTextureSizeRatio: number;
  118908. /**
  118909. * How big in texel of the blur texture is the vertical blur.
  118910. */
  118911. blurVerticalSize: number;
  118912. /**
  118913. * How big in texel of the blur texture is the horizontal blur.
  118914. */
  118915. blurHorizontalSize: number;
  118916. /**
  118917. * Alpha blending mode used to apply the blur. Default is combine.
  118918. */
  118919. alphaBlendingMode: number;
  118920. /**
  118921. * The camera attached to the layer.
  118922. */
  118923. camera: Nullable<Camera>;
  118924. /**
  118925. * Should we display highlight as a solid stroke?
  118926. */
  118927. isStroke?: boolean;
  118928. /**
  118929. * The rendering group to draw the layer in.
  118930. */
  118931. renderingGroupId: number;
  118932. }
  118933. /**
  118934. * The highlight layer Helps adding a glow effect around a mesh.
  118935. *
  118936. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  118937. * glowy meshes to your scene.
  118938. *
  118939. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  118940. */
  118941. export class HighlightLayer extends EffectLayer {
  118942. name: string;
  118943. /**
  118944. * Effect Name of the highlight layer.
  118945. */
  118946. static readonly EffectName: string;
  118947. /**
  118948. * The neutral color used during the preparation of the glow effect.
  118949. * This is black by default as the blend operation is a blend operation.
  118950. */
  118951. static NeutralColor: Color4;
  118952. /**
  118953. * Stencil value used for glowing meshes.
  118954. */
  118955. static GlowingMeshStencilReference: number;
  118956. /**
  118957. * Stencil value used for the other meshes in the scene.
  118958. */
  118959. static NormalMeshStencilReference: number;
  118960. /**
  118961. * Specifies whether or not the inner glow is ACTIVE in the layer.
  118962. */
  118963. innerGlow: boolean;
  118964. /**
  118965. * Specifies whether or not the outer glow is ACTIVE in the layer.
  118966. */
  118967. outerGlow: boolean;
  118968. /**
  118969. * Specifies the horizontal size of the blur.
  118970. */
  118971. /**
  118972. * Gets the horizontal size of the blur.
  118973. */
  118974. blurHorizontalSize: number;
  118975. /**
  118976. * Specifies the vertical size of the blur.
  118977. */
  118978. /**
  118979. * Gets the vertical size of the blur.
  118980. */
  118981. blurVerticalSize: number;
  118982. /**
  118983. * An event triggered when the highlight layer is being blurred.
  118984. */
  118985. onBeforeBlurObservable: Observable<HighlightLayer>;
  118986. /**
  118987. * An event triggered when the highlight layer has been blurred.
  118988. */
  118989. onAfterBlurObservable: Observable<HighlightLayer>;
  118990. private _instanceGlowingMeshStencilReference;
  118991. private _options;
  118992. private _downSamplePostprocess;
  118993. private _horizontalBlurPostprocess;
  118994. private _verticalBlurPostprocess;
  118995. private _blurTexture;
  118996. private _meshes;
  118997. private _excludedMeshes;
  118998. /**
  118999. * Instantiates a new highlight Layer and references it to the scene..
  119000. * @param name The name of the layer
  119001. * @param scene The scene to use the layer in
  119002. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  119003. */
  119004. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  119005. /**
  119006. * Get the effect name of the layer.
  119007. * @return The effect name
  119008. */
  119009. getEffectName(): string;
  119010. /**
  119011. * Create the merge effect. This is the shader use to blit the information back
  119012. * to the main canvas at the end of the scene rendering.
  119013. */
  119014. protected _createMergeEffect(): Effect;
  119015. /**
  119016. * Creates the render target textures and post processes used in the highlight layer.
  119017. */
  119018. protected _createTextureAndPostProcesses(): void;
  119019. /**
  119020. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  119021. */
  119022. needStencil(): boolean;
  119023. /**
  119024. * Checks for the readiness of the element composing the layer.
  119025. * @param subMesh the mesh to check for
  119026. * @param useInstances specify wether or not to use instances to render the mesh
  119027. * @param emissiveTexture the associated emissive texture used to generate the glow
  119028. * @return true if ready otherwise, false
  119029. */
  119030. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119031. /**
  119032. * Implementation specific of rendering the generating effect on the main canvas.
  119033. * @param effect The effect used to render through
  119034. */
  119035. protected _internalRender(effect: Effect): void;
  119036. /**
  119037. * Returns true if the layer contains information to display, otherwise false.
  119038. */
  119039. shouldRender(): boolean;
  119040. /**
  119041. * Returns true if the mesh should render, otherwise false.
  119042. * @param mesh The mesh to render
  119043. * @returns true if it should render otherwise false
  119044. */
  119045. protected _shouldRenderMesh(mesh: Mesh): boolean;
  119046. /**
  119047. * Sets the required values for both the emissive texture and and the main color.
  119048. */
  119049. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  119050. /**
  119051. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  119052. * @param mesh The mesh to exclude from the highlight layer
  119053. */
  119054. addExcludedMesh(mesh: Mesh): void;
  119055. /**
  119056. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  119057. * @param mesh The mesh to highlight
  119058. */
  119059. removeExcludedMesh(mesh: Mesh): void;
  119060. /**
  119061. * Determine if a given mesh will be highlighted by the current HighlightLayer
  119062. * @param mesh mesh to test
  119063. * @returns true if the mesh will be highlighted by the current HighlightLayer
  119064. */
  119065. hasMesh(mesh: AbstractMesh): boolean;
  119066. /**
  119067. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  119068. * @param mesh The mesh to highlight
  119069. * @param color The color of the highlight
  119070. * @param glowEmissiveOnly Extract the glow from the emissive texture
  119071. */
  119072. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  119073. /**
  119074. * Remove a mesh from the highlight layer in order to make it stop glowing.
  119075. * @param mesh The mesh to highlight
  119076. */
  119077. removeMesh(mesh: Mesh): void;
  119078. /**
  119079. * Force the stencil to the normal expected value for none glowing parts
  119080. */
  119081. private _defaultStencilReference;
  119082. /**
  119083. * Free any resources and references associated to a mesh.
  119084. * Internal use
  119085. * @param mesh The mesh to free.
  119086. * @hidden
  119087. */
  119088. _disposeMesh(mesh: Mesh): void;
  119089. /**
  119090. * Dispose the highlight layer and free resources.
  119091. */
  119092. dispose(): void;
  119093. /**
  119094. * Gets the class name of the effect layer
  119095. * @returns the string with the class name of the effect layer
  119096. */
  119097. getClassName(): string;
  119098. /**
  119099. * Serializes this Highlight layer
  119100. * @returns a serialized Highlight layer object
  119101. */
  119102. serialize(): any;
  119103. /**
  119104. * Creates a Highlight layer from parsed Highlight layer data
  119105. * @param parsedHightlightLayer defines the Highlight layer data
  119106. * @param scene defines the current scene
  119107. * @param rootUrl defines the root URL containing the Highlight layer information
  119108. * @returns a parsed Highlight layer
  119109. */
  119110. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  119111. }
  119112. }
  119113. declare module BABYLON {
  119114. interface AbstractScene {
  119115. /**
  119116. * The list of layers (background and foreground) of the scene
  119117. */
  119118. layers: Array<Layer>;
  119119. }
  119120. /**
  119121. * Defines the layer scene component responsible to manage any layers
  119122. * in a given scene.
  119123. */
  119124. export class LayerSceneComponent implements ISceneComponent {
  119125. /**
  119126. * The component name helpfull to identify the component in the list of scene components.
  119127. */
  119128. readonly name: string;
  119129. /**
  119130. * The scene the component belongs to.
  119131. */
  119132. scene: Scene;
  119133. private _engine;
  119134. /**
  119135. * Creates a new instance of the component for the given scene
  119136. * @param scene Defines the scene to register the component in
  119137. */
  119138. constructor(scene: Scene);
  119139. /**
  119140. * Registers the component in a given scene
  119141. */
  119142. register(): void;
  119143. /**
  119144. * Rebuilds the elements related to this component in case of
  119145. * context lost for instance.
  119146. */
  119147. rebuild(): void;
  119148. /**
  119149. * Disposes the component and the associated ressources.
  119150. */
  119151. dispose(): void;
  119152. private _draw;
  119153. private _drawCameraPredicate;
  119154. private _drawCameraBackground;
  119155. private _drawCameraForeground;
  119156. private _drawRenderTargetPredicate;
  119157. private _drawRenderTargetBackground;
  119158. private _drawRenderTargetForeground;
  119159. /**
  119160. * Adds all the elements from the container to the scene
  119161. * @param container the container holding the elements
  119162. */
  119163. addFromContainer(container: AbstractScene): void;
  119164. /**
  119165. * Removes all the elements in the container from the scene
  119166. * @param container contains the elements to remove
  119167. * @param dispose if the removed element should be disposed (default: false)
  119168. */
  119169. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119170. }
  119171. }
  119172. declare module BABYLON {
  119173. /** @hidden */
  119174. export var layerPixelShader: {
  119175. name: string;
  119176. shader: string;
  119177. };
  119178. }
  119179. declare module BABYLON {
  119180. /** @hidden */
  119181. export var layerVertexShader: {
  119182. name: string;
  119183. shader: string;
  119184. };
  119185. }
  119186. declare module BABYLON {
  119187. /**
  119188. * This represents a full screen 2d layer.
  119189. * This can be useful to display a picture in the background of your scene for instance.
  119190. * @see https://www.babylonjs-playground.com/#08A2BS#1
  119191. */
  119192. export class Layer {
  119193. /**
  119194. * Define the name of the layer.
  119195. */
  119196. name: string;
  119197. /**
  119198. * Define the texture the layer should display.
  119199. */
  119200. texture: Nullable<Texture>;
  119201. /**
  119202. * Is the layer in background or foreground.
  119203. */
  119204. isBackground: boolean;
  119205. /**
  119206. * Define the color of the layer (instead of texture).
  119207. */
  119208. color: Color4;
  119209. /**
  119210. * Define the scale of the layer in order to zoom in out of the texture.
  119211. */
  119212. scale: Vector2;
  119213. /**
  119214. * Define an offset for the layer in order to shift the texture.
  119215. */
  119216. offset: Vector2;
  119217. /**
  119218. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  119219. */
  119220. alphaBlendingMode: number;
  119221. /**
  119222. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  119223. * Alpha test will not mix with the background color in case of transparency.
  119224. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  119225. */
  119226. alphaTest: boolean;
  119227. /**
  119228. * Define a mask to restrict the layer to only some of the scene cameras.
  119229. */
  119230. layerMask: number;
  119231. /**
  119232. * Define the list of render target the layer is visible into.
  119233. */
  119234. renderTargetTextures: RenderTargetTexture[];
  119235. /**
  119236. * Define if the layer is only used in renderTarget or if it also
  119237. * renders in the main frame buffer of the canvas.
  119238. */
  119239. renderOnlyInRenderTargetTextures: boolean;
  119240. private _scene;
  119241. private _vertexBuffers;
  119242. private _indexBuffer;
  119243. private _effect;
  119244. private _alphaTestEffect;
  119245. /**
  119246. * An event triggered when the layer is disposed.
  119247. */
  119248. onDisposeObservable: Observable<Layer>;
  119249. private _onDisposeObserver;
  119250. /**
  119251. * Back compatibility with callback before the onDisposeObservable existed.
  119252. * The set callback will be triggered when the layer has been disposed.
  119253. */
  119254. onDispose: () => void;
  119255. /**
  119256. * An event triggered before rendering the scene
  119257. */
  119258. onBeforeRenderObservable: Observable<Layer>;
  119259. private _onBeforeRenderObserver;
  119260. /**
  119261. * Back compatibility with callback before the onBeforeRenderObservable existed.
  119262. * The set callback will be triggered just before rendering the layer.
  119263. */
  119264. onBeforeRender: () => void;
  119265. /**
  119266. * An event triggered after rendering the scene
  119267. */
  119268. onAfterRenderObservable: Observable<Layer>;
  119269. private _onAfterRenderObserver;
  119270. /**
  119271. * Back compatibility with callback before the onAfterRenderObservable existed.
  119272. * The set callback will be triggered just after rendering the layer.
  119273. */
  119274. onAfterRender: () => void;
  119275. /**
  119276. * Instantiates a new layer.
  119277. * This represents a full screen 2d layer.
  119278. * This can be useful to display a picture in the background of your scene for instance.
  119279. * @see https://www.babylonjs-playground.com/#08A2BS#1
  119280. * @param name Define the name of the layer in the scene
  119281. * @param imgUrl Define the url of the texture to display in the layer
  119282. * @param scene Define the scene the layer belongs to
  119283. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  119284. * @param color Defines a color for the layer
  119285. */
  119286. constructor(
  119287. /**
  119288. * Define the name of the layer.
  119289. */
  119290. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  119291. private _createIndexBuffer;
  119292. /** @hidden */
  119293. _rebuild(): void;
  119294. /**
  119295. * Renders the layer in the scene.
  119296. */
  119297. render(): void;
  119298. /**
  119299. * Disposes and releases the associated ressources.
  119300. */
  119301. dispose(): void;
  119302. }
  119303. }
  119304. declare module BABYLON {
  119305. /** @hidden */
  119306. export var lensFlarePixelShader: {
  119307. name: string;
  119308. shader: string;
  119309. };
  119310. }
  119311. declare module BABYLON {
  119312. /** @hidden */
  119313. export var lensFlareVertexShader: {
  119314. name: string;
  119315. shader: string;
  119316. };
  119317. }
  119318. declare module BABYLON {
  119319. /**
  119320. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  119321. * It is usually composed of several `lensFlare`.
  119322. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119323. */
  119324. export class LensFlareSystem {
  119325. /**
  119326. * Define the name of the lens flare system
  119327. */
  119328. name: string;
  119329. /**
  119330. * List of lens flares used in this system.
  119331. */
  119332. lensFlares: LensFlare[];
  119333. /**
  119334. * Define a limit from the border the lens flare can be visible.
  119335. */
  119336. borderLimit: number;
  119337. /**
  119338. * Define a viewport border we do not want to see the lens flare in.
  119339. */
  119340. viewportBorder: number;
  119341. /**
  119342. * Define a predicate which could limit the list of meshes able to occlude the effect.
  119343. */
  119344. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  119345. /**
  119346. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  119347. */
  119348. layerMask: number;
  119349. /**
  119350. * Define the id of the lens flare system in the scene.
  119351. * (equal to name by default)
  119352. */
  119353. id: string;
  119354. private _scene;
  119355. private _emitter;
  119356. private _vertexBuffers;
  119357. private _indexBuffer;
  119358. private _effect;
  119359. private _positionX;
  119360. private _positionY;
  119361. private _isEnabled;
  119362. /** @hidden */
  119363. static _SceneComponentInitialization: (scene: Scene) => void;
  119364. /**
  119365. * Instantiates a lens flare system.
  119366. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  119367. * It is usually composed of several `lensFlare`.
  119368. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119369. * @param name Define the name of the lens flare system in the scene
  119370. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  119371. * @param scene Define the scene the lens flare system belongs to
  119372. */
  119373. constructor(
  119374. /**
  119375. * Define the name of the lens flare system
  119376. */
  119377. name: string, emitter: any, scene: Scene);
  119378. /**
  119379. * Define if the lens flare system is enabled.
  119380. */
  119381. isEnabled: boolean;
  119382. /**
  119383. * Get the scene the effects belongs to.
  119384. * @returns the scene holding the lens flare system
  119385. */
  119386. getScene(): Scene;
  119387. /**
  119388. * Get the emitter of the lens flare system.
  119389. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  119390. * @returns the emitter of the lens flare system
  119391. */
  119392. getEmitter(): any;
  119393. /**
  119394. * Set the emitter of the lens flare system.
  119395. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  119396. * @param newEmitter Define the new emitter of the system
  119397. */
  119398. setEmitter(newEmitter: any): void;
  119399. /**
  119400. * Get the lens flare system emitter position.
  119401. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  119402. * @returns the position
  119403. */
  119404. getEmitterPosition(): Vector3;
  119405. /**
  119406. * @hidden
  119407. */
  119408. computeEffectivePosition(globalViewport: Viewport): boolean;
  119409. /** @hidden */
  119410. _isVisible(): boolean;
  119411. /**
  119412. * @hidden
  119413. */
  119414. render(): boolean;
  119415. /**
  119416. * Dispose and release the lens flare with its associated resources.
  119417. */
  119418. dispose(): void;
  119419. /**
  119420. * Parse a lens flare system from a JSON repressentation
  119421. * @param parsedLensFlareSystem Define the JSON to parse
  119422. * @param scene Define the scene the parsed system should be instantiated in
  119423. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  119424. * @returns the parsed system
  119425. */
  119426. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  119427. /**
  119428. * Serialize the current Lens Flare System into a JSON representation.
  119429. * @returns the serialized JSON
  119430. */
  119431. serialize(): any;
  119432. }
  119433. }
  119434. declare module BABYLON {
  119435. /**
  119436. * This represents one of the lens effect in a `lensFlareSystem`.
  119437. * It controls one of the indiviual texture used in the effect.
  119438. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119439. */
  119440. export class LensFlare {
  119441. /**
  119442. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119443. */
  119444. size: number;
  119445. /**
  119446. * 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.
  119447. */
  119448. position: number;
  119449. /**
  119450. * Define the lens color.
  119451. */
  119452. color: Color3;
  119453. /**
  119454. * Define the lens texture.
  119455. */
  119456. texture: Nullable<Texture>;
  119457. /**
  119458. * Define the alpha mode to render this particular lens.
  119459. */
  119460. alphaMode: number;
  119461. private _system;
  119462. /**
  119463. * Creates a new Lens Flare.
  119464. * This represents one of the lens effect in a `lensFlareSystem`.
  119465. * It controls one of the indiviual texture used in the effect.
  119466. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119467. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  119468. * @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.
  119469. * @param color Define the lens color
  119470. * @param imgUrl Define the lens texture url
  119471. * @param system Define the `lensFlareSystem` this flare is part of
  119472. * @returns The newly created Lens Flare
  119473. */
  119474. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  119475. /**
  119476. * Instantiates a new Lens Flare.
  119477. * This represents one of the lens effect in a `lensFlareSystem`.
  119478. * It controls one of the indiviual texture used in the effect.
  119479. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119480. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  119481. * @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.
  119482. * @param color Define the lens color
  119483. * @param imgUrl Define the lens texture url
  119484. * @param system Define the `lensFlareSystem` this flare is part of
  119485. */
  119486. constructor(
  119487. /**
  119488. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119489. */
  119490. size: number,
  119491. /**
  119492. * 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.
  119493. */
  119494. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  119495. /**
  119496. * Dispose and release the lens flare with its associated resources.
  119497. */
  119498. dispose(): void;
  119499. }
  119500. }
  119501. declare module BABYLON {
  119502. interface AbstractScene {
  119503. /**
  119504. * The list of lens flare system added to the scene
  119505. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119506. */
  119507. lensFlareSystems: Array<LensFlareSystem>;
  119508. /**
  119509. * Removes the given lens flare system from this scene.
  119510. * @param toRemove The lens flare system to remove
  119511. * @returns The index of the removed lens flare system
  119512. */
  119513. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  119514. /**
  119515. * Adds the given lens flare system to this scene
  119516. * @param newLensFlareSystem The lens flare system to add
  119517. */
  119518. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  119519. /**
  119520. * Gets a lens flare system using its name
  119521. * @param name defines the name to look for
  119522. * @returns the lens flare system or null if not found
  119523. */
  119524. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  119525. /**
  119526. * Gets a lens flare system using its id
  119527. * @param id defines the id to look for
  119528. * @returns the lens flare system or null if not found
  119529. */
  119530. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  119531. }
  119532. /**
  119533. * Defines the lens flare scene component responsible to manage any lens flares
  119534. * in a given scene.
  119535. */
  119536. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  119537. /**
  119538. * The component name helpfull to identify the component in the list of scene components.
  119539. */
  119540. readonly name: string;
  119541. /**
  119542. * The scene the component belongs to.
  119543. */
  119544. scene: Scene;
  119545. /**
  119546. * Creates a new instance of the component for the given scene
  119547. * @param scene Defines the scene to register the component in
  119548. */
  119549. constructor(scene: Scene);
  119550. /**
  119551. * Registers the component in a given scene
  119552. */
  119553. register(): void;
  119554. /**
  119555. * Rebuilds the elements related to this component in case of
  119556. * context lost for instance.
  119557. */
  119558. rebuild(): void;
  119559. /**
  119560. * Adds all the elements from the container to the scene
  119561. * @param container the container holding the elements
  119562. */
  119563. addFromContainer(container: AbstractScene): void;
  119564. /**
  119565. * Removes all the elements in the container from the scene
  119566. * @param container contains the elements to remove
  119567. * @param dispose if the removed element should be disposed (default: false)
  119568. */
  119569. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119570. /**
  119571. * Serializes the component data to the specified json object
  119572. * @param serializationObject The object to serialize to
  119573. */
  119574. serialize(serializationObject: any): void;
  119575. /**
  119576. * Disposes the component and the associated ressources.
  119577. */
  119578. dispose(): void;
  119579. private _draw;
  119580. }
  119581. }
  119582. declare module BABYLON {
  119583. /**
  119584. * Defines the shadow generator component responsible to manage any shadow generators
  119585. * in a given scene.
  119586. */
  119587. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  119588. /**
  119589. * The component name helpfull to identify the component in the list of scene components.
  119590. */
  119591. readonly name: string;
  119592. /**
  119593. * The scene the component belongs to.
  119594. */
  119595. scene: Scene;
  119596. /**
  119597. * Creates a new instance of the component for the given scene
  119598. * @param scene Defines the scene to register the component in
  119599. */
  119600. constructor(scene: Scene);
  119601. /**
  119602. * Registers the component in a given scene
  119603. */
  119604. register(): void;
  119605. /**
  119606. * Rebuilds the elements related to this component in case of
  119607. * context lost for instance.
  119608. */
  119609. rebuild(): void;
  119610. /**
  119611. * Serializes the component data to the specified json object
  119612. * @param serializationObject The object to serialize to
  119613. */
  119614. serialize(serializationObject: any): void;
  119615. /**
  119616. * Adds all the elements from the container to the scene
  119617. * @param container the container holding the elements
  119618. */
  119619. addFromContainer(container: AbstractScene): void;
  119620. /**
  119621. * Removes all the elements in the container from the scene
  119622. * @param container contains the elements to remove
  119623. * @param dispose if the removed element should be disposed (default: false)
  119624. */
  119625. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119626. /**
  119627. * Rebuilds the elements related to this component in case of
  119628. * context lost for instance.
  119629. */
  119630. dispose(): void;
  119631. private _gatherRenderTargets;
  119632. }
  119633. }
  119634. declare module BABYLON {
  119635. /**
  119636. * A point light is a light defined by an unique point in world space.
  119637. * The light is emitted in every direction from this point.
  119638. * A good example of a point light is a standard light bulb.
  119639. * Documentation: https://doc.babylonjs.com/babylon101/lights
  119640. */
  119641. export class PointLight extends ShadowLight {
  119642. private _shadowAngle;
  119643. /**
  119644. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119645. * This specifies what angle the shadow will use to be created.
  119646. *
  119647. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  119648. */
  119649. /**
  119650. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119651. * This specifies what angle the shadow will use to be created.
  119652. *
  119653. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  119654. */
  119655. shadowAngle: number;
  119656. /**
  119657. * Gets the direction if it has been set.
  119658. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119659. */
  119660. /**
  119661. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119662. */
  119663. direction: Vector3;
  119664. /**
  119665. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  119666. * A PointLight emits the light in every direction.
  119667. * It can cast shadows.
  119668. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  119669. * ```javascript
  119670. * var pointLight = new PointLight("pl", camera.position, scene);
  119671. * ```
  119672. * Documentation : https://doc.babylonjs.com/babylon101/lights
  119673. * @param name The light friendly name
  119674. * @param position The position of the point light in the scene
  119675. * @param scene The scene the lights belongs to
  119676. */
  119677. constructor(name: string, position: Vector3, scene: Scene);
  119678. /**
  119679. * Returns the string "PointLight"
  119680. * @returns the class name
  119681. */
  119682. getClassName(): string;
  119683. /**
  119684. * Returns the integer 0.
  119685. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  119686. */
  119687. getTypeID(): number;
  119688. /**
  119689. * Specifies wether or not the shadowmap should be a cube texture.
  119690. * @returns true if the shadowmap needs to be a cube texture.
  119691. */
  119692. needCube(): boolean;
  119693. /**
  119694. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  119695. * @param faceIndex The index of the face we are computed the direction to generate shadow
  119696. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  119697. */
  119698. getShadowDirection(faceIndex?: number): Vector3;
  119699. /**
  119700. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  119701. * - fov = PI / 2
  119702. * - aspect ratio : 1.0
  119703. * - z-near and far equal to the active camera minZ and maxZ.
  119704. * Returns the PointLight.
  119705. */
  119706. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  119707. protected _buildUniformLayout(): void;
  119708. /**
  119709. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  119710. * @param effect The effect to update
  119711. * @param lightIndex The index of the light in the effect to update
  119712. * @returns The point light
  119713. */
  119714. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  119715. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  119716. /**
  119717. * Prepares the list of defines specific to the light type.
  119718. * @param defines the list of defines
  119719. * @param lightIndex defines the index of the light for the effect
  119720. */
  119721. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  119722. }
  119723. }
  119724. declare module BABYLON {
  119725. /**
  119726. * Header information of HDR texture files.
  119727. */
  119728. export interface HDRInfo {
  119729. /**
  119730. * The height of the texture in pixels.
  119731. */
  119732. height: number;
  119733. /**
  119734. * The width of the texture in pixels.
  119735. */
  119736. width: number;
  119737. /**
  119738. * The index of the beginning of the data in the binary file.
  119739. */
  119740. dataPosition: number;
  119741. }
  119742. /**
  119743. * This groups tools to convert HDR texture to native colors array.
  119744. */
  119745. export class HDRTools {
  119746. private static Ldexp;
  119747. private static Rgbe2float;
  119748. private static readStringLine;
  119749. /**
  119750. * Reads header information from an RGBE texture stored in a native array.
  119751. * More information on this format are available here:
  119752. * https://en.wikipedia.org/wiki/RGBE_image_format
  119753. *
  119754. * @param uint8array The binary file stored in native array.
  119755. * @return The header information.
  119756. */
  119757. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  119758. /**
  119759. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  119760. * This RGBE texture needs to store the information as a panorama.
  119761. *
  119762. * More information on this format are available here:
  119763. * https://en.wikipedia.org/wiki/RGBE_image_format
  119764. *
  119765. * @param buffer The binary file stored in an array buffer.
  119766. * @param size The expected size of the extracted cubemap.
  119767. * @return The Cube Map information.
  119768. */
  119769. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  119770. /**
  119771. * Returns the pixels data extracted from an RGBE texture.
  119772. * This pixels will be stored left to right up to down in the R G B order in one array.
  119773. *
  119774. * More information on this format are available here:
  119775. * https://en.wikipedia.org/wiki/RGBE_image_format
  119776. *
  119777. * @param uint8array The binary file stored in an array buffer.
  119778. * @param hdrInfo The header information of the file.
  119779. * @return The pixels data in RGB right to left up to down order.
  119780. */
  119781. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  119782. private static RGBE_ReadPixels_RLE;
  119783. }
  119784. }
  119785. declare module BABYLON {
  119786. /**
  119787. * This represents a texture coming from an HDR input.
  119788. *
  119789. * The only supported format is currently panorama picture stored in RGBE format.
  119790. * Example of such files can be found on HDRLib: http://hdrlib.com/
  119791. */
  119792. export class HDRCubeTexture extends BaseTexture {
  119793. private static _facesMapping;
  119794. private _generateHarmonics;
  119795. private _noMipmap;
  119796. private _textureMatrix;
  119797. private _size;
  119798. private _onLoad;
  119799. private _onError;
  119800. /**
  119801. * The texture URL.
  119802. */
  119803. url: string;
  119804. /**
  119805. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  119806. */
  119807. coordinatesMode: number;
  119808. protected _isBlocking: boolean;
  119809. /**
  119810. * Sets wether or not the texture is blocking during loading.
  119811. */
  119812. /**
  119813. * Gets wether or not the texture is blocking during loading.
  119814. */
  119815. isBlocking: boolean;
  119816. protected _rotationY: number;
  119817. /**
  119818. * Sets texture matrix rotation angle around Y axis in radians.
  119819. */
  119820. /**
  119821. * Gets texture matrix rotation angle around Y axis radians.
  119822. */
  119823. rotationY: number;
  119824. /**
  119825. * Gets or sets the center of the bounding box associated with the cube texture
  119826. * It must define where the camera used to render the texture was set
  119827. */
  119828. boundingBoxPosition: Vector3;
  119829. private _boundingBoxSize;
  119830. /**
  119831. * Gets or sets the size of the bounding box associated with the cube texture
  119832. * When defined, the cubemap will switch to local mode
  119833. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  119834. * @example https://www.babylonjs-playground.com/#RNASML
  119835. */
  119836. boundingBoxSize: Vector3;
  119837. /**
  119838. * Instantiates an HDRTexture from the following parameters.
  119839. *
  119840. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  119841. * @param scene The scene the texture will be used in
  119842. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  119843. * @param noMipmap Forces to not generate the mipmap if true
  119844. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  119845. * @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)
  119846. * @param reserved Reserved flag for internal use.
  119847. */
  119848. 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>);
  119849. /**
  119850. * Get the current class name of the texture useful for serialization or dynamic coding.
  119851. * @returns "HDRCubeTexture"
  119852. */
  119853. getClassName(): string;
  119854. /**
  119855. * Occurs when the file is raw .hdr file.
  119856. */
  119857. private loadTexture;
  119858. clone(): HDRCubeTexture;
  119859. delayLoad(): void;
  119860. /**
  119861. * Get the texture reflection matrix used to rotate/transform the reflection.
  119862. * @returns the reflection matrix
  119863. */
  119864. getReflectionTextureMatrix(): Matrix;
  119865. /**
  119866. * Set the texture reflection matrix used to rotate/transform the reflection.
  119867. * @param value Define the reflection matrix to set
  119868. */
  119869. setReflectionTextureMatrix(value: Matrix): void;
  119870. /**
  119871. * Parses a JSON representation of an HDR Texture in order to create the texture
  119872. * @param parsedTexture Define the JSON representation
  119873. * @param scene Define the scene the texture should be created in
  119874. * @param rootUrl Define the root url in case we need to load relative dependencies
  119875. * @returns the newly created texture after parsing
  119876. */
  119877. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  119878. serialize(): any;
  119879. }
  119880. }
  119881. declare module BABYLON {
  119882. /**
  119883. * Class used to control physics engine
  119884. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  119885. */
  119886. export class PhysicsEngine implements IPhysicsEngine {
  119887. private _physicsPlugin;
  119888. /**
  119889. * Global value used to control the smallest number supported by the simulation
  119890. */
  119891. static Epsilon: number;
  119892. private _impostors;
  119893. private _joints;
  119894. /**
  119895. * Gets the gravity vector used by the simulation
  119896. */
  119897. gravity: Vector3;
  119898. /**
  119899. * Factory used to create the default physics plugin.
  119900. * @returns The default physics plugin
  119901. */
  119902. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  119903. /**
  119904. * Creates a new Physics Engine
  119905. * @param gravity defines the gravity vector used by the simulation
  119906. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  119907. */
  119908. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  119909. /**
  119910. * Sets the gravity vector used by the simulation
  119911. * @param gravity defines the gravity vector to use
  119912. */
  119913. setGravity(gravity: Vector3): void;
  119914. /**
  119915. * Set the time step of the physics engine.
  119916. * Default is 1/60.
  119917. * To slow it down, enter 1/600 for example.
  119918. * To speed it up, 1/30
  119919. * @param newTimeStep defines the new timestep to apply to this world.
  119920. */
  119921. setTimeStep(newTimeStep?: number): void;
  119922. /**
  119923. * Get the time step of the physics engine.
  119924. * @returns the current time step
  119925. */
  119926. getTimeStep(): number;
  119927. /**
  119928. * Release all resources
  119929. */
  119930. dispose(): void;
  119931. /**
  119932. * Gets the name of the current physics plugin
  119933. * @returns the name of the plugin
  119934. */
  119935. getPhysicsPluginName(): string;
  119936. /**
  119937. * Adding a new impostor for the impostor tracking.
  119938. * This will be done by the impostor itself.
  119939. * @param impostor the impostor to add
  119940. */
  119941. addImpostor(impostor: PhysicsImpostor): void;
  119942. /**
  119943. * Remove an impostor from the engine.
  119944. * This impostor and its mesh will not longer be updated by the physics engine.
  119945. * @param impostor the impostor to remove
  119946. */
  119947. removeImpostor(impostor: PhysicsImpostor): void;
  119948. /**
  119949. * Add a joint to the physics engine
  119950. * @param mainImpostor defines the main impostor to which the joint is added.
  119951. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  119952. * @param joint defines the joint that will connect both impostors.
  119953. */
  119954. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  119955. /**
  119956. * Removes a joint from the simulation
  119957. * @param mainImpostor defines the impostor used with the joint
  119958. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  119959. * @param joint defines the joint to remove
  119960. */
  119961. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  119962. /**
  119963. * Called by the scene. No need to call it.
  119964. * @param delta defines the timespam between frames
  119965. */
  119966. _step(delta: number): void;
  119967. /**
  119968. * Gets the current plugin used to run the simulation
  119969. * @returns current plugin
  119970. */
  119971. getPhysicsPlugin(): IPhysicsEnginePlugin;
  119972. /**
  119973. * Gets the list of physic impostors
  119974. * @returns an array of PhysicsImpostor
  119975. */
  119976. getImpostors(): Array<PhysicsImpostor>;
  119977. /**
  119978. * Gets the impostor for a physics enabled object
  119979. * @param object defines the object impersonated by the impostor
  119980. * @returns the PhysicsImpostor or null if not found
  119981. */
  119982. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  119983. /**
  119984. * Gets the impostor for a physics body object
  119985. * @param body defines physics body used by the impostor
  119986. * @returns the PhysicsImpostor or null if not found
  119987. */
  119988. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  119989. /**
  119990. * Does a raycast in the physics world
  119991. * @param from when should the ray start?
  119992. * @param to when should the ray end?
  119993. * @returns PhysicsRaycastResult
  119994. */
  119995. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119996. }
  119997. }
  119998. declare module BABYLON {
  119999. /** @hidden */
  120000. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  120001. private _useDeltaForWorldStep;
  120002. world: any;
  120003. name: string;
  120004. private _physicsMaterials;
  120005. private _fixedTimeStep;
  120006. private _cannonRaycastResult;
  120007. private _raycastResult;
  120008. private _physicsBodysToRemoveAfterStep;
  120009. BJSCANNON: any;
  120010. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  120011. setGravity(gravity: Vector3): void;
  120012. setTimeStep(timeStep: number): void;
  120013. getTimeStep(): number;
  120014. executeStep(delta: number): void;
  120015. private _removeMarkedPhysicsBodiesFromWorld;
  120016. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120017. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120018. generatePhysicsBody(impostor: PhysicsImpostor): void;
  120019. private _processChildMeshes;
  120020. removePhysicsBody(impostor: PhysicsImpostor): void;
  120021. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  120022. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  120023. private _addMaterial;
  120024. private _checkWithEpsilon;
  120025. private _createShape;
  120026. private _createHeightmap;
  120027. private _minus90X;
  120028. private _plus90X;
  120029. private _tmpPosition;
  120030. private _tmpDeltaPosition;
  120031. private _tmpUnityRotation;
  120032. private _updatePhysicsBodyTransformation;
  120033. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  120034. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  120035. isSupported(): boolean;
  120036. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120037. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120038. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120039. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120040. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120041. getBodyMass(impostor: PhysicsImpostor): number;
  120042. getBodyFriction(impostor: PhysicsImpostor): number;
  120043. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120044. getBodyRestitution(impostor: PhysicsImpostor): number;
  120045. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120046. sleepBody(impostor: PhysicsImpostor): void;
  120047. wakeUpBody(impostor: PhysicsImpostor): void;
  120048. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  120049. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  120050. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  120051. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120052. getRadius(impostor: PhysicsImpostor): number;
  120053. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120054. dispose(): void;
  120055. private _extendNamespace;
  120056. /**
  120057. * Does a raycast in the physics world
  120058. * @param from when should the ray start?
  120059. * @param to when should the ray end?
  120060. * @returns PhysicsRaycastResult
  120061. */
  120062. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120063. }
  120064. }
  120065. declare module BABYLON {
  120066. /** @hidden */
  120067. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  120068. world: any;
  120069. name: string;
  120070. BJSOIMO: any;
  120071. private _raycastResult;
  120072. constructor(iterations?: number, oimoInjection?: any);
  120073. setGravity(gravity: Vector3): void;
  120074. setTimeStep(timeStep: number): void;
  120075. getTimeStep(): number;
  120076. private _tmpImpostorsArray;
  120077. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  120078. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120079. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120080. generatePhysicsBody(impostor: PhysicsImpostor): void;
  120081. private _tmpPositionVector;
  120082. removePhysicsBody(impostor: PhysicsImpostor): void;
  120083. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  120084. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  120085. isSupported(): boolean;
  120086. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  120087. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  120088. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120089. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120090. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120091. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120092. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120093. getBodyMass(impostor: PhysicsImpostor): number;
  120094. getBodyFriction(impostor: PhysicsImpostor): number;
  120095. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120096. getBodyRestitution(impostor: PhysicsImpostor): number;
  120097. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120098. sleepBody(impostor: PhysicsImpostor): void;
  120099. wakeUpBody(impostor: PhysicsImpostor): void;
  120100. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  120101. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  120102. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  120103. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120104. getRadius(impostor: PhysicsImpostor): number;
  120105. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120106. dispose(): void;
  120107. /**
  120108. * Does a raycast in the physics world
  120109. * @param from when should the ray start?
  120110. * @param to when should the ray end?
  120111. * @returns PhysicsRaycastResult
  120112. */
  120113. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120114. }
  120115. }
  120116. declare module BABYLON {
  120117. /**
  120118. * Class containing static functions to help procedurally build meshes
  120119. */
  120120. export class RibbonBuilder {
  120121. /**
  120122. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  120123. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  120124. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  120125. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  120126. * * 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
  120127. * * 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
  120128. * * 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
  120129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120130. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120131. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120132. * * 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
  120133. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  120134. * * 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
  120135. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  120136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120137. * @param name defines the name of the mesh
  120138. * @param options defines the options used to create the mesh
  120139. * @param scene defines the hosting scene
  120140. * @returns the ribbon mesh
  120141. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  120142. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120143. */
  120144. static CreateRibbon(name: string, options: {
  120145. pathArray: Vector3[][];
  120146. closeArray?: boolean;
  120147. closePath?: boolean;
  120148. offset?: number;
  120149. updatable?: boolean;
  120150. sideOrientation?: number;
  120151. frontUVs?: Vector4;
  120152. backUVs?: Vector4;
  120153. instance?: Mesh;
  120154. invertUV?: boolean;
  120155. uvs?: Vector2[];
  120156. colors?: Color4[];
  120157. }, scene?: Nullable<Scene>): Mesh;
  120158. }
  120159. }
  120160. declare module BABYLON {
  120161. /**
  120162. * Class containing static functions to help procedurally build meshes
  120163. */
  120164. export class ShapeBuilder {
  120165. /**
  120166. * 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.
  120167. * * 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.
  120168. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  120169. * * 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.
  120170. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  120171. * * 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
  120172. * * 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
  120173. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  120174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120175. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120176. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  120177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120178. * @param name defines the name of the mesh
  120179. * @param options defines the options used to create the mesh
  120180. * @param scene defines the hosting scene
  120181. * @returns the extruded shape mesh
  120182. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120183. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  120184. */
  120185. static ExtrudeShape(name: string, options: {
  120186. shape: Vector3[];
  120187. path: Vector3[];
  120188. scale?: number;
  120189. rotation?: number;
  120190. cap?: number;
  120191. updatable?: boolean;
  120192. sideOrientation?: number;
  120193. frontUVs?: Vector4;
  120194. backUVs?: Vector4;
  120195. instance?: Mesh;
  120196. invertUV?: boolean;
  120197. }, scene?: Nullable<Scene>): Mesh;
  120198. /**
  120199. * Creates an custom extruded shape mesh.
  120200. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  120201. * * 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.
  120202. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  120203. * * 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
  120204. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  120205. * * 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
  120206. * * It must returns a float value that will be the scale value applied to the shape on each path point
  120207. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  120208. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  120209. * * 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
  120210. * * 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
  120211. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  120212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120213. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120214. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120216. * @param name defines the name of the mesh
  120217. * @param options defines the options used to create the mesh
  120218. * @param scene defines the hosting scene
  120219. * @returns the custom extruded shape mesh
  120220. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  120221. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120222. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  120223. */
  120224. static ExtrudeShapeCustom(name: string, options: {
  120225. shape: Vector3[];
  120226. path: Vector3[];
  120227. scaleFunction?: any;
  120228. rotationFunction?: any;
  120229. ribbonCloseArray?: boolean;
  120230. ribbonClosePath?: boolean;
  120231. cap?: number;
  120232. updatable?: boolean;
  120233. sideOrientation?: number;
  120234. frontUVs?: Vector4;
  120235. backUVs?: Vector4;
  120236. instance?: Mesh;
  120237. invertUV?: boolean;
  120238. }, scene?: Nullable<Scene>): Mesh;
  120239. private static _ExtrudeShapeGeneric;
  120240. }
  120241. }
  120242. declare module BABYLON {
  120243. /**
  120244. * AmmoJS Physics plugin
  120245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  120246. * @see https://github.com/kripken/ammo.js/
  120247. */
  120248. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  120249. private _useDeltaForWorldStep;
  120250. /**
  120251. * Reference to the Ammo library
  120252. */
  120253. bjsAMMO: any;
  120254. /**
  120255. * Created ammoJS world which physics bodies are added to
  120256. */
  120257. world: any;
  120258. /**
  120259. * Name of the plugin
  120260. */
  120261. name: string;
  120262. private _timeStep;
  120263. private _fixedTimeStep;
  120264. private _maxSteps;
  120265. private _tmpQuaternion;
  120266. private _tmpAmmoTransform;
  120267. private _tmpAmmoQuaternion;
  120268. private _tmpAmmoConcreteContactResultCallback;
  120269. private _collisionConfiguration;
  120270. private _dispatcher;
  120271. private _overlappingPairCache;
  120272. private _solver;
  120273. private _softBodySolver;
  120274. private _tmpAmmoVectorA;
  120275. private _tmpAmmoVectorB;
  120276. private _tmpAmmoVectorC;
  120277. private _tmpAmmoVectorD;
  120278. private _tmpContactCallbackResult;
  120279. private _tmpAmmoVectorRCA;
  120280. private _tmpAmmoVectorRCB;
  120281. private _raycastResult;
  120282. private static readonly DISABLE_COLLISION_FLAG;
  120283. private static readonly KINEMATIC_FLAG;
  120284. private static readonly DISABLE_DEACTIVATION_FLAG;
  120285. /**
  120286. * Initializes the ammoJS plugin
  120287. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  120288. * @param ammoInjection can be used to inject your own ammo reference
  120289. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  120290. */
  120291. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  120292. /**
  120293. * Sets the gravity of the physics world (m/(s^2))
  120294. * @param gravity Gravity to set
  120295. */
  120296. setGravity(gravity: Vector3): void;
  120297. /**
  120298. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  120299. * @param timeStep timestep to use in seconds
  120300. */
  120301. setTimeStep(timeStep: number): void;
  120302. /**
  120303. * 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)
  120304. * @param fixedTimeStep fixedTimeStep to use in seconds
  120305. */
  120306. setFixedTimeStep(fixedTimeStep: number): void;
  120307. /**
  120308. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  120309. * @param maxSteps the maximum number of steps by the physics engine per frame
  120310. */
  120311. setMaxSteps(maxSteps: number): void;
  120312. /**
  120313. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  120314. * @returns the current timestep in seconds
  120315. */
  120316. getTimeStep(): number;
  120317. private _isImpostorInContact;
  120318. private _isImpostorPairInContact;
  120319. private _stepSimulation;
  120320. /**
  120321. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  120322. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  120323. * After the step the babylon meshes are set to the position of the physics imposters
  120324. * @param delta amount of time to step forward
  120325. * @param impostors array of imposters to update before/after the step
  120326. */
  120327. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  120328. /**
  120329. * Update babylon mesh to match physics world object
  120330. * @param impostor imposter to match
  120331. */
  120332. private _afterSoftStep;
  120333. /**
  120334. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  120335. * @param impostor imposter to match
  120336. */
  120337. private _ropeStep;
  120338. /**
  120339. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  120340. * @param impostor imposter to match
  120341. */
  120342. private _softbodyOrClothStep;
  120343. private _tmpVector;
  120344. private _tmpMatrix;
  120345. /**
  120346. * Applies an impulse on the imposter
  120347. * @param impostor imposter to apply impulse to
  120348. * @param force amount of force to be applied to the imposter
  120349. * @param contactPoint the location to apply the impulse on the imposter
  120350. */
  120351. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120352. /**
  120353. * Applies a force on the imposter
  120354. * @param impostor imposter to apply force
  120355. * @param force amount of force to be applied to the imposter
  120356. * @param contactPoint the location to apply the force on the imposter
  120357. */
  120358. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120359. /**
  120360. * Creates a physics body using the plugin
  120361. * @param impostor the imposter to create the physics body on
  120362. */
  120363. generatePhysicsBody(impostor: PhysicsImpostor): void;
  120364. /**
  120365. * Removes the physics body from the imposter and disposes of the body's memory
  120366. * @param impostor imposter to remove the physics body from
  120367. */
  120368. removePhysicsBody(impostor: PhysicsImpostor): void;
  120369. /**
  120370. * Generates a joint
  120371. * @param impostorJoint the imposter joint to create the joint with
  120372. */
  120373. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  120374. /**
  120375. * Removes a joint
  120376. * @param impostorJoint the imposter joint to remove the joint from
  120377. */
  120378. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  120379. private _addMeshVerts;
  120380. /**
  120381. * Initialise the soft body vertices to match its object's (mesh) vertices
  120382. * Softbody vertices (nodes) are in world space and to match this
  120383. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  120384. * @param impostor to create the softbody for
  120385. */
  120386. private _softVertexData;
  120387. /**
  120388. * Create an impostor's soft body
  120389. * @param impostor to create the softbody for
  120390. */
  120391. private _createSoftbody;
  120392. /**
  120393. * Create cloth for an impostor
  120394. * @param impostor to create the softbody for
  120395. */
  120396. private _createCloth;
  120397. /**
  120398. * Create rope for an impostor
  120399. * @param impostor to create the softbody for
  120400. */
  120401. private _createRope;
  120402. private _addHullVerts;
  120403. private _createShape;
  120404. /**
  120405. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  120406. * @param impostor imposter containing the physics body and babylon object
  120407. */
  120408. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  120409. /**
  120410. * Sets the babylon object's position/rotation from the physics body's position/rotation
  120411. * @param impostor imposter containing the physics body and babylon object
  120412. * @param newPosition new position
  120413. * @param newRotation new rotation
  120414. */
  120415. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  120416. /**
  120417. * If this plugin is supported
  120418. * @returns true if its supported
  120419. */
  120420. isSupported(): boolean;
  120421. /**
  120422. * Sets the linear velocity of the physics body
  120423. * @param impostor imposter to set the velocity on
  120424. * @param velocity velocity to set
  120425. */
  120426. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120427. /**
  120428. * Sets the angular velocity of the physics body
  120429. * @param impostor imposter to set the velocity on
  120430. * @param velocity velocity to set
  120431. */
  120432. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120433. /**
  120434. * gets the linear velocity
  120435. * @param impostor imposter to get linear velocity from
  120436. * @returns linear velocity
  120437. */
  120438. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120439. /**
  120440. * gets the angular velocity
  120441. * @param impostor imposter to get angular velocity from
  120442. * @returns angular velocity
  120443. */
  120444. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120445. /**
  120446. * Sets the mass of physics body
  120447. * @param impostor imposter to set the mass on
  120448. * @param mass mass to set
  120449. */
  120450. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120451. /**
  120452. * Gets the mass of the physics body
  120453. * @param impostor imposter to get the mass from
  120454. * @returns mass
  120455. */
  120456. getBodyMass(impostor: PhysicsImpostor): number;
  120457. /**
  120458. * Gets friction of the impostor
  120459. * @param impostor impostor to get friction from
  120460. * @returns friction value
  120461. */
  120462. getBodyFriction(impostor: PhysicsImpostor): number;
  120463. /**
  120464. * Sets friction of the impostor
  120465. * @param impostor impostor to set friction on
  120466. * @param friction friction value
  120467. */
  120468. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120469. /**
  120470. * Gets restitution of the impostor
  120471. * @param impostor impostor to get restitution from
  120472. * @returns restitution value
  120473. */
  120474. getBodyRestitution(impostor: PhysicsImpostor): number;
  120475. /**
  120476. * Sets resitution of the impostor
  120477. * @param impostor impostor to set resitution on
  120478. * @param restitution resitution value
  120479. */
  120480. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120481. /**
  120482. * Gets pressure inside the impostor
  120483. * @param impostor impostor to get pressure from
  120484. * @returns pressure value
  120485. */
  120486. getBodyPressure(impostor: PhysicsImpostor): number;
  120487. /**
  120488. * Sets pressure inside a soft body impostor
  120489. * Cloth and rope must remain 0 pressure
  120490. * @param impostor impostor to set pressure on
  120491. * @param pressure pressure value
  120492. */
  120493. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  120494. /**
  120495. * Gets stiffness of the impostor
  120496. * @param impostor impostor to get stiffness from
  120497. * @returns pressure value
  120498. */
  120499. getBodyStiffness(impostor: PhysicsImpostor): number;
  120500. /**
  120501. * Sets stiffness of the impostor
  120502. * @param impostor impostor to set stiffness on
  120503. * @param stiffness stiffness value from 0 to 1
  120504. */
  120505. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  120506. /**
  120507. * Gets velocityIterations of the impostor
  120508. * @param impostor impostor to get velocity iterations from
  120509. * @returns velocityIterations value
  120510. */
  120511. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  120512. /**
  120513. * Sets velocityIterations of the impostor
  120514. * @param impostor impostor to set velocity iterations on
  120515. * @param velocityIterations velocityIterations value
  120516. */
  120517. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  120518. /**
  120519. * Gets positionIterations of the impostor
  120520. * @param impostor impostor to get position iterations from
  120521. * @returns positionIterations value
  120522. */
  120523. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  120524. /**
  120525. * Sets positionIterations of the impostor
  120526. * @param impostor impostor to set position on
  120527. * @param positionIterations positionIterations value
  120528. */
  120529. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  120530. /**
  120531. * Append an anchor to a cloth object
  120532. * @param impostor is the cloth impostor to add anchor to
  120533. * @param otherImpostor is the rigid impostor to anchor to
  120534. * @param width ratio across width from 0 to 1
  120535. * @param height ratio up height from 0 to 1
  120536. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  120537. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120538. */
  120539. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  120540. /**
  120541. * Append an hook to a rope object
  120542. * @param impostor is the rope impostor to add hook to
  120543. * @param otherImpostor is the rigid impostor to hook to
  120544. * @param length ratio along the rope from 0 to 1
  120545. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  120546. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120547. */
  120548. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  120549. /**
  120550. * Sleeps the physics body and stops it from being active
  120551. * @param impostor impostor to sleep
  120552. */
  120553. sleepBody(impostor: PhysicsImpostor): void;
  120554. /**
  120555. * Activates the physics body
  120556. * @param impostor impostor to activate
  120557. */
  120558. wakeUpBody(impostor: PhysicsImpostor): void;
  120559. /**
  120560. * Updates the distance parameters of the joint
  120561. * @param joint joint to update
  120562. * @param maxDistance maximum distance of the joint
  120563. * @param minDistance minimum distance of the joint
  120564. */
  120565. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  120566. /**
  120567. * Sets a motor on the joint
  120568. * @param joint joint to set motor on
  120569. * @param speed speed of the motor
  120570. * @param maxForce maximum force of the motor
  120571. * @param motorIndex index of the motor
  120572. */
  120573. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  120574. /**
  120575. * Sets the motors limit
  120576. * @param joint joint to set limit on
  120577. * @param upperLimit upper limit
  120578. * @param lowerLimit lower limit
  120579. */
  120580. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  120581. /**
  120582. * Syncs the position and rotation of a mesh with the impostor
  120583. * @param mesh mesh to sync
  120584. * @param impostor impostor to update the mesh with
  120585. */
  120586. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120587. /**
  120588. * Gets the radius of the impostor
  120589. * @param impostor impostor to get radius from
  120590. * @returns the radius
  120591. */
  120592. getRadius(impostor: PhysicsImpostor): number;
  120593. /**
  120594. * Gets the box size of the impostor
  120595. * @param impostor impostor to get box size from
  120596. * @param result the resulting box size
  120597. */
  120598. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120599. /**
  120600. * Disposes of the impostor
  120601. */
  120602. dispose(): void;
  120603. /**
  120604. * Does a raycast in the physics world
  120605. * @param from when should the ray start?
  120606. * @param to when should the ray end?
  120607. * @returns PhysicsRaycastResult
  120608. */
  120609. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120610. }
  120611. }
  120612. declare module BABYLON {
  120613. interface AbstractScene {
  120614. /**
  120615. * The list of reflection probes added to the scene
  120616. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120617. */
  120618. reflectionProbes: Array<ReflectionProbe>;
  120619. /**
  120620. * Removes the given reflection probe from this scene.
  120621. * @param toRemove The reflection probe to remove
  120622. * @returns The index of the removed reflection probe
  120623. */
  120624. removeReflectionProbe(toRemove: ReflectionProbe): number;
  120625. /**
  120626. * Adds the given reflection probe to this scene.
  120627. * @param newReflectionProbe The reflection probe to add
  120628. */
  120629. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  120630. }
  120631. /**
  120632. * Class used to generate realtime reflection / refraction cube textures
  120633. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120634. */
  120635. export class ReflectionProbe {
  120636. /** defines the name of the probe */
  120637. name: string;
  120638. private _scene;
  120639. private _renderTargetTexture;
  120640. private _projectionMatrix;
  120641. private _viewMatrix;
  120642. private _target;
  120643. private _add;
  120644. private _attachedMesh;
  120645. private _invertYAxis;
  120646. /** Gets or sets probe position (center of the cube map) */
  120647. position: Vector3;
  120648. /**
  120649. * Creates a new reflection probe
  120650. * @param name defines the name of the probe
  120651. * @param size defines the texture resolution (for each face)
  120652. * @param scene defines the hosting scene
  120653. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  120654. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  120655. */
  120656. constructor(
  120657. /** defines the name of the probe */
  120658. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  120659. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  120660. samples: number;
  120661. /** Gets or sets the refresh rate to use (on every frame by default) */
  120662. refreshRate: number;
  120663. /**
  120664. * Gets the hosting scene
  120665. * @returns a Scene
  120666. */
  120667. getScene(): Scene;
  120668. /** Gets the internal CubeTexture used to render to */
  120669. readonly cubeTexture: RenderTargetTexture;
  120670. /** Gets the list of meshes to render */
  120671. readonly renderList: Nullable<AbstractMesh[]>;
  120672. /**
  120673. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  120674. * @param mesh defines the mesh to attach to
  120675. */
  120676. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  120677. /**
  120678. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  120679. * @param renderingGroupId The rendering group id corresponding to its index
  120680. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120681. */
  120682. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  120683. /**
  120684. * Clean all associated resources
  120685. */
  120686. dispose(): void;
  120687. /**
  120688. * Converts the reflection probe information to a readable string for debug purpose.
  120689. * @param fullDetails Supports for multiple levels of logging within scene loading
  120690. * @returns the human readable reflection probe info
  120691. */
  120692. toString(fullDetails?: boolean): string;
  120693. /**
  120694. * Get the class name of the relfection probe.
  120695. * @returns "ReflectionProbe"
  120696. */
  120697. getClassName(): string;
  120698. /**
  120699. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  120700. * @returns The JSON representation of the texture
  120701. */
  120702. serialize(): any;
  120703. /**
  120704. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  120705. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  120706. * @param scene Define the scene the parsed reflection probe should be instantiated in
  120707. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  120708. * @returns The parsed reflection probe if successful
  120709. */
  120710. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  120711. }
  120712. }
  120713. declare module BABYLON {
  120714. /** @hidden */
  120715. export var _BabylonLoaderRegistered: boolean;
  120716. /**
  120717. * Helps setting up some configuration for the babylon file loader.
  120718. */
  120719. export class BabylonFileLoaderConfiguration {
  120720. /**
  120721. * The loader does not allow injecting custom physix engine into the plugins.
  120722. * Unfortunately in ES6, we need to manually inject them into the plugin.
  120723. * So you could set this variable to your engine import to make it work.
  120724. */
  120725. static LoaderInjectedPhysicsEngine: any;
  120726. }
  120727. }
  120728. declare module BABYLON {
  120729. /**
  120730. * The Physically based simple base material of BJS.
  120731. *
  120732. * This enables better naming and convention enforcements on top of the pbrMaterial.
  120733. * It is used as the base class for both the specGloss and metalRough conventions.
  120734. */
  120735. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  120736. /**
  120737. * Number of Simultaneous lights allowed on the material.
  120738. */
  120739. maxSimultaneousLights: number;
  120740. /**
  120741. * If sets to true, disables all the lights affecting the material.
  120742. */
  120743. disableLighting: boolean;
  120744. /**
  120745. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  120746. */
  120747. environmentTexture: BaseTexture;
  120748. /**
  120749. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  120750. */
  120751. invertNormalMapX: boolean;
  120752. /**
  120753. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  120754. */
  120755. invertNormalMapY: boolean;
  120756. /**
  120757. * Normal map used in the model.
  120758. */
  120759. normalTexture: BaseTexture;
  120760. /**
  120761. * Emissivie color used to self-illuminate the model.
  120762. */
  120763. emissiveColor: Color3;
  120764. /**
  120765. * Emissivie texture used to self-illuminate the model.
  120766. */
  120767. emissiveTexture: BaseTexture;
  120768. /**
  120769. * Occlusion Channel Strenght.
  120770. */
  120771. occlusionStrength: number;
  120772. /**
  120773. * Occlusion Texture of the material (adding extra occlusion effects).
  120774. */
  120775. occlusionTexture: BaseTexture;
  120776. /**
  120777. * Defines the alpha limits in alpha test mode.
  120778. */
  120779. alphaCutOff: number;
  120780. /**
  120781. * Gets the current double sided mode.
  120782. */
  120783. /**
  120784. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  120785. */
  120786. doubleSided: boolean;
  120787. /**
  120788. * Stores the pre-calculated light information of a mesh in a texture.
  120789. */
  120790. lightmapTexture: BaseTexture;
  120791. /**
  120792. * If true, the light map contains occlusion information instead of lighting info.
  120793. */
  120794. useLightmapAsShadowmap: boolean;
  120795. /**
  120796. * Instantiates a new PBRMaterial instance.
  120797. *
  120798. * @param name The material name
  120799. * @param scene The scene the material will be use in.
  120800. */
  120801. constructor(name: string, scene: Scene);
  120802. getClassName(): string;
  120803. }
  120804. }
  120805. declare module BABYLON {
  120806. /**
  120807. * The PBR material of BJS following the metal roughness convention.
  120808. *
  120809. * This fits to the PBR convention in the GLTF definition:
  120810. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  120811. */
  120812. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  120813. /**
  120814. * The base color has two different interpretations depending on the value of metalness.
  120815. * When the material is a metal, the base color is the specific measured reflectance value
  120816. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  120817. * of the material.
  120818. */
  120819. baseColor: Color3;
  120820. /**
  120821. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  120822. * well as opacity information in the alpha channel.
  120823. */
  120824. baseTexture: BaseTexture;
  120825. /**
  120826. * Specifies the metallic scalar value of the material.
  120827. * Can also be used to scale the metalness values of the metallic texture.
  120828. */
  120829. metallic: number;
  120830. /**
  120831. * Specifies the roughness scalar value of the material.
  120832. * Can also be used to scale the roughness values of the metallic texture.
  120833. */
  120834. roughness: number;
  120835. /**
  120836. * Texture containing both the metallic value in the B channel and the
  120837. * roughness value in the G channel to keep better precision.
  120838. */
  120839. metallicRoughnessTexture: BaseTexture;
  120840. /**
  120841. * Instantiates a new PBRMetalRoughnessMaterial instance.
  120842. *
  120843. * @param name The material name
  120844. * @param scene The scene the material will be use in.
  120845. */
  120846. constructor(name: string, scene: Scene);
  120847. /**
  120848. * Return the currrent class name of the material.
  120849. */
  120850. getClassName(): string;
  120851. /**
  120852. * Makes a duplicate of the current material.
  120853. * @param name - name to use for the new material.
  120854. */
  120855. clone(name: string): PBRMetallicRoughnessMaterial;
  120856. /**
  120857. * Serialize the material to a parsable JSON object.
  120858. */
  120859. serialize(): any;
  120860. /**
  120861. * Parses a JSON object correponding to the serialize function.
  120862. */
  120863. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  120864. }
  120865. }
  120866. declare module BABYLON {
  120867. /**
  120868. * The PBR material of BJS following the specular glossiness convention.
  120869. *
  120870. * This fits to the PBR convention in the GLTF definition:
  120871. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  120872. */
  120873. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  120874. /**
  120875. * Specifies the diffuse color of the material.
  120876. */
  120877. diffuseColor: Color3;
  120878. /**
  120879. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  120880. * channel.
  120881. */
  120882. diffuseTexture: BaseTexture;
  120883. /**
  120884. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  120885. */
  120886. specularColor: Color3;
  120887. /**
  120888. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  120889. */
  120890. glossiness: number;
  120891. /**
  120892. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  120893. */
  120894. specularGlossinessTexture: BaseTexture;
  120895. /**
  120896. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  120897. *
  120898. * @param name The material name
  120899. * @param scene The scene the material will be use in.
  120900. */
  120901. constructor(name: string, scene: Scene);
  120902. /**
  120903. * Return the currrent class name of the material.
  120904. */
  120905. getClassName(): string;
  120906. /**
  120907. * Makes a duplicate of the current material.
  120908. * @param name - name to use for the new material.
  120909. */
  120910. clone(name: string): PBRSpecularGlossinessMaterial;
  120911. /**
  120912. * Serialize the material to a parsable JSON object.
  120913. */
  120914. serialize(): any;
  120915. /**
  120916. * Parses a JSON object correponding to the serialize function.
  120917. */
  120918. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  120919. }
  120920. }
  120921. declare module BABYLON {
  120922. /**
  120923. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  120924. * It can help converting any input color in a desired output one. This can then be used to create effects
  120925. * from sepia, black and white to sixties or futuristic rendering...
  120926. *
  120927. * The only supported format is currently 3dl.
  120928. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  120929. */
  120930. export class ColorGradingTexture extends BaseTexture {
  120931. /**
  120932. * The current texture matrix. (will always be identity in color grading texture)
  120933. */
  120934. private _textureMatrix;
  120935. /**
  120936. * The texture URL.
  120937. */
  120938. url: string;
  120939. /**
  120940. * Empty line regex stored for GC.
  120941. */
  120942. private static _noneEmptyLineRegex;
  120943. private _engine;
  120944. /**
  120945. * Instantiates a ColorGradingTexture from the following parameters.
  120946. *
  120947. * @param url The location of the color gradind data (currently only supporting 3dl)
  120948. * @param scene The scene the texture will be used in
  120949. */
  120950. constructor(url: string, scene: Scene);
  120951. /**
  120952. * Returns the texture matrix used in most of the material.
  120953. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  120954. */
  120955. getTextureMatrix(): Matrix;
  120956. /**
  120957. * Occurs when the file being loaded is a .3dl LUT file.
  120958. */
  120959. private load3dlTexture;
  120960. /**
  120961. * Starts the loading process of the texture.
  120962. */
  120963. private loadTexture;
  120964. /**
  120965. * Clones the color gradind texture.
  120966. */
  120967. clone(): ColorGradingTexture;
  120968. /**
  120969. * Called during delayed load for textures.
  120970. */
  120971. delayLoad(): void;
  120972. /**
  120973. * Parses a color grading texture serialized by Babylon.
  120974. * @param parsedTexture The texture information being parsedTexture
  120975. * @param scene The scene to load the texture in
  120976. * @param rootUrl The root url of the data assets to load
  120977. * @return A color gradind texture
  120978. */
  120979. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  120980. /**
  120981. * Serializes the LUT texture to json format.
  120982. */
  120983. serialize(): any;
  120984. }
  120985. }
  120986. declare module BABYLON {
  120987. /**
  120988. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  120989. */
  120990. export class EquiRectangularCubeTexture extends BaseTexture {
  120991. /** The six faces of the cube. */
  120992. private static _FacesMapping;
  120993. private _noMipmap;
  120994. private _onLoad;
  120995. private _onError;
  120996. /** The size of the cubemap. */
  120997. private _size;
  120998. /** The buffer of the image. */
  120999. private _buffer;
  121000. /** The width of the input image. */
  121001. private _width;
  121002. /** The height of the input image. */
  121003. private _height;
  121004. /** The URL to the image. */
  121005. url: string;
  121006. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  121007. coordinatesMode: number;
  121008. /**
  121009. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  121010. * @param url The location of the image
  121011. * @param scene The scene the texture will be used in
  121012. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  121013. * @param noMipmap Forces to not generate the mipmap if true
  121014. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  121015. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  121016. * @param onLoad — defines a callback called when texture is loaded
  121017. * @param onError — defines a callback called if there is an error
  121018. */
  121019. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  121020. /**
  121021. * Load the image data, by putting the image on a canvas and extracting its buffer.
  121022. */
  121023. private loadImage;
  121024. /**
  121025. * Convert the image buffer into a cubemap and create a CubeTexture.
  121026. */
  121027. private loadTexture;
  121028. /**
  121029. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  121030. * @param buffer The ArrayBuffer that should be converted.
  121031. * @returns The buffer as Float32Array.
  121032. */
  121033. private getFloat32ArrayFromArrayBuffer;
  121034. /**
  121035. * Get the current class name of the texture useful for serialization or dynamic coding.
  121036. * @returns "EquiRectangularCubeTexture"
  121037. */
  121038. getClassName(): string;
  121039. /**
  121040. * Create a clone of the current EquiRectangularCubeTexture and return it.
  121041. * @returns A clone of the current EquiRectangularCubeTexture.
  121042. */
  121043. clone(): EquiRectangularCubeTexture;
  121044. }
  121045. }
  121046. declare module BABYLON {
  121047. /**
  121048. * Based on jsTGALoader - Javascript loader for TGA file
  121049. * By Vincent Thibault
  121050. * @see http://blog.robrowser.com/javascript-tga-loader.html
  121051. */
  121052. export class TGATools {
  121053. private static _TYPE_INDEXED;
  121054. private static _TYPE_RGB;
  121055. private static _TYPE_GREY;
  121056. private static _TYPE_RLE_INDEXED;
  121057. private static _TYPE_RLE_RGB;
  121058. private static _TYPE_RLE_GREY;
  121059. private static _ORIGIN_MASK;
  121060. private static _ORIGIN_SHIFT;
  121061. private static _ORIGIN_BL;
  121062. private static _ORIGIN_BR;
  121063. private static _ORIGIN_UL;
  121064. private static _ORIGIN_UR;
  121065. /**
  121066. * Gets the header of a TGA file
  121067. * @param data defines the TGA data
  121068. * @returns the header
  121069. */
  121070. static GetTGAHeader(data: Uint8Array): any;
  121071. /**
  121072. * Uploads TGA content to a Babylon Texture
  121073. * @hidden
  121074. */
  121075. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  121076. /** @hidden */
  121077. 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;
  121078. /** @hidden */
  121079. 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;
  121080. /** @hidden */
  121081. 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;
  121082. /** @hidden */
  121083. 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;
  121084. /** @hidden */
  121085. 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;
  121086. /** @hidden */
  121087. 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;
  121088. }
  121089. }
  121090. declare module BABYLON {
  121091. /**
  121092. * Implementation of the TGA Texture Loader.
  121093. * @hidden
  121094. */
  121095. export class _TGATextureLoader implements IInternalTextureLoader {
  121096. /**
  121097. * Defines wether the loader supports cascade loading the different faces.
  121098. */
  121099. readonly supportCascades: boolean;
  121100. /**
  121101. * This returns if the loader support the current file information.
  121102. * @param extension defines the file extension of the file being loaded
  121103. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121104. * @param fallback defines the fallback internal texture if any
  121105. * @param isBase64 defines whether the texture is encoded as a base64
  121106. * @param isBuffer defines whether the texture data are stored as a buffer
  121107. * @returns true if the loader can load the specified file
  121108. */
  121109. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121110. /**
  121111. * Transform the url before loading if required.
  121112. * @param rootUrl the url of the texture
  121113. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121114. * @returns the transformed texture
  121115. */
  121116. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121117. /**
  121118. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121119. * @param rootUrl the url of the texture
  121120. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121121. * @returns the fallback texture
  121122. */
  121123. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121124. /**
  121125. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121126. * @param data contains the texture data
  121127. * @param texture defines the BabylonJS internal texture
  121128. * @param createPolynomials will be true if polynomials have been requested
  121129. * @param onLoad defines the callback to trigger once the texture is ready
  121130. * @param onError defines the callback to trigger in case of error
  121131. */
  121132. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121133. /**
  121134. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121135. * @param data contains the texture data
  121136. * @param texture defines the BabylonJS internal texture
  121137. * @param callback defines the method to call once ready to upload
  121138. */
  121139. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121140. }
  121141. }
  121142. declare module BABYLON {
  121143. /**
  121144. * Info about the .basis files
  121145. */
  121146. class BasisFileInfo {
  121147. /**
  121148. * If the file has alpha
  121149. */
  121150. hasAlpha: boolean;
  121151. /**
  121152. * Info about each image of the basis file
  121153. */
  121154. images: Array<{
  121155. levels: Array<{
  121156. width: number;
  121157. height: number;
  121158. transcodedPixels: ArrayBufferView;
  121159. }>;
  121160. }>;
  121161. }
  121162. /**
  121163. * Result of transcoding a basis file
  121164. */
  121165. class TranscodeResult {
  121166. /**
  121167. * Info about the .basis file
  121168. */
  121169. fileInfo: BasisFileInfo;
  121170. /**
  121171. * Format to use when loading the file
  121172. */
  121173. format: number;
  121174. }
  121175. /**
  121176. * Configuration options for the Basis transcoder
  121177. */
  121178. export class BasisTranscodeConfiguration {
  121179. /**
  121180. * Supported compression formats used to determine the supported output format of the transcoder
  121181. */
  121182. supportedCompressionFormats?: {
  121183. /**
  121184. * etc1 compression format
  121185. */
  121186. etc1?: boolean;
  121187. /**
  121188. * s3tc compression format
  121189. */
  121190. s3tc?: boolean;
  121191. /**
  121192. * pvrtc compression format
  121193. */
  121194. pvrtc?: boolean;
  121195. /**
  121196. * etc2 compression format
  121197. */
  121198. etc2?: boolean;
  121199. };
  121200. /**
  121201. * If mipmap levels should be loaded for transcoded images (Default: true)
  121202. */
  121203. loadMipmapLevels?: boolean;
  121204. /**
  121205. * Index of a single image to load (Default: all images)
  121206. */
  121207. loadSingleImage?: number;
  121208. }
  121209. /**
  121210. * Used to load .Basis files
  121211. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  121212. */
  121213. export class BasisTools {
  121214. private static _IgnoreSupportedFormats;
  121215. /**
  121216. * URL to use when loading the basis transcoder
  121217. */
  121218. static JSModuleURL: string;
  121219. /**
  121220. * URL to use when loading the wasm module for the transcoder
  121221. */
  121222. static WasmModuleURL: string;
  121223. /**
  121224. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  121225. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  121226. * @returns internal format corresponding to the Basis format
  121227. */
  121228. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  121229. private static _WorkerPromise;
  121230. private static _Worker;
  121231. private static _actionId;
  121232. private static _CreateWorkerAsync;
  121233. /**
  121234. * Transcodes a loaded image file to compressed pixel data
  121235. * @param imageData image data to transcode
  121236. * @param config configuration options for the transcoding
  121237. * @returns a promise resulting in the transcoded image
  121238. */
  121239. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  121240. /**
  121241. * Loads a texture from the transcode result
  121242. * @param texture texture load to
  121243. * @param transcodeResult the result of transcoding the basis file to load from
  121244. */
  121245. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  121246. }
  121247. }
  121248. declare module BABYLON {
  121249. /**
  121250. * Loader for .basis file format
  121251. */
  121252. export class _BasisTextureLoader implements IInternalTextureLoader {
  121253. /**
  121254. * Defines whether the loader supports cascade loading the different faces.
  121255. */
  121256. readonly supportCascades: boolean;
  121257. /**
  121258. * This returns if the loader support the current file information.
  121259. * @param extension defines the file extension of the file being loaded
  121260. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121261. * @param fallback defines the fallback internal texture if any
  121262. * @param isBase64 defines whether the texture is encoded as a base64
  121263. * @param isBuffer defines whether the texture data are stored as a buffer
  121264. * @returns true if the loader can load the specified file
  121265. */
  121266. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121267. /**
  121268. * Transform the url before loading if required.
  121269. * @param rootUrl the url of the texture
  121270. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121271. * @returns the transformed texture
  121272. */
  121273. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121274. /**
  121275. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121276. * @param rootUrl the url of the texture
  121277. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121278. * @returns the fallback texture
  121279. */
  121280. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121281. /**
  121282. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  121283. * @param data contains the texture data
  121284. * @param texture defines the BabylonJS internal texture
  121285. * @param createPolynomials will be true if polynomials have been requested
  121286. * @param onLoad defines the callback to trigger once the texture is ready
  121287. * @param onError defines the callback to trigger in case of error
  121288. */
  121289. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121290. /**
  121291. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121292. * @param data contains the texture data
  121293. * @param texture defines the BabylonJS internal texture
  121294. * @param callback defines the method to call once ready to upload
  121295. */
  121296. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121297. }
  121298. }
  121299. declare module BABYLON {
  121300. /**
  121301. * 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.
  121302. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  121303. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  121304. */
  121305. export class CustomProceduralTexture extends ProceduralTexture {
  121306. private _animate;
  121307. private _time;
  121308. private _config;
  121309. private _texturePath;
  121310. /**
  121311. * Instantiates a new Custom Procedural Texture.
  121312. * 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.
  121313. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  121314. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  121315. * @param name Define the name of the texture
  121316. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  121317. * @param size Define the size of the texture to create
  121318. * @param scene Define the scene the texture belongs to
  121319. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  121320. * @param generateMipMaps Define if the texture should creates mip maps or not
  121321. */
  121322. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  121323. private _loadJson;
  121324. /**
  121325. * Is the texture ready to be used ? (rendered at least once)
  121326. * @returns true if ready, otherwise, false.
  121327. */
  121328. isReady(): boolean;
  121329. /**
  121330. * Render the texture to its associated render target.
  121331. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  121332. */
  121333. render(useCameraPostProcess?: boolean): void;
  121334. /**
  121335. * Update the list of dependant textures samplers in the shader.
  121336. */
  121337. updateTextures(): void;
  121338. /**
  121339. * Update the uniform values of the procedural texture in the shader.
  121340. */
  121341. updateShaderUniforms(): void;
  121342. /**
  121343. * Define if the texture animates or not.
  121344. */
  121345. animate: boolean;
  121346. }
  121347. }
  121348. declare module BABYLON {
  121349. /** @hidden */
  121350. export var noisePixelShader: {
  121351. name: string;
  121352. shader: string;
  121353. };
  121354. }
  121355. declare module BABYLON {
  121356. /**
  121357. * Class used to generate noise procedural textures
  121358. */
  121359. export class NoiseProceduralTexture extends ProceduralTexture {
  121360. private _time;
  121361. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  121362. brightness: number;
  121363. /** Defines the number of octaves to process */
  121364. octaves: number;
  121365. /** Defines the level of persistence (0.8 by default) */
  121366. persistence: number;
  121367. /** Gets or sets animation speed factor (default is 1) */
  121368. animationSpeedFactor: number;
  121369. /**
  121370. * Creates a new NoiseProceduralTexture
  121371. * @param name defines the name fo the texture
  121372. * @param size defines the size of the texture (default is 256)
  121373. * @param scene defines the hosting scene
  121374. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  121375. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  121376. */
  121377. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  121378. private _updateShaderUniforms;
  121379. protected _getDefines(): string;
  121380. /** Generate the current state of the procedural texture */
  121381. render(useCameraPostProcess?: boolean): void;
  121382. /**
  121383. * Serializes this noise procedural texture
  121384. * @returns a serialized noise procedural texture object
  121385. */
  121386. serialize(): any;
  121387. /**
  121388. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  121389. * @param parsedTexture defines parsed texture data
  121390. * @param scene defines the current scene
  121391. * @param rootUrl defines the root URL containing noise procedural texture information
  121392. * @returns a parsed NoiseProceduralTexture
  121393. */
  121394. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  121395. }
  121396. }
  121397. declare module BABYLON {
  121398. /**
  121399. * Raw cube texture where the raw buffers are passed in
  121400. */
  121401. export class RawCubeTexture extends CubeTexture {
  121402. /**
  121403. * Creates a cube texture where the raw buffers are passed in.
  121404. * @param scene defines the scene the texture is attached to
  121405. * @param data defines the array of data to use to create each face
  121406. * @param size defines the size of the textures
  121407. * @param format defines the format of the data
  121408. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  121409. * @param generateMipMaps defines if the engine should generate the mip levels
  121410. * @param invertY defines if data must be stored with Y axis inverted
  121411. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  121412. * @param compression defines the compression used (null by default)
  121413. */
  121414. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  121415. /**
  121416. * Updates the raw cube texture.
  121417. * @param data defines the data to store
  121418. * @param format defines the data format
  121419. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  121420. * @param invertY defines if data must be stored with Y axis inverted
  121421. * @param compression defines the compression used (null by default)
  121422. * @param level defines which level of the texture to update
  121423. */
  121424. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  121425. /**
  121426. * Updates a raw cube texture with RGBD encoded data.
  121427. * @param data defines the array of data [mipmap][face] to use to create each face
  121428. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  121429. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  121430. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  121431. * @returns a promsie that resolves when the operation is complete
  121432. */
  121433. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  121434. /**
  121435. * Clones the raw cube texture.
  121436. * @return a new cube texture
  121437. */
  121438. clone(): CubeTexture;
  121439. /** @hidden */
  121440. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  121441. }
  121442. }
  121443. declare module BABYLON {
  121444. /**
  121445. * Class used to store 3D textures containing user data
  121446. */
  121447. export class RawTexture3D extends Texture {
  121448. /** Gets or sets the texture format to use */
  121449. format: number;
  121450. private _engine;
  121451. /**
  121452. * Create a new RawTexture3D
  121453. * @param data defines the data of the texture
  121454. * @param width defines the width of the texture
  121455. * @param height defines the height of the texture
  121456. * @param depth defines the depth of the texture
  121457. * @param format defines the texture format to use
  121458. * @param scene defines the hosting scene
  121459. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121460. * @param invertY defines if texture must be stored with Y axis inverted
  121461. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121462. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121463. */
  121464. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121465. /** Gets or sets the texture format to use */
  121466. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121467. /**
  121468. * Update the texture with new data
  121469. * @param data defines the data to store in the texture
  121470. */
  121471. update(data: ArrayBufferView): void;
  121472. }
  121473. }
  121474. declare module BABYLON {
  121475. /**
  121476. * Class used to store 2D array textures containing user data
  121477. */
  121478. export class RawTexture2DArray extends Texture {
  121479. /** Gets or sets the texture format to use */
  121480. format: number;
  121481. private _engine;
  121482. /**
  121483. * Create a new RawTexture2DArray
  121484. * @param data defines the data of the texture
  121485. * @param width defines the width of the texture
  121486. * @param height defines the height of the texture
  121487. * @param depth defines the number of layers of the texture
  121488. * @param format defines the texture format to use
  121489. * @param scene defines the hosting scene
  121490. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121491. * @param invertY defines if texture must be stored with Y axis inverted
  121492. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121493. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121494. */
  121495. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121496. /** Gets or sets the texture format to use */
  121497. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121498. /**
  121499. * Update the texture with new data
  121500. * @param data defines the data to store in the texture
  121501. */
  121502. update(data: ArrayBufferView): void;
  121503. }
  121504. }
  121505. declare module BABYLON {
  121506. /**
  121507. * Creates a refraction texture used by refraction channel of the standard material.
  121508. * It is like a mirror but to see through a material.
  121509. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121510. */
  121511. export class RefractionTexture extends RenderTargetTexture {
  121512. /**
  121513. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  121514. * 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.
  121515. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121516. */
  121517. refractionPlane: Plane;
  121518. /**
  121519. * Define how deep under the surface we should see.
  121520. */
  121521. depth: number;
  121522. /**
  121523. * Creates a refraction texture used by refraction channel of the standard material.
  121524. * It is like a mirror but to see through a material.
  121525. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121526. * @param name Define the texture name
  121527. * @param size Define the size of the underlying texture
  121528. * @param scene Define the scene the refraction belongs to
  121529. * @param generateMipMaps Define if we need to generate mips level for the refraction
  121530. */
  121531. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  121532. /**
  121533. * Clone the refraction texture.
  121534. * @returns the cloned texture
  121535. */
  121536. clone(): RefractionTexture;
  121537. /**
  121538. * Serialize the texture to a JSON representation you could use in Parse later on
  121539. * @returns the serialized JSON representation
  121540. */
  121541. serialize(): any;
  121542. }
  121543. }
  121544. declare module BABYLON {
  121545. /**
  121546. * Defines the options related to the creation of an HtmlElementTexture
  121547. */
  121548. export interface IHtmlElementTextureOptions {
  121549. /**
  121550. * Defines wether mip maps should be created or not.
  121551. */
  121552. generateMipMaps?: boolean;
  121553. /**
  121554. * Defines the sampling mode of the texture.
  121555. */
  121556. samplingMode?: number;
  121557. /**
  121558. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  121559. */
  121560. engine: Nullable<ThinEngine>;
  121561. /**
  121562. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  121563. */
  121564. scene: Nullable<Scene>;
  121565. }
  121566. /**
  121567. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  121568. * To be as efficient as possible depending on your constraints nothing aside the first upload
  121569. * is automatically managed.
  121570. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  121571. * in your application.
  121572. *
  121573. * As the update is not automatic, you need to call them manually.
  121574. */
  121575. export class HtmlElementTexture extends BaseTexture {
  121576. /**
  121577. * The texture URL.
  121578. */
  121579. element: HTMLVideoElement | HTMLCanvasElement;
  121580. private static readonly DefaultOptions;
  121581. private _textureMatrix;
  121582. private _engine;
  121583. private _isVideo;
  121584. private _generateMipMaps;
  121585. private _samplingMode;
  121586. /**
  121587. * Instantiates a HtmlElementTexture from the following parameters.
  121588. *
  121589. * @param name Defines the name of the texture
  121590. * @param element Defines the video or canvas the texture is filled with
  121591. * @param options Defines the other none mandatory texture creation options
  121592. */
  121593. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  121594. private _createInternalTexture;
  121595. /**
  121596. * Returns the texture matrix used in most of the material.
  121597. */
  121598. getTextureMatrix(): Matrix;
  121599. /**
  121600. * Updates the content of the texture.
  121601. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  121602. */
  121603. update(invertY?: Nullable<boolean>): void;
  121604. }
  121605. }
  121606. declare module BABYLON {
  121607. /**
  121608. * Enum used to define the target of a block
  121609. */
  121610. export enum NodeMaterialBlockTargets {
  121611. /** Vertex shader */
  121612. Vertex = 1,
  121613. /** Fragment shader */
  121614. Fragment = 2,
  121615. /** Neutral */
  121616. Neutral = 4,
  121617. /** Vertex and Fragment */
  121618. VertexAndFragment = 3
  121619. }
  121620. }
  121621. declare module BABYLON {
  121622. /**
  121623. * Defines the kind of connection point for node based material
  121624. */
  121625. export enum NodeMaterialBlockConnectionPointTypes {
  121626. /** Float */
  121627. Float = 1,
  121628. /** Int */
  121629. Int = 2,
  121630. /** Vector2 */
  121631. Vector2 = 4,
  121632. /** Vector3 */
  121633. Vector3 = 8,
  121634. /** Vector4 */
  121635. Vector4 = 16,
  121636. /** Color3 */
  121637. Color3 = 32,
  121638. /** Color4 */
  121639. Color4 = 64,
  121640. /** Matrix */
  121641. Matrix = 128,
  121642. /** Detect type based on connection */
  121643. AutoDetect = 1024,
  121644. /** Output type that will be defined by input type */
  121645. BasedOnInput = 2048
  121646. }
  121647. }
  121648. declare module BABYLON {
  121649. /**
  121650. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  121651. */
  121652. export enum NodeMaterialBlockConnectionPointMode {
  121653. /** Value is an uniform */
  121654. Uniform = 0,
  121655. /** Value is a mesh attribute */
  121656. Attribute = 1,
  121657. /** Value is a varying between vertex and fragment shaders */
  121658. Varying = 2,
  121659. /** Mode is undefined */
  121660. Undefined = 3
  121661. }
  121662. }
  121663. declare module BABYLON {
  121664. /**
  121665. * Enum used to define system values e.g. values automatically provided by the system
  121666. */
  121667. export enum NodeMaterialSystemValues {
  121668. /** World */
  121669. World = 1,
  121670. /** View */
  121671. View = 2,
  121672. /** Projection */
  121673. Projection = 3,
  121674. /** ViewProjection */
  121675. ViewProjection = 4,
  121676. /** WorldView */
  121677. WorldView = 5,
  121678. /** WorldViewProjection */
  121679. WorldViewProjection = 6,
  121680. /** CameraPosition */
  121681. CameraPosition = 7,
  121682. /** Fog Color */
  121683. FogColor = 8,
  121684. /** Delta time */
  121685. DeltaTime = 9
  121686. }
  121687. }
  121688. declare module BABYLON {
  121689. /**
  121690. * Root class for all node material optimizers
  121691. */
  121692. export class NodeMaterialOptimizer {
  121693. /**
  121694. * Function used to optimize a NodeMaterial graph
  121695. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  121696. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  121697. */
  121698. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  121699. }
  121700. }
  121701. declare module BABYLON {
  121702. /**
  121703. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  121704. */
  121705. export class TransformBlock extends NodeMaterialBlock {
  121706. /**
  121707. * Defines the value to use to complement W value to transform it to a Vector4
  121708. */
  121709. complementW: number;
  121710. /**
  121711. * Defines the value to use to complement z value to transform it to a Vector4
  121712. */
  121713. complementZ: number;
  121714. /**
  121715. * Creates a new TransformBlock
  121716. * @param name defines the block name
  121717. */
  121718. constructor(name: string);
  121719. /**
  121720. * Gets the current class name
  121721. * @returns the class name
  121722. */
  121723. getClassName(): string;
  121724. /**
  121725. * Gets the vector input
  121726. */
  121727. readonly vector: NodeMaterialConnectionPoint;
  121728. /**
  121729. * Gets the output component
  121730. */
  121731. readonly output: NodeMaterialConnectionPoint;
  121732. /**
  121733. * Gets the matrix transform input
  121734. */
  121735. readonly transform: NodeMaterialConnectionPoint;
  121736. protected _buildBlock(state: NodeMaterialBuildState): this;
  121737. serialize(): any;
  121738. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121739. protected _dumpPropertiesCode(): string;
  121740. }
  121741. }
  121742. declare module BABYLON {
  121743. /**
  121744. * Block used to output the vertex position
  121745. */
  121746. export class VertexOutputBlock extends NodeMaterialBlock {
  121747. /**
  121748. * Creates a new VertexOutputBlock
  121749. * @param name defines the block name
  121750. */
  121751. constructor(name: string);
  121752. /**
  121753. * Gets the current class name
  121754. * @returns the class name
  121755. */
  121756. getClassName(): string;
  121757. /**
  121758. * Gets the vector input component
  121759. */
  121760. readonly vector: NodeMaterialConnectionPoint;
  121761. protected _buildBlock(state: NodeMaterialBuildState): this;
  121762. }
  121763. }
  121764. declare module BABYLON {
  121765. /**
  121766. * Block used to output the final color
  121767. */
  121768. export class FragmentOutputBlock extends NodeMaterialBlock {
  121769. /**
  121770. * Create a new FragmentOutputBlock
  121771. * @param name defines the block name
  121772. */
  121773. constructor(name: string);
  121774. /**
  121775. * Gets the current class name
  121776. * @returns the class name
  121777. */
  121778. getClassName(): string;
  121779. /**
  121780. * Gets the rgba input component
  121781. */
  121782. readonly rgba: NodeMaterialConnectionPoint;
  121783. /**
  121784. * Gets the rgb input component
  121785. */
  121786. readonly rgb: NodeMaterialConnectionPoint;
  121787. /**
  121788. * Gets the a input component
  121789. */
  121790. readonly a: NodeMaterialConnectionPoint;
  121791. protected _buildBlock(state: NodeMaterialBuildState): this;
  121792. }
  121793. }
  121794. declare module BABYLON {
  121795. /**
  121796. * Block used to read a reflection texture from a sampler
  121797. */
  121798. export class ReflectionTextureBlock extends NodeMaterialBlock {
  121799. private _define3DName;
  121800. private _defineCubicName;
  121801. private _defineExplicitName;
  121802. private _defineProjectionName;
  121803. private _defineLocalCubicName;
  121804. private _defineSphericalName;
  121805. private _definePlanarName;
  121806. private _defineEquirectangularName;
  121807. private _defineMirroredEquirectangularFixedName;
  121808. private _defineEquirectangularFixedName;
  121809. private _defineSkyboxName;
  121810. private _cubeSamplerName;
  121811. private _2DSamplerName;
  121812. private _positionUVWName;
  121813. private _directionWName;
  121814. private _reflectionCoordsName;
  121815. private _reflection2DCoordsName;
  121816. private _reflectionColorName;
  121817. private _reflectionMatrixName;
  121818. /**
  121819. * Gets or sets the texture associated with the node
  121820. */
  121821. texture: Nullable<BaseTexture>;
  121822. /**
  121823. * Create a new TextureBlock
  121824. * @param name defines the block name
  121825. */
  121826. constructor(name: string);
  121827. /**
  121828. * Gets the current class name
  121829. * @returns the class name
  121830. */
  121831. getClassName(): string;
  121832. /**
  121833. * Gets the world position input component
  121834. */
  121835. readonly position: NodeMaterialConnectionPoint;
  121836. /**
  121837. * Gets the world position input component
  121838. */
  121839. readonly worldPosition: NodeMaterialConnectionPoint;
  121840. /**
  121841. * Gets the world normal input component
  121842. */
  121843. readonly worldNormal: NodeMaterialConnectionPoint;
  121844. /**
  121845. * Gets the world input component
  121846. */
  121847. readonly world: NodeMaterialConnectionPoint;
  121848. /**
  121849. * Gets the camera (or eye) position component
  121850. */
  121851. readonly cameraPosition: NodeMaterialConnectionPoint;
  121852. /**
  121853. * Gets the view input component
  121854. */
  121855. readonly view: NodeMaterialConnectionPoint;
  121856. /**
  121857. * Gets the rgb output component
  121858. */
  121859. readonly rgb: NodeMaterialConnectionPoint;
  121860. /**
  121861. * Gets the r output component
  121862. */
  121863. readonly r: NodeMaterialConnectionPoint;
  121864. /**
  121865. * Gets the g output component
  121866. */
  121867. readonly g: NodeMaterialConnectionPoint;
  121868. /**
  121869. * Gets the b output component
  121870. */
  121871. readonly b: NodeMaterialConnectionPoint;
  121872. autoConfigure(material: NodeMaterial): void;
  121873. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121874. isReady(): boolean;
  121875. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121876. private _injectVertexCode;
  121877. private _writeOutput;
  121878. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121879. protected _dumpPropertiesCode(): string;
  121880. serialize(): any;
  121881. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121882. }
  121883. }
  121884. declare module BABYLON {
  121885. /**
  121886. * Interface used to configure the node material editor
  121887. */
  121888. export interface INodeMaterialEditorOptions {
  121889. /** Define the URl to load node editor script */
  121890. editorURL?: string;
  121891. }
  121892. /** @hidden */
  121893. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  121894. /** BONES */
  121895. NUM_BONE_INFLUENCERS: number;
  121896. BonesPerMesh: number;
  121897. BONETEXTURE: boolean;
  121898. /** MORPH TARGETS */
  121899. MORPHTARGETS: boolean;
  121900. MORPHTARGETS_NORMAL: boolean;
  121901. MORPHTARGETS_TANGENT: boolean;
  121902. MORPHTARGETS_UV: boolean;
  121903. NUM_MORPH_INFLUENCERS: number;
  121904. /** IMAGE PROCESSING */
  121905. IMAGEPROCESSING: boolean;
  121906. VIGNETTE: boolean;
  121907. VIGNETTEBLENDMODEMULTIPLY: boolean;
  121908. VIGNETTEBLENDMODEOPAQUE: boolean;
  121909. TONEMAPPING: boolean;
  121910. TONEMAPPING_ACES: boolean;
  121911. CONTRAST: boolean;
  121912. EXPOSURE: boolean;
  121913. COLORCURVES: boolean;
  121914. COLORGRADING: boolean;
  121915. COLORGRADING3D: boolean;
  121916. SAMPLER3DGREENDEPTH: boolean;
  121917. SAMPLER3DBGRMAP: boolean;
  121918. IMAGEPROCESSINGPOSTPROCESS: boolean;
  121919. /** MISC. */
  121920. BUMPDIRECTUV: number;
  121921. constructor();
  121922. setValue(name: string, value: boolean): void;
  121923. }
  121924. /**
  121925. * Class used to configure NodeMaterial
  121926. */
  121927. export interface INodeMaterialOptions {
  121928. /**
  121929. * Defines if blocks should emit comments
  121930. */
  121931. emitComments: boolean;
  121932. }
  121933. /**
  121934. * Class used to create a node based material built by assembling shader blocks
  121935. */
  121936. export class NodeMaterial extends PushMaterial {
  121937. private static _BuildIdGenerator;
  121938. private _options;
  121939. private _vertexCompilationState;
  121940. private _fragmentCompilationState;
  121941. private _sharedData;
  121942. private _buildId;
  121943. private _buildWasSuccessful;
  121944. private _cachedWorldViewMatrix;
  121945. private _cachedWorldViewProjectionMatrix;
  121946. private _optimizers;
  121947. private _animationFrame;
  121948. /** Define the URl to load node editor script */
  121949. static EditorURL: string;
  121950. private BJSNODEMATERIALEDITOR;
  121951. /** Get the inspector from bundle or global */
  121952. private _getGlobalNodeMaterialEditor;
  121953. /**
  121954. * Gets or sets data used by visual editor
  121955. * @see https://nme.babylonjs.com
  121956. */
  121957. editorData: any;
  121958. /**
  121959. * 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)
  121960. */
  121961. ignoreAlpha: boolean;
  121962. /**
  121963. * Defines the maximum number of lights that can be used in the material
  121964. */
  121965. maxSimultaneousLights: number;
  121966. /**
  121967. * Observable raised when the material is built
  121968. */
  121969. onBuildObservable: Observable<NodeMaterial>;
  121970. /**
  121971. * Gets or sets the root nodes of the material vertex shader
  121972. */
  121973. _vertexOutputNodes: NodeMaterialBlock[];
  121974. /**
  121975. * Gets or sets the root nodes of the material fragment (pixel) shader
  121976. */
  121977. _fragmentOutputNodes: NodeMaterialBlock[];
  121978. /** Gets or sets options to control the node material overall behavior */
  121979. options: INodeMaterialOptions;
  121980. /**
  121981. * Default configuration related to image processing available in the standard Material.
  121982. */
  121983. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  121984. /**
  121985. * Gets the image processing configuration used either in this material.
  121986. */
  121987. /**
  121988. * Sets the Default image processing configuration used either in the this material.
  121989. *
  121990. * If sets to null, the scene one is in use.
  121991. */
  121992. imageProcessingConfiguration: ImageProcessingConfiguration;
  121993. /**
  121994. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  121995. */
  121996. attachedBlocks: NodeMaterialBlock[];
  121997. /**
  121998. * Create a new node based material
  121999. * @param name defines the material name
  122000. * @param scene defines the hosting scene
  122001. * @param options defines creation option
  122002. */
  122003. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  122004. /**
  122005. * Gets the current class name of the material e.g. "NodeMaterial"
  122006. * @returns the class name
  122007. */
  122008. getClassName(): string;
  122009. /**
  122010. * Keep track of the image processing observer to allow dispose and replace.
  122011. */
  122012. private _imageProcessingObserver;
  122013. /**
  122014. * Attaches a new image processing configuration to the Standard Material.
  122015. * @param configuration
  122016. */
  122017. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122018. /**
  122019. * Get a block by its name
  122020. * @param name defines the name of the block to retrieve
  122021. * @returns the required block or null if not found
  122022. */
  122023. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  122024. /**
  122025. * Get a block by its name
  122026. * @param predicate defines the predicate used to find the good candidate
  122027. * @returns the required block or null if not found
  122028. */
  122029. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  122030. /**
  122031. * Get an input block by its name
  122032. * @param predicate defines the predicate used to find the good candidate
  122033. * @returns the required input block or null if not found
  122034. */
  122035. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  122036. /**
  122037. * Gets the list of input blocks attached to this material
  122038. * @returns an array of InputBlocks
  122039. */
  122040. getInputBlocks(): InputBlock[];
  122041. /**
  122042. * Adds a new optimizer to the list of optimizers
  122043. * @param optimizer defines the optimizers to add
  122044. * @returns the current material
  122045. */
  122046. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  122047. /**
  122048. * Remove an optimizer from the list of optimizers
  122049. * @param optimizer defines the optimizers to remove
  122050. * @returns the current material
  122051. */
  122052. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  122053. /**
  122054. * Add a new block to the list of output nodes
  122055. * @param node defines the node to add
  122056. * @returns the current material
  122057. */
  122058. addOutputNode(node: NodeMaterialBlock): this;
  122059. /**
  122060. * Remove a block from the list of root nodes
  122061. * @param node defines the node to remove
  122062. * @returns the current material
  122063. */
  122064. removeOutputNode(node: NodeMaterialBlock): this;
  122065. private _addVertexOutputNode;
  122066. private _removeVertexOutputNode;
  122067. private _addFragmentOutputNode;
  122068. private _removeFragmentOutputNode;
  122069. /**
  122070. * Specifies if the material will require alpha blending
  122071. * @returns a boolean specifying if alpha blending is needed
  122072. */
  122073. needAlphaBlending(): boolean;
  122074. /**
  122075. * Specifies if this material should be rendered in alpha test mode
  122076. * @returns a boolean specifying if an alpha test is needed.
  122077. */
  122078. needAlphaTesting(): boolean;
  122079. private _initializeBlock;
  122080. private _resetDualBlocks;
  122081. /**
  122082. * Build the material and generates the inner effect
  122083. * @param verbose defines if the build should log activity
  122084. */
  122085. build(verbose?: boolean): void;
  122086. /**
  122087. * Runs an otpimization phase to try to improve the shader code
  122088. */
  122089. optimize(): void;
  122090. private _prepareDefinesForAttributes;
  122091. /**
  122092. * Get if the submesh is ready to be used and all its information available.
  122093. * Child classes can use it to update shaders
  122094. * @param mesh defines the mesh to check
  122095. * @param subMesh defines which submesh to check
  122096. * @param useInstances specifies that instances should be used
  122097. * @returns a boolean indicating that the submesh is ready or not
  122098. */
  122099. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122100. /**
  122101. * Get a string representing the shaders built by the current node graph
  122102. */
  122103. readonly compiledShaders: string;
  122104. /**
  122105. * Binds the world matrix to the material
  122106. * @param world defines the world transformation matrix
  122107. */
  122108. bindOnlyWorldMatrix(world: Matrix): void;
  122109. /**
  122110. * Binds the submesh to this material by preparing the effect and shader to draw
  122111. * @param world defines the world transformation matrix
  122112. * @param mesh defines the mesh containing the submesh
  122113. * @param subMesh defines the submesh to bind the material to
  122114. */
  122115. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122116. /**
  122117. * Gets the active textures from the material
  122118. * @returns an array of textures
  122119. */
  122120. getActiveTextures(): BaseTexture[];
  122121. /**
  122122. * Gets the list of texture blocks
  122123. * @returns an array of texture blocks
  122124. */
  122125. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  122126. /**
  122127. * Specifies if the material uses a texture
  122128. * @param texture defines the texture to check against the material
  122129. * @returns a boolean specifying if the material uses the texture
  122130. */
  122131. hasTexture(texture: BaseTexture): boolean;
  122132. /**
  122133. * Disposes the material
  122134. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  122135. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  122136. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  122137. */
  122138. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  122139. /** Creates the node editor window. */
  122140. private _createNodeEditor;
  122141. /**
  122142. * Launch the node material editor
  122143. * @param config Define the configuration of the editor
  122144. * @return a promise fulfilled when the node editor is visible
  122145. */
  122146. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  122147. /**
  122148. * Clear the current material
  122149. */
  122150. clear(): void;
  122151. /**
  122152. * Clear the current material and set it to a default state
  122153. */
  122154. setToDefault(): void;
  122155. /**
  122156. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  122157. * @param url defines the url to load from
  122158. * @returns a promise that will fullfil when the material is fully loaded
  122159. */
  122160. loadAsync(url: string): Promise<void>;
  122161. private _gatherBlocks;
  122162. /**
  122163. * Generate a string containing the code declaration required to create an equivalent of this material
  122164. * @returns a string
  122165. */
  122166. generateCode(): string;
  122167. /**
  122168. * Serializes this material in a JSON representation
  122169. * @returns the serialized material object
  122170. */
  122171. serialize(): any;
  122172. private _restoreConnections;
  122173. /**
  122174. * Clear the current graph and load a new one from a serialization object
  122175. * @param source defines the JSON representation of the material
  122176. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  122177. */
  122178. loadFromSerialization(source: any, rootUrl?: string): void;
  122179. /**
  122180. * Creates a node material from parsed material data
  122181. * @param source defines the JSON representation of the material
  122182. * @param scene defines the hosting scene
  122183. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  122184. * @returns a new node material
  122185. */
  122186. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  122187. /**
  122188. * Creates a new node material set to default basic configuration
  122189. * @param name defines the name of the material
  122190. * @param scene defines the hosting scene
  122191. * @returns a new NodeMaterial
  122192. */
  122193. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  122194. }
  122195. }
  122196. declare module BABYLON {
  122197. /**
  122198. * Block used to read a texture from a sampler
  122199. */
  122200. export class TextureBlock extends NodeMaterialBlock {
  122201. private _defineName;
  122202. private _linearDefineName;
  122203. private _tempTextureRead;
  122204. private _samplerName;
  122205. private _transformedUVName;
  122206. private _textureTransformName;
  122207. private _textureInfoName;
  122208. private _mainUVName;
  122209. private _mainUVDefineName;
  122210. /**
  122211. * Gets or sets the texture associated with the node
  122212. */
  122213. texture: Nullable<Texture>;
  122214. /**
  122215. * Create a new TextureBlock
  122216. * @param name defines the block name
  122217. */
  122218. constructor(name: string);
  122219. /**
  122220. * Gets the current class name
  122221. * @returns the class name
  122222. */
  122223. getClassName(): string;
  122224. /**
  122225. * Gets the uv input component
  122226. */
  122227. readonly uv: NodeMaterialConnectionPoint;
  122228. /**
  122229. * Gets the rgba output component
  122230. */
  122231. readonly rgba: NodeMaterialConnectionPoint;
  122232. /**
  122233. * Gets the rgb output component
  122234. */
  122235. readonly rgb: NodeMaterialConnectionPoint;
  122236. /**
  122237. * Gets the r output component
  122238. */
  122239. readonly r: NodeMaterialConnectionPoint;
  122240. /**
  122241. * Gets the g output component
  122242. */
  122243. readonly g: NodeMaterialConnectionPoint;
  122244. /**
  122245. * Gets the b output component
  122246. */
  122247. readonly b: NodeMaterialConnectionPoint;
  122248. /**
  122249. * Gets the a output component
  122250. */
  122251. readonly a: NodeMaterialConnectionPoint;
  122252. readonly target: NodeMaterialBlockTargets;
  122253. autoConfigure(material: NodeMaterial): void;
  122254. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122255. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122256. isReady(): boolean;
  122257. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122258. private readonly _isMixed;
  122259. private _injectVertexCode;
  122260. private _writeTextureRead;
  122261. private _writeOutput;
  122262. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122263. protected _dumpPropertiesCode(): string;
  122264. serialize(): any;
  122265. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122266. }
  122267. }
  122268. declare module BABYLON {
  122269. /**
  122270. * Class used to store shared data between 2 NodeMaterialBuildState
  122271. */
  122272. export class NodeMaterialBuildStateSharedData {
  122273. /**
  122274. * Gets the list of emitted varyings
  122275. */
  122276. temps: string[];
  122277. /**
  122278. * Gets the list of emitted varyings
  122279. */
  122280. varyings: string[];
  122281. /**
  122282. * Gets the varying declaration string
  122283. */
  122284. varyingDeclaration: string;
  122285. /**
  122286. * Input blocks
  122287. */
  122288. inputBlocks: InputBlock[];
  122289. /**
  122290. * Input blocks
  122291. */
  122292. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  122293. /**
  122294. * Bindable blocks (Blocks that need to set data to the effect)
  122295. */
  122296. bindableBlocks: NodeMaterialBlock[];
  122297. /**
  122298. * List of blocks that can provide a compilation fallback
  122299. */
  122300. blocksWithFallbacks: NodeMaterialBlock[];
  122301. /**
  122302. * List of blocks that can provide a define update
  122303. */
  122304. blocksWithDefines: NodeMaterialBlock[];
  122305. /**
  122306. * List of blocks that can provide a repeatable content
  122307. */
  122308. repeatableContentBlocks: NodeMaterialBlock[];
  122309. /**
  122310. * List of blocks that can provide a dynamic list of uniforms
  122311. */
  122312. dynamicUniformBlocks: NodeMaterialBlock[];
  122313. /**
  122314. * List of blocks that can block the isReady function for the material
  122315. */
  122316. blockingBlocks: NodeMaterialBlock[];
  122317. /**
  122318. * Gets the list of animated inputs
  122319. */
  122320. animatedInputs: InputBlock[];
  122321. /**
  122322. * Build Id used to avoid multiple recompilations
  122323. */
  122324. buildId: number;
  122325. /** List of emitted variables */
  122326. variableNames: {
  122327. [key: string]: number;
  122328. };
  122329. /** List of emitted defines */
  122330. defineNames: {
  122331. [key: string]: number;
  122332. };
  122333. /** Should emit comments? */
  122334. emitComments: boolean;
  122335. /** Emit build activity */
  122336. verbose: boolean;
  122337. /** Gets or sets the hosting scene */
  122338. scene: Scene;
  122339. /**
  122340. * Gets the compilation hints emitted at compilation time
  122341. */
  122342. hints: {
  122343. needWorldViewMatrix: boolean;
  122344. needWorldViewProjectionMatrix: boolean;
  122345. needAlphaBlending: boolean;
  122346. needAlphaTesting: boolean;
  122347. };
  122348. /**
  122349. * List of compilation checks
  122350. */
  122351. checks: {
  122352. emitVertex: boolean;
  122353. emitFragment: boolean;
  122354. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  122355. };
  122356. /** Creates a new shared data */
  122357. constructor();
  122358. /**
  122359. * Emits console errors and exceptions if there is a failing check
  122360. */
  122361. emitErrors(): void;
  122362. }
  122363. }
  122364. declare module BABYLON {
  122365. /**
  122366. * Class used to store node based material build state
  122367. */
  122368. export class NodeMaterialBuildState {
  122369. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  122370. supportUniformBuffers: boolean;
  122371. /**
  122372. * Gets the list of emitted attributes
  122373. */
  122374. attributes: string[];
  122375. /**
  122376. * Gets the list of emitted uniforms
  122377. */
  122378. uniforms: string[];
  122379. /**
  122380. * Gets the list of emitted constants
  122381. */
  122382. constants: string[];
  122383. /**
  122384. * Gets the list of emitted samplers
  122385. */
  122386. samplers: string[];
  122387. /**
  122388. * Gets the list of emitted functions
  122389. */
  122390. functions: {
  122391. [key: string]: string;
  122392. };
  122393. /**
  122394. * Gets the list of emitted extensions
  122395. */
  122396. extensions: {
  122397. [key: string]: string;
  122398. };
  122399. /**
  122400. * Gets the target of the compilation state
  122401. */
  122402. target: NodeMaterialBlockTargets;
  122403. /**
  122404. * Gets the list of emitted counters
  122405. */
  122406. counters: {
  122407. [key: string]: number;
  122408. };
  122409. /**
  122410. * Shared data between multiple NodeMaterialBuildState instances
  122411. */
  122412. sharedData: NodeMaterialBuildStateSharedData;
  122413. /** @hidden */
  122414. _vertexState: NodeMaterialBuildState;
  122415. /** @hidden */
  122416. _attributeDeclaration: string;
  122417. /** @hidden */
  122418. _uniformDeclaration: string;
  122419. /** @hidden */
  122420. _constantDeclaration: string;
  122421. /** @hidden */
  122422. _samplerDeclaration: string;
  122423. /** @hidden */
  122424. _varyingTransfer: string;
  122425. private _repeatableContentAnchorIndex;
  122426. /** @hidden */
  122427. _builtCompilationString: string;
  122428. /**
  122429. * Gets the emitted compilation strings
  122430. */
  122431. compilationString: string;
  122432. /**
  122433. * Finalize the compilation strings
  122434. * @param state defines the current compilation state
  122435. */
  122436. finalize(state: NodeMaterialBuildState): void;
  122437. /** @hidden */
  122438. readonly _repeatableContentAnchor: string;
  122439. /** @hidden */
  122440. _getFreeVariableName(prefix: string): string;
  122441. /** @hidden */
  122442. _getFreeDefineName(prefix: string): string;
  122443. /** @hidden */
  122444. _excludeVariableName(name: string): void;
  122445. /** @hidden */
  122446. _emit2DSampler(name: string): void;
  122447. /** @hidden */
  122448. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  122449. /** @hidden */
  122450. _emitExtension(name: string, extension: string): void;
  122451. /** @hidden */
  122452. _emitFunction(name: string, code: string, comments: string): void;
  122453. /** @hidden */
  122454. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  122455. replaceStrings?: {
  122456. search: RegExp;
  122457. replace: string;
  122458. }[];
  122459. repeatKey?: string;
  122460. }): string;
  122461. /** @hidden */
  122462. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  122463. repeatKey?: string;
  122464. removeAttributes?: boolean;
  122465. removeUniforms?: boolean;
  122466. removeVaryings?: boolean;
  122467. removeIfDef?: boolean;
  122468. replaceStrings?: {
  122469. search: RegExp;
  122470. replace: string;
  122471. }[];
  122472. }, storeKey?: string): void;
  122473. /** @hidden */
  122474. _registerTempVariable(name: string): boolean;
  122475. /** @hidden */
  122476. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  122477. /** @hidden */
  122478. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  122479. /** @hidden */
  122480. _emitFloat(value: number): string;
  122481. }
  122482. }
  122483. declare module BABYLON {
  122484. /**
  122485. * Defines a block that can be used inside a node based material
  122486. */
  122487. export class NodeMaterialBlock {
  122488. private _buildId;
  122489. private _buildTarget;
  122490. private _target;
  122491. private _isFinalMerger;
  122492. private _isInput;
  122493. protected _isUnique: boolean;
  122494. /** @hidden */
  122495. _codeVariableName: string;
  122496. /** @hidden */
  122497. _inputs: NodeMaterialConnectionPoint[];
  122498. /** @hidden */
  122499. _outputs: NodeMaterialConnectionPoint[];
  122500. /** @hidden */
  122501. _preparationId: number;
  122502. /**
  122503. * Gets or sets the name of the block
  122504. */
  122505. name: string;
  122506. /**
  122507. * Gets or sets the unique id of the node
  122508. */
  122509. uniqueId: number;
  122510. /**
  122511. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  122512. */
  122513. readonly isUnique: boolean;
  122514. /**
  122515. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  122516. */
  122517. readonly isFinalMerger: boolean;
  122518. /**
  122519. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  122520. */
  122521. readonly isInput: boolean;
  122522. /**
  122523. * Gets or sets the build Id
  122524. */
  122525. buildId: number;
  122526. /**
  122527. * Gets or sets the target of the block
  122528. */
  122529. target: NodeMaterialBlockTargets;
  122530. /**
  122531. * Gets the list of input points
  122532. */
  122533. readonly inputs: NodeMaterialConnectionPoint[];
  122534. /** Gets the list of output points */
  122535. readonly outputs: NodeMaterialConnectionPoint[];
  122536. /**
  122537. * Find an input by its name
  122538. * @param name defines the name of the input to look for
  122539. * @returns the input or null if not found
  122540. */
  122541. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  122542. /**
  122543. * Find an output by its name
  122544. * @param name defines the name of the outputto look for
  122545. * @returns the output or null if not found
  122546. */
  122547. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  122548. /**
  122549. * Creates a new NodeMaterialBlock
  122550. * @param name defines the block name
  122551. * @param target defines the target of that block (Vertex by default)
  122552. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  122553. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  122554. */
  122555. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  122556. /**
  122557. * Initialize the block and prepare the context for build
  122558. * @param state defines the state that will be used for the build
  122559. */
  122560. initialize(state: NodeMaterialBuildState): void;
  122561. /**
  122562. * Bind data to effect. Will only be called for blocks with isBindable === true
  122563. * @param effect defines the effect to bind data to
  122564. * @param nodeMaterial defines the hosting NodeMaterial
  122565. * @param mesh defines the mesh that will be rendered
  122566. */
  122567. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122568. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  122569. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  122570. protected _writeFloat(value: number): string;
  122571. /**
  122572. * Gets the current class name e.g. "NodeMaterialBlock"
  122573. * @returns the class name
  122574. */
  122575. getClassName(): string;
  122576. /**
  122577. * Register a new input. Must be called inside a block constructor
  122578. * @param name defines the connection point name
  122579. * @param type defines the connection point type
  122580. * @param isOptional defines a boolean indicating that this input can be omitted
  122581. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  122582. * @returns the current block
  122583. */
  122584. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  122585. /**
  122586. * Register a new output. Must be called inside a block constructor
  122587. * @param name defines the connection point name
  122588. * @param type defines the connection point type
  122589. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  122590. * @returns the current block
  122591. */
  122592. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  122593. /**
  122594. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  122595. * @param forOutput defines an optional connection point to check compatibility with
  122596. * @returns the first available input or null
  122597. */
  122598. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  122599. /**
  122600. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  122601. * @param forBlock defines an optional block to check compatibility with
  122602. * @returns the first available input or null
  122603. */
  122604. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  122605. /**
  122606. * Gets the sibling of the given output
  122607. * @param current defines the current output
  122608. * @returns the next output in the list or null
  122609. */
  122610. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  122611. /**
  122612. * Connect current block with another block
  122613. * @param other defines the block to connect with
  122614. * @param options define the various options to help pick the right connections
  122615. * @returns the current block
  122616. */
  122617. connectTo(other: NodeMaterialBlock, options?: {
  122618. input?: string;
  122619. output?: string;
  122620. outputSwizzle?: string;
  122621. }): this | undefined;
  122622. protected _buildBlock(state: NodeMaterialBuildState): void;
  122623. /**
  122624. * Add uniforms, samplers and uniform buffers at compilation time
  122625. * @param state defines the state to update
  122626. * @param nodeMaterial defines the node material requesting the update
  122627. * @param defines defines the material defines to update
  122628. * @param uniformBuffers defines the list of uniform buffer names
  122629. */
  122630. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  122631. /**
  122632. * Add potential fallbacks if shader compilation fails
  122633. * @param mesh defines the mesh to be rendered
  122634. * @param fallbacks defines the current prioritized list of fallbacks
  122635. */
  122636. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  122637. /**
  122638. * Initialize defines for shader compilation
  122639. * @param mesh defines the mesh to be rendered
  122640. * @param nodeMaterial defines the node material requesting the update
  122641. * @param defines defines the material defines to update
  122642. * @param useInstances specifies that instances should be used
  122643. */
  122644. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122645. /**
  122646. * Update defines for shader compilation
  122647. * @param mesh defines the mesh to be rendered
  122648. * @param nodeMaterial defines the node material requesting the update
  122649. * @param defines defines the material defines to update
  122650. * @param useInstances specifies that instances should be used
  122651. */
  122652. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122653. /**
  122654. * Lets the block try to connect some inputs automatically
  122655. * @param material defines the hosting NodeMaterial
  122656. */
  122657. autoConfigure(material: NodeMaterial): void;
  122658. /**
  122659. * Function called when a block is declared as repeatable content generator
  122660. * @param vertexShaderState defines the current compilation state for the vertex shader
  122661. * @param fragmentShaderState defines the current compilation state for the fragment shader
  122662. * @param mesh defines the mesh to be rendered
  122663. * @param defines defines the material defines to update
  122664. */
  122665. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  122666. /**
  122667. * Checks if the block is ready
  122668. * @param mesh defines the mesh to be rendered
  122669. * @param nodeMaterial defines the node material requesting the update
  122670. * @param defines defines the material defines to update
  122671. * @param useInstances specifies that instances should be used
  122672. * @returns true if the block is ready
  122673. */
  122674. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  122675. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  122676. private _processBuild;
  122677. /**
  122678. * Compile the current node and generate the shader code
  122679. * @param state defines the current compilation state (uniforms, samplers, current string)
  122680. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  122681. * @returns true if already built
  122682. */
  122683. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  122684. protected _inputRename(name: string): string;
  122685. protected _outputRename(name: string): string;
  122686. protected _dumpPropertiesCode(): string;
  122687. /** @hidden */
  122688. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  122689. /** @hidden */
  122690. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  122691. /**
  122692. * Clone the current block to a new identical block
  122693. * @param scene defines the hosting scene
  122694. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  122695. * @returns a copy of the current block
  122696. */
  122697. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  122698. /**
  122699. * Serializes this block in a JSON representation
  122700. * @returns the serialized block object
  122701. */
  122702. serialize(): any;
  122703. /** @hidden */
  122704. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122705. /**
  122706. * Release resources
  122707. */
  122708. dispose(): void;
  122709. }
  122710. }
  122711. declare module BABYLON {
  122712. /**
  122713. * Enum defining the type of animations supported by InputBlock
  122714. */
  122715. export enum AnimatedInputBlockTypes {
  122716. /** No animation */
  122717. None = 0,
  122718. /** Time based animation. Will only work for floats */
  122719. Time = 1
  122720. }
  122721. }
  122722. declare module BABYLON {
  122723. /**
  122724. * Block used to expose an input value
  122725. */
  122726. export class InputBlock extends NodeMaterialBlock {
  122727. private _mode;
  122728. private _associatedVariableName;
  122729. private _storedValue;
  122730. private _valueCallback;
  122731. private _type;
  122732. private _animationType;
  122733. /** Gets or set a value used to limit the range of float values */
  122734. min: number;
  122735. /** Gets or set a value used to limit the range of float values */
  122736. max: number;
  122737. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  122738. matrixMode: number;
  122739. /** @hidden */
  122740. _systemValue: Nullable<NodeMaterialSystemValues>;
  122741. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  122742. visibleInInspector: boolean;
  122743. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  122744. isConstant: boolean;
  122745. /**
  122746. * Gets or sets the connection point type (default is float)
  122747. */
  122748. readonly type: NodeMaterialBlockConnectionPointTypes;
  122749. /**
  122750. * Creates a new InputBlock
  122751. * @param name defines the block name
  122752. * @param target defines the target of that block (Vertex by default)
  122753. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  122754. */
  122755. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  122756. /**
  122757. * Gets the output component
  122758. */
  122759. readonly output: NodeMaterialConnectionPoint;
  122760. /**
  122761. * Set the source of this connection point to a vertex attribute
  122762. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  122763. * @returns the current connection point
  122764. */
  122765. setAsAttribute(attributeName?: string): InputBlock;
  122766. /**
  122767. * Set the source of this connection point to a system value
  122768. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  122769. * @returns the current connection point
  122770. */
  122771. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  122772. /**
  122773. * Gets or sets the value of that point.
  122774. * Please note that this value will be ignored if valueCallback is defined
  122775. */
  122776. value: any;
  122777. /**
  122778. * Gets or sets a callback used to get the value of that point.
  122779. * Please note that setting this value will force the connection point to ignore the value property
  122780. */
  122781. valueCallback: () => any;
  122782. /**
  122783. * Gets or sets the associated variable name in the shader
  122784. */
  122785. associatedVariableName: string;
  122786. /** Gets or sets the type of animation applied to the input */
  122787. animationType: AnimatedInputBlockTypes;
  122788. /**
  122789. * Gets a boolean indicating that this connection point not defined yet
  122790. */
  122791. readonly isUndefined: boolean;
  122792. /**
  122793. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  122794. * In this case the connection point name must be the name of the uniform to use.
  122795. * Can only be set on inputs
  122796. */
  122797. isUniform: boolean;
  122798. /**
  122799. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  122800. * In this case the connection point name must be the name of the attribute to use
  122801. * Can only be set on inputs
  122802. */
  122803. isAttribute: boolean;
  122804. /**
  122805. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  122806. * Can only be set on exit points
  122807. */
  122808. isVarying: boolean;
  122809. /**
  122810. * Gets a boolean indicating that the current connection point is a system value
  122811. */
  122812. readonly isSystemValue: boolean;
  122813. /**
  122814. * Gets or sets the current well known value or null if not defined as a system value
  122815. */
  122816. systemValue: Nullable<NodeMaterialSystemValues>;
  122817. /**
  122818. * Gets the current class name
  122819. * @returns the class name
  122820. */
  122821. getClassName(): string;
  122822. /**
  122823. * Animate the input if animationType !== None
  122824. * @param scene defines the rendering scene
  122825. */
  122826. animate(scene: Scene): void;
  122827. private _emitDefine;
  122828. initialize(state: NodeMaterialBuildState): void;
  122829. /**
  122830. * Set the input block to its default value (based on its type)
  122831. */
  122832. setDefaultValue(): void;
  122833. private _emitConstant;
  122834. private _emit;
  122835. /** @hidden */
  122836. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  122837. /** @hidden */
  122838. _transmit(effect: Effect, scene: Scene): void;
  122839. protected _buildBlock(state: NodeMaterialBuildState): void;
  122840. protected _dumpPropertiesCode(): string;
  122841. serialize(): any;
  122842. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122843. }
  122844. }
  122845. declare module BABYLON {
  122846. /**
  122847. * Enum used to define the compatibility state between two connection points
  122848. */
  122849. export enum NodeMaterialConnectionPointCompatibilityStates {
  122850. /** Points are compatibles */
  122851. Compatible = 0,
  122852. /** Points are incompatible because of their types */
  122853. TypeIncompatible = 1,
  122854. /** Points are incompatible because of their targets (vertex vs fragment) */
  122855. TargetIncompatible = 2
  122856. }
  122857. /**
  122858. * Defines a connection point for a block
  122859. */
  122860. export class NodeMaterialConnectionPoint {
  122861. /** @hidden */
  122862. _ownerBlock: NodeMaterialBlock;
  122863. /** @hidden */
  122864. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  122865. private _endpoints;
  122866. private _associatedVariableName;
  122867. /** @hidden */
  122868. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  122869. /** @hidden */
  122870. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  122871. private _type;
  122872. /** @hidden */
  122873. _enforceAssociatedVariableName: boolean;
  122874. /**
  122875. * Gets or sets the additional types supported by this connection point
  122876. */
  122877. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  122878. /**
  122879. * Gets or sets the additional types excluded by this connection point
  122880. */
  122881. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  122882. /**
  122883. * Observable triggered when this point is connected
  122884. */
  122885. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  122886. /**
  122887. * Gets or sets the associated variable name in the shader
  122888. */
  122889. associatedVariableName: string;
  122890. /**
  122891. * Gets or sets the connection point type (default is float)
  122892. */
  122893. type: NodeMaterialBlockConnectionPointTypes;
  122894. /**
  122895. * Gets or sets the connection point name
  122896. */
  122897. name: string;
  122898. /**
  122899. * Gets or sets a boolean indicating that this connection point can be omitted
  122900. */
  122901. isOptional: boolean;
  122902. /**
  122903. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  122904. */
  122905. define: string;
  122906. /** @hidden */
  122907. _prioritizeVertex: boolean;
  122908. private _target;
  122909. /** Gets or sets the target of that connection point */
  122910. target: NodeMaterialBlockTargets;
  122911. /**
  122912. * Gets a boolean indicating that the current point is connected
  122913. */
  122914. readonly isConnected: boolean;
  122915. /**
  122916. * Gets a boolean indicating that the current point is connected to an input block
  122917. */
  122918. readonly isConnectedToInputBlock: boolean;
  122919. /**
  122920. * Gets a the connected input block (if any)
  122921. */
  122922. readonly connectInputBlock: Nullable<InputBlock>;
  122923. /** Get the other side of the connection (if any) */
  122924. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  122925. /** Get the block that owns this connection point */
  122926. readonly ownerBlock: NodeMaterialBlock;
  122927. /** Get the block connected on the other side of this connection (if any) */
  122928. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  122929. /** Get the block connected on the endpoints of this connection (if any) */
  122930. readonly connectedBlocks: Array<NodeMaterialBlock>;
  122931. /** Gets the list of connected endpoints */
  122932. readonly endpoints: NodeMaterialConnectionPoint[];
  122933. /** Gets a boolean indicating if that output point is connected to at least one input */
  122934. readonly hasEndpoints: boolean;
  122935. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  122936. readonly isConnectedInVertexShader: boolean;
  122937. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  122938. readonly isConnectedInFragmentShader: boolean;
  122939. /**
  122940. * Creates a new connection point
  122941. * @param name defines the connection point name
  122942. * @param ownerBlock defines the block hosting this connection point
  122943. */
  122944. constructor(name: string, ownerBlock: NodeMaterialBlock);
  122945. /**
  122946. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  122947. * @returns the class name
  122948. */
  122949. getClassName(): string;
  122950. /**
  122951. * Gets a boolean indicating if the current point can be connected to another point
  122952. * @param connectionPoint defines the other connection point
  122953. * @returns a boolean
  122954. */
  122955. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  122956. /**
  122957. * Gets a number indicating if the current point can be connected to another point
  122958. * @param connectionPoint defines the other connection point
  122959. * @returns a number defining the compatibility state
  122960. */
  122961. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  122962. /**
  122963. * Connect this point to another connection point
  122964. * @param connectionPoint defines the other connection point
  122965. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  122966. * @returns the current connection point
  122967. */
  122968. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  122969. /**
  122970. * Disconnect this point from one of his endpoint
  122971. * @param endpoint defines the other connection point
  122972. * @returns the current connection point
  122973. */
  122974. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  122975. /**
  122976. * Serializes this point in a JSON representation
  122977. * @returns the serialized point object
  122978. */
  122979. serialize(): any;
  122980. /**
  122981. * Release resources
  122982. */
  122983. dispose(): void;
  122984. }
  122985. }
  122986. declare module BABYLON {
  122987. /**
  122988. * Block used to add support for vertex skinning (bones)
  122989. */
  122990. export class BonesBlock extends NodeMaterialBlock {
  122991. /**
  122992. * Creates a new BonesBlock
  122993. * @param name defines the block name
  122994. */
  122995. constructor(name: string);
  122996. /**
  122997. * Initialize the block and prepare the context for build
  122998. * @param state defines the state that will be used for the build
  122999. */
  123000. initialize(state: NodeMaterialBuildState): void;
  123001. /**
  123002. * Gets the current class name
  123003. * @returns the class name
  123004. */
  123005. getClassName(): string;
  123006. /**
  123007. * Gets the matrix indices input component
  123008. */
  123009. readonly matricesIndices: NodeMaterialConnectionPoint;
  123010. /**
  123011. * Gets the matrix weights input component
  123012. */
  123013. readonly matricesWeights: NodeMaterialConnectionPoint;
  123014. /**
  123015. * Gets the extra matrix indices input component
  123016. */
  123017. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  123018. /**
  123019. * Gets the extra matrix weights input component
  123020. */
  123021. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  123022. /**
  123023. * Gets the world input component
  123024. */
  123025. readonly world: NodeMaterialConnectionPoint;
  123026. /**
  123027. * Gets the output component
  123028. */
  123029. readonly output: NodeMaterialConnectionPoint;
  123030. autoConfigure(material: NodeMaterial): void;
  123031. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  123032. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123033. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123034. protected _buildBlock(state: NodeMaterialBuildState): this;
  123035. }
  123036. }
  123037. declare module BABYLON {
  123038. /**
  123039. * Block used to add support for instances
  123040. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  123041. */
  123042. export class InstancesBlock extends NodeMaterialBlock {
  123043. /**
  123044. * Creates a new InstancesBlock
  123045. * @param name defines the block name
  123046. */
  123047. constructor(name: string);
  123048. /**
  123049. * Gets the current class name
  123050. * @returns the class name
  123051. */
  123052. getClassName(): string;
  123053. /**
  123054. * Gets the first world row input component
  123055. */
  123056. readonly world0: NodeMaterialConnectionPoint;
  123057. /**
  123058. * Gets the second world row input component
  123059. */
  123060. readonly world1: NodeMaterialConnectionPoint;
  123061. /**
  123062. * Gets the third world row input component
  123063. */
  123064. readonly world2: NodeMaterialConnectionPoint;
  123065. /**
  123066. * Gets the forth world row input component
  123067. */
  123068. readonly world3: NodeMaterialConnectionPoint;
  123069. /**
  123070. * Gets the world input component
  123071. */
  123072. readonly world: NodeMaterialConnectionPoint;
  123073. /**
  123074. * Gets the output component
  123075. */
  123076. readonly output: NodeMaterialConnectionPoint;
  123077. autoConfigure(material: NodeMaterial): void;
  123078. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123079. protected _buildBlock(state: NodeMaterialBuildState): this;
  123080. }
  123081. }
  123082. declare module BABYLON {
  123083. /**
  123084. * Block used to add morph targets support to vertex shader
  123085. */
  123086. export class MorphTargetsBlock extends NodeMaterialBlock {
  123087. private _repeatableContentAnchor;
  123088. private _repeatebleContentGenerated;
  123089. /**
  123090. * Create a new MorphTargetsBlock
  123091. * @param name defines the block name
  123092. */
  123093. constructor(name: string);
  123094. /**
  123095. * Gets the current class name
  123096. * @returns the class name
  123097. */
  123098. getClassName(): string;
  123099. /**
  123100. * Gets the position input component
  123101. */
  123102. readonly position: NodeMaterialConnectionPoint;
  123103. /**
  123104. * Gets the normal input component
  123105. */
  123106. readonly normal: NodeMaterialConnectionPoint;
  123107. /**
  123108. * Gets the tangent input component
  123109. */
  123110. readonly tangent: NodeMaterialConnectionPoint;
  123111. /**
  123112. * Gets the tangent input component
  123113. */
  123114. readonly uv: NodeMaterialConnectionPoint;
  123115. /**
  123116. * Gets the position output component
  123117. */
  123118. readonly positionOutput: NodeMaterialConnectionPoint;
  123119. /**
  123120. * Gets the normal output component
  123121. */
  123122. readonly normalOutput: NodeMaterialConnectionPoint;
  123123. /**
  123124. * Gets the tangent output component
  123125. */
  123126. readonly tangentOutput: NodeMaterialConnectionPoint;
  123127. /**
  123128. * Gets the tangent output component
  123129. */
  123130. readonly uvOutput: NodeMaterialConnectionPoint;
  123131. initialize(state: NodeMaterialBuildState): void;
  123132. autoConfigure(material: NodeMaterial): void;
  123133. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123134. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123135. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  123136. protected _buildBlock(state: NodeMaterialBuildState): this;
  123137. }
  123138. }
  123139. declare module BABYLON {
  123140. /**
  123141. * Block used to get data information from a light
  123142. */
  123143. export class LightInformationBlock extends NodeMaterialBlock {
  123144. private _lightDataUniformName;
  123145. private _lightColorUniformName;
  123146. private _lightTypeDefineName;
  123147. /**
  123148. * Gets or sets the light associated with this block
  123149. */
  123150. light: Nullable<Light>;
  123151. /**
  123152. * Creates a new LightInformationBlock
  123153. * @param name defines the block name
  123154. */
  123155. constructor(name: string);
  123156. /**
  123157. * Gets the current class name
  123158. * @returns the class name
  123159. */
  123160. getClassName(): string;
  123161. /**
  123162. * Gets the world position input component
  123163. */
  123164. readonly worldPosition: NodeMaterialConnectionPoint;
  123165. /**
  123166. * Gets the direction output component
  123167. */
  123168. readonly direction: NodeMaterialConnectionPoint;
  123169. /**
  123170. * Gets the direction output component
  123171. */
  123172. readonly color: NodeMaterialConnectionPoint;
  123173. /**
  123174. * Gets the direction output component
  123175. */
  123176. readonly intensity: NodeMaterialConnectionPoint;
  123177. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123178. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123179. protected _buildBlock(state: NodeMaterialBuildState): this;
  123180. serialize(): any;
  123181. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123182. }
  123183. }
  123184. declare module BABYLON {
  123185. /**
  123186. * Block used to add image processing support to fragment shader
  123187. */
  123188. export class ImageProcessingBlock extends NodeMaterialBlock {
  123189. /**
  123190. * Create a new ImageProcessingBlock
  123191. * @param name defines the block name
  123192. */
  123193. constructor(name: string);
  123194. /**
  123195. * Gets the current class name
  123196. * @returns the class name
  123197. */
  123198. getClassName(): string;
  123199. /**
  123200. * Gets the color input component
  123201. */
  123202. readonly color: NodeMaterialConnectionPoint;
  123203. /**
  123204. * Gets the output component
  123205. */
  123206. readonly output: NodeMaterialConnectionPoint;
  123207. /**
  123208. * Initialize the block and prepare the context for build
  123209. * @param state defines the state that will be used for the build
  123210. */
  123211. initialize(state: NodeMaterialBuildState): void;
  123212. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  123213. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123214. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123215. protected _buildBlock(state: NodeMaterialBuildState): this;
  123216. }
  123217. }
  123218. declare module BABYLON {
  123219. /**
  123220. * Block used to pertub normals based on a normal map
  123221. */
  123222. export class PerturbNormalBlock extends NodeMaterialBlock {
  123223. private _tangentSpaceParameterName;
  123224. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  123225. invertX: boolean;
  123226. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  123227. invertY: boolean;
  123228. /**
  123229. * Create a new PerturbNormalBlock
  123230. * @param name defines the block name
  123231. */
  123232. constructor(name: string);
  123233. /**
  123234. * Gets the current class name
  123235. * @returns the class name
  123236. */
  123237. getClassName(): string;
  123238. /**
  123239. * Gets the world position input component
  123240. */
  123241. readonly worldPosition: NodeMaterialConnectionPoint;
  123242. /**
  123243. * Gets the world normal input component
  123244. */
  123245. readonly worldNormal: NodeMaterialConnectionPoint;
  123246. /**
  123247. * Gets the uv input component
  123248. */
  123249. readonly uv: NodeMaterialConnectionPoint;
  123250. /**
  123251. * Gets the normal map color input component
  123252. */
  123253. readonly normalMapColor: NodeMaterialConnectionPoint;
  123254. /**
  123255. * Gets the strength input component
  123256. */
  123257. readonly strength: NodeMaterialConnectionPoint;
  123258. /**
  123259. * Gets the output component
  123260. */
  123261. readonly output: NodeMaterialConnectionPoint;
  123262. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123263. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123264. autoConfigure(material: NodeMaterial): void;
  123265. protected _buildBlock(state: NodeMaterialBuildState): this;
  123266. protected _dumpPropertiesCode(): string;
  123267. serialize(): any;
  123268. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123269. }
  123270. }
  123271. declare module BABYLON {
  123272. /**
  123273. * Block used to discard a pixel if a value is smaller than a cutoff
  123274. */
  123275. export class DiscardBlock extends NodeMaterialBlock {
  123276. /**
  123277. * Create a new DiscardBlock
  123278. * @param name defines the block name
  123279. */
  123280. constructor(name: string);
  123281. /**
  123282. * Gets the current class name
  123283. * @returns the class name
  123284. */
  123285. getClassName(): string;
  123286. /**
  123287. * Gets the color input component
  123288. */
  123289. readonly value: NodeMaterialConnectionPoint;
  123290. /**
  123291. * Gets the cutoff input component
  123292. */
  123293. readonly cutoff: NodeMaterialConnectionPoint;
  123294. protected _buildBlock(state: NodeMaterialBuildState): this;
  123295. }
  123296. }
  123297. declare module BABYLON {
  123298. /**
  123299. * Block used to test if the fragment shader is front facing
  123300. */
  123301. export class FrontFacingBlock extends NodeMaterialBlock {
  123302. /**
  123303. * Creates a new FrontFacingBlock
  123304. * @param name defines the block name
  123305. */
  123306. constructor(name: string);
  123307. /**
  123308. * Gets the current class name
  123309. * @returns the class name
  123310. */
  123311. getClassName(): string;
  123312. /**
  123313. * Gets the output component
  123314. */
  123315. readonly output: NodeMaterialConnectionPoint;
  123316. protected _buildBlock(state: NodeMaterialBuildState): this;
  123317. }
  123318. }
  123319. declare module BABYLON {
  123320. /**
  123321. * Block used to add support for scene fog
  123322. */
  123323. export class FogBlock extends NodeMaterialBlock {
  123324. private _fogDistanceName;
  123325. private _fogParameters;
  123326. /**
  123327. * Create a new FogBlock
  123328. * @param name defines the block name
  123329. */
  123330. constructor(name: string);
  123331. /**
  123332. * Gets the current class name
  123333. * @returns the class name
  123334. */
  123335. getClassName(): string;
  123336. /**
  123337. * Gets the world position input component
  123338. */
  123339. readonly worldPosition: NodeMaterialConnectionPoint;
  123340. /**
  123341. * Gets the view input component
  123342. */
  123343. readonly view: NodeMaterialConnectionPoint;
  123344. /**
  123345. * Gets the color input component
  123346. */
  123347. readonly input: NodeMaterialConnectionPoint;
  123348. /**
  123349. * Gets the fog color input component
  123350. */
  123351. readonly fogColor: NodeMaterialConnectionPoint;
  123352. /**
  123353. * Gets the output component
  123354. */
  123355. readonly output: NodeMaterialConnectionPoint;
  123356. autoConfigure(material: NodeMaterial): void;
  123357. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123358. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123359. protected _buildBlock(state: NodeMaterialBuildState): this;
  123360. }
  123361. }
  123362. declare module BABYLON {
  123363. /**
  123364. * Block used to add light in the fragment shader
  123365. */
  123366. export class LightBlock extends NodeMaterialBlock {
  123367. private _lightId;
  123368. /**
  123369. * Gets or sets the light associated with this block
  123370. */
  123371. light: Nullable<Light>;
  123372. /**
  123373. * Create a new LightBlock
  123374. * @param name defines the block name
  123375. */
  123376. constructor(name: string);
  123377. /**
  123378. * Gets the current class name
  123379. * @returns the class name
  123380. */
  123381. getClassName(): string;
  123382. /**
  123383. * Gets the world position input component
  123384. */
  123385. readonly worldPosition: NodeMaterialConnectionPoint;
  123386. /**
  123387. * Gets the world normal input component
  123388. */
  123389. readonly worldNormal: NodeMaterialConnectionPoint;
  123390. /**
  123391. * Gets the camera (or eye) position component
  123392. */
  123393. readonly cameraPosition: NodeMaterialConnectionPoint;
  123394. /**
  123395. * Gets the glossiness component
  123396. */
  123397. readonly glossiness: NodeMaterialConnectionPoint;
  123398. /**
  123399. * Gets the glossinness power component
  123400. */
  123401. readonly glossPower: NodeMaterialConnectionPoint;
  123402. /**
  123403. * Gets the diffuse color component
  123404. */
  123405. readonly diffuseColor: NodeMaterialConnectionPoint;
  123406. /**
  123407. * Gets the specular color component
  123408. */
  123409. readonly specularColor: NodeMaterialConnectionPoint;
  123410. /**
  123411. * Gets the diffuse output component
  123412. */
  123413. readonly diffuseOutput: NodeMaterialConnectionPoint;
  123414. /**
  123415. * Gets the specular output component
  123416. */
  123417. readonly specularOutput: NodeMaterialConnectionPoint;
  123418. autoConfigure(material: NodeMaterial): void;
  123419. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123420. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  123421. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123422. private _injectVertexCode;
  123423. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123424. serialize(): any;
  123425. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123426. }
  123427. }
  123428. declare module BABYLON {
  123429. /**
  123430. * Block used to multiply 2 values
  123431. */
  123432. export class MultiplyBlock extends NodeMaterialBlock {
  123433. /**
  123434. * Creates a new MultiplyBlock
  123435. * @param name defines the block name
  123436. */
  123437. constructor(name: string);
  123438. /**
  123439. * Gets the current class name
  123440. * @returns the class name
  123441. */
  123442. getClassName(): string;
  123443. /**
  123444. * Gets the left operand input component
  123445. */
  123446. readonly left: NodeMaterialConnectionPoint;
  123447. /**
  123448. * Gets the right operand input component
  123449. */
  123450. readonly right: NodeMaterialConnectionPoint;
  123451. /**
  123452. * Gets the output component
  123453. */
  123454. readonly output: NodeMaterialConnectionPoint;
  123455. protected _buildBlock(state: NodeMaterialBuildState): this;
  123456. }
  123457. }
  123458. declare module BABYLON {
  123459. /**
  123460. * Block used to add 2 vectors
  123461. */
  123462. export class AddBlock extends NodeMaterialBlock {
  123463. /**
  123464. * Creates a new AddBlock
  123465. * @param name defines the block name
  123466. */
  123467. constructor(name: string);
  123468. /**
  123469. * Gets the current class name
  123470. * @returns the class name
  123471. */
  123472. getClassName(): string;
  123473. /**
  123474. * Gets the left operand input component
  123475. */
  123476. readonly left: NodeMaterialConnectionPoint;
  123477. /**
  123478. * Gets the right operand input component
  123479. */
  123480. readonly right: NodeMaterialConnectionPoint;
  123481. /**
  123482. * Gets the output component
  123483. */
  123484. readonly output: NodeMaterialConnectionPoint;
  123485. protected _buildBlock(state: NodeMaterialBuildState): this;
  123486. }
  123487. }
  123488. declare module BABYLON {
  123489. /**
  123490. * Block used to scale a vector by a float
  123491. */
  123492. export class ScaleBlock extends NodeMaterialBlock {
  123493. /**
  123494. * Creates a new ScaleBlock
  123495. * @param name defines the block name
  123496. */
  123497. constructor(name: string);
  123498. /**
  123499. * Gets the current class name
  123500. * @returns the class name
  123501. */
  123502. getClassName(): string;
  123503. /**
  123504. * Gets the input component
  123505. */
  123506. readonly input: NodeMaterialConnectionPoint;
  123507. /**
  123508. * Gets the factor input component
  123509. */
  123510. readonly factor: NodeMaterialConnectionPoint;
  123511. /**
  123512. * Gets the output component
  123513. */
  123514. readonly output: NodeMaterialConnectionPoint;
  123515. protected _buildBlock(state: NodeMaterialBuildState): this;
  123516. }
  123517. }
  123518. declare module BABYLON {
  123519. /**
  123520. * Block used to clamp a float
  123521. */
  123522. export class ClampBlock extends NodeMaterialBlock {
  123523. /** Gets or sets the minimum range */
  123524. minimum: number;
  123525. /** Gets or sets the maximum range */
  123526. maximum: number;
  123527. /**
  123528. * Creates a new ClampBlock
  123529. * @param name defines the block name
  123530. */
  123531. constructor(name: string);
  123532. /**
  123533. * Gets the current class name
  123534. * @returns the class name
  123535. */
  123536. getClassName(): string;
  123537. /**
  123538. * Gets the value input component
  123539. */
  123540. readonly value: NodeMaterialConnectionPoint;
  123541. /**
  123542. * Gets the output component
  123543. */
  123544. readonly output: NodeMaterialConnectionPoint;
  123545. protected _buildBlock(state: NodeMaterialBuildState): this;
  123546. protected _dumpPropertiesCode(): string;
  123547. serialize(): any;
  123548. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123549. }
  123550. }
  123551. declare module BABYLON {
  123552. /**
  123553. * Block used to apply a cross product between 2 vectors
  123554. */
  123555. export class CrossBlock extends NodeMaterialBlock {
  123556. /**
  123557. * Creates a new CrossBlock
  123558. * @param name defines the block name
  123559. */
  123560. constructor(name: string);
  123561. /**
  123562. * Gets the current class name
  123563. * @returns the class name
  123564. */
  123565. getClassName(): string;
  123566. /**
  123567. * Gets the left operand input component
  123568. */
  123569. readonly left: NodeMaterialConnectionPoint;
  123570. /**
  123571. * Gets the right operand input component
  123572. */
  123573. readonly right: NodeMaterialConnectionPoint;
  123574. /**
  123575. * Gets the output component
  123576. */
  123577. readonly output: NodeMaterialConnectionPoint;
  123578. protected _buildBlock(state: NodeMaterialBuildState): this;
  123579. }
  123580. }
  123581. declare module BABYLON {
  123582. /**
  123583. * Block used to apply a dot product between 2 vectors
  123584. */
  123585. export class DotBlock extends NodeMaterialBlock {
  123586. /**
  123587. * Creates a new DotBlock
  123588. * @param name defines the block name
  123589. */
  123590. constructor(name: string);
  123591. /**
  123592. * Gets the current class name
  123593. * @returns the class name
  123594. */
  123595. getClassName(): string;
  123596. /**
  123597. * Gets the left operand input component
  123598. */
  123599. readonly left: NodeMaterialConnectionPoint;
  123600. /**
  123601. * Gets the right operand input component
  123602. */
  123603. readonly right: NodeMaterialConnectionPoint;
  123604. /**
  123605. * Gets the output component
  123606. */
  123607. readonly output: NodeMaterialConnectionPoint;
  123608. protected _buildBlock(state: NodeMaterialBuildState): this;
  123609. }
  123610. }
  123611. declare module BABYLON {
  123612. /**
  123613. * Block used to remap a float from a range to a new one
  123614. */
  123615. export class RemapBlock extends NodeMaterialBlock {
  123616. /**
  123617. * Gets or sets the source range
  123618. */
  123619. sourceRange: Vector2;
  123620. /**
  123621. * Gets or sets the target range
  123622. */
  123623. targetRange: Vector2;
  123624. /**
  123625. * Creates a new RemapBlock
  123626. * @param name defines the block name
  123627. */
  123628. constructor(name: string);
  123629. /**
  123630. * Gets the current class name
  123631. * @returns the class name
  123632. */
  123633. getClassName(): string;
  123634. /**
  123635. * Gets the input component
  123636. */
  123637. readonly input: NodeMaterialConnectionPoint;
  123638. /**
  123639. * Gets the source min input component
  123640. */
  123641. readonly sourceMin: NodeMaterialConnectionPoint;
  123642. /**
  123643. * Gets the source max input component
  123644. */
  123645. readonly sourceMax: NodeMaterialConnectionPoint;
  123646. /**
  123647. * Gets the target min input component
  123648. */
  123649. readonly targetMin: NodeMaterialConnectionPoint;
  123650. /**
  123651. * Gets the target max input component
  123652. */
  123653. readonly targetMax: NodeMaterialConnectionPoint;
  123654. /**
  123655. * Gets the output component
  123656. */
  123657. readonly output: NodeMaterialConnectionPoint;
  123658. protected _buildBlock(state: NodeMaterialBuildState): this;
  123659. protected _dumpPropertiesCode(): string;
  123660. serialize(): any;
  123661. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123662. }
  123663. }
  123664. declare module BABYLON {
  123665. /**
  123666. * Block used to normalize a vector
  123667. */
  123668. export class NormalizeBlock extends NodeMaterialBlock {
  123669. /**
  123670. * Creates a new NormalizeBlock
  123671. * @param name defines the block name
  123672. */
  123673. constructor(name: string);
  123674. /**
  123675. * Gets the current class name
  123676. * @returns the class name
  123677. */
  123678. getClassName(): string;
  123679. /**
  123680. * Gets the input component
  123681. */
  123682. readonly input: NodeMaterialConnectionPoint;
  123683. /**
  123684. * Gets the output component
  123685. */
  123686. readonly output: NodeMaterialConnectionPoint;
  123687. protected _buildBlock(state: NodeMaterialBuildState): this;
  123688. }
  123689. }
  123690. declare module BABYLON {
  123691. /**
  123692. * Operations supported by the Trigonometry block
  123693. */
  123694. export enum TrigonometryBlockOperations {
  123695. /** Cos */
  123696. Cos = 0,
  123697. /** Sin */
  123698. Sin = 1,
  123699. /** Abs */
  123700. Abs = 2,
  123701. /** Exp */
  123702. Exp = 3,
  123703. /** Exp2 */
  123704. Exp2 = 4,
  123705. /** Round */
  123706. Round = 5,
  123707. /** Floor */
  123708. Floor = 6,
  123709. /** Ceiling */
  123710. Ceiling = 7,
  123711. /** Square root */
  123712. Sqrt = 8,
  123713. /** Log */
  123714. Log = 9,
  123715. /** Tangent */
  123716. Tan = 10,
  123717. /** Arc tangent */
  123718. ArcTan = 11,
  123719. /** Arc cosinus */
  123720. ArcCos = 12,
  123721. /** Arc sinus */
  123722. ArcSin = 13,
  123723. /** Fraction */
  123724. Fract = 14,
  123725. /** Sign */
  123726. Sign = 15,
  123727. /** To radians (from degrees) */
  123728. Radians = 16,
  123729. /** To degrees (from radians) */
  123730. Degrees = 17
  123731. }
  123732. /**
  123733. * Block used to apply trigonometry operation to floats
  123734. */
  123735. export class TrigonometryBlock extends NodeMaterialBlock {
  123736. /**
  123737. * Gets or sets the operation applied by the block
  123738. */
  123739. operation: TrigonometryBlockOperations;
  123740. /**
  123741. * Creates a new TrigonometryBlock
  123742. * @param name defines the block name
  123743. */
  123744. constructor(name: string);
  123745. /**
  123746. * Gets the current class name
  123747. * @returns the class name
  123748. */
  123749. getClassName(): string;
  123750. /**
  123751. * Gets the input component
  123752. */
  123753. readonly input: NodeMaterialConnectionPoint;
  123754. /**
  123755. * Gets the output component
  123756. */
  123757. readonly output: NodeMaterialConnectionPoint;
  123758. protected _buildBlock(state: NodeMaterialBuildState): this;
  123759. serialize(): any;
  123760. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123761. protected _dumpPropertiesCode(): string;
  123762. }
  123763. }
  123764. declare module BABYLON {
  123765. /**
  123766. * Block used to create a Color3/4 out of individual inputs (one for each component)
  123767. */
  123768. export class ColorMergerBlock extends NodeMaterialBlock {
  123769. /**
  123770. * Create a new ColorMergerBlock
  123771. * @param name defines the block name
  123772. */
  123773. constructor(name: string);
  123774. /**
  123775. * Gets the current class name
  123776. * @returns the class name
  123777. */
  123778. getClassName(): string;
  123779. /**
  123780. * Gets the r component (input)
  123781. */
  123782. readonly r: NodeMaterialConnectionPoint;
  123783. /**
  123784. * Gets the g component (input)
  123785. */
  123786. readonly g: NodeMaterialConnectionPoint;
  123787. /**
  123788. * Gets the b component (input)
  123789. */
  123790. readonly b: NodeMaterialConnectionPoint;
  123791. /**
  123792. * Gets the a component (input)
  123793. */
  123794. readonly a: NodeMaterialConnectionPoint;
  123795. /**
  123796. * Gets the rgba component (output)
  123797. */
  123798. readonly rgba: NodeMaterialConnectionPoint;
  123799. /**
  123800. * Gets the rgb component (output)
  123801. */
  123802. readonly rgb: NodeMaterialConnectionPoint;
  123803. protected _buildBlock(state: NodeMaterialBuildState): this;
  123804. }
  123805. }
  123806. declare module BABYLON {
  123807. /**
  123808. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  123809. */
  123810. export class VectorMergerBlock extends NodeMaterialBlock {
  123811. /**
  123812. * Create a new VectorMergerBlock
  123813. * @param name defines the block name
  123814. */
  123815. constructor(name: string);
  123816. /**
  123817. * Gets the current class name
  123818. * @returns the class name
  123819. */
  123820. getClassName(): string;
  123821. /**
  123822. * Gets the x component (input)
  123823. */
  123824. readonly x: NodeMaterialConnectionPoint;
  123825. /**
  123826. * Gets the y component (input)
  123827. */
  123828. readonly y: NodeMaterialConnectionPoint;
  123829. /**
  123830. * Gets the z component (input)
  123831. */
  123832. readonly z: NodeMaterialConnectionPoint;
  123833. /**
  123834. * Gets the w component (input)
  123835. */
  123836. readonly w: NodeMaterialConnectionPoint;
  123837. /**
  123838. * Gets the xyzw component (output)
  123839. */
  123840. readonly xyzw: NodeMaterialConnectionPoint;
  123841. /**
  123842. * Gets the xyz component (output)
  123843. */
  123844. readonly xyz: NodeMaterialConnectionPoint;
  123845. /**
  123846. * Gets the xy component (output)
  123847. */
  123848. readonly xy: NodeMaterialConnectionPoint;
  123849. protected _buildBlock(state: NodeMaterialBuildState): this;
  123850. }
  123851. }
  123852. declare module BABYLON {
  123853. /**
  123854. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  123855. */
  123856. export class ColorSplitterBlock extends NodeMaterialBlock {
  123857. /**
  123858. * Create a new ColorSplitterBlock
  123859. * @param name defines the block name
  123860. */
  123861. constructor(name: string);
  123862. /**
  123863. * Gets the current class name
  123864. * @returns the class name
  123865. */
  123866. getClassName(): string;
  123867. /**
  123868. * Gets the rgba component (input)
  123869. */
  123870. readonly rgba: NodeMaterialConnectionPoint;
  123871. /**
  123872. * Gets the rgb component (input)
  123873. */
  123874. readonly rgbIn: NodeMaterialConnectionPoint;
  123875. /**
  123876. * Gets the rgb component (output)
  123877. */
  123878. readonly rgbOut: NodeMaterialConnectionPoint;
  123879. /**
  123880. * Gets the r component (output)
  123881. */
  123882. readonly r: NodeMaterialConnectionPoint;
  123883. /**
  123884. * Gets the g component (output)
  123885. */
  123886. readonly g: NodeMaterialConnectionPoint;
  123887. /**
  123888. * Gets the b component (output)
  123889. */
  123890. readonly b: NodeMaterialConnectionPoint;
  123891. /**
  123892. * Gets the a component (output)
  123893. */
  123894. readonly a: NodeMaterialConnectionPoint;
  123895. protected _inputRename(name: string): string;
  123896. protected _outputRename(name: string): string;
  123897. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123898. }
  123899. }
  123900. declare module BABYLON {
  123901. /**
  123902. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  123903. */
  123904. export class VectorSplitterBlock extends NodeMaterialBlock {
  123905. /**
  123906. * Create a new VectorSplitterBlock
  123907. * @param name defines the block name
  123908. */
  123909. constructor(name: string);
  123910. /**
  123911. * Gets the current class name
  123912. * @returns the class name
  123913. */
  123914. getClassName(): string;
  123915. /**
  123916. * Gets the xyzw component (input)
  123917. */
  123918. readonly xyzw: NodeMaterialConnectionPoint;
  123919. /**
  123920. * Gets the xyz component (input)
  123921. */
  123922. readonly xyzIn: NodeMaterialConnectionPoint;
  123923. /**
  123924. * Gets the xy component (input)
  123925. */
  123926. readonly xyIn: NodeMaterialConnectionPoint;
  123927. /**
  123928. * Gets the xyz component (output)
  123929. */
  123930. readonly xyzOut: NodeMaterialConnectionPoint;
  123931. /**
  123932. * Gets the xy component (output)
  123933. */
  123934. readonly xyOut: NodeMaterialConnectionPoint;
  123935. /**
  123936. * Gets the x component (output)
  123937. */
  123938. readonly x: NodeMaterialConnectionPoint;
  123939. /**
  123940. * Gets the y component (output)
  123941. */
  123942. readonly y: NodeMaterialConnectionPoint;
  123943. /**
  123944. * Gets the z component (output)
  123945. */
  123946. readonly z: NodeMaterialConnectionPoint;
  123947. /**
  123948. * Gets the w component (output)
  123949. */
  123950. readonly w: NodeMaterialConnectionPoint;
  123951. protected _inputRename(name: string): string;
  123952. protected _outputRename(name: string): string;
  123953. protected _buildBlock(state: NodeMaterialBuildState): this;
  123954. }
  123955. }
  123956. declare module BABYLON {
  123957. /**
  123958. * Block used to lerp between 2 values
  123959. */
  123960. export class LerpBlock extends NodeMaterialBlock {
  123961. /**
  123962. * Creates a new LerpBlock
  123963. * @param name defines the block name
  123964. */
  123965. constructor(name: string);
  123966. /**
  123967. * Gets the current class name
  123968. * @returns the class name
  123969. */
  123970. getClassName(): string;
  123971. /**
  123972. * Gets the left operand input component
  123973. */
  123974. readonly left: NodeMaterialConnectionPoint;
  123975. /**
  123976. * Gets the right operand input component
  123977. */
  123978. readonly right: NodeMaterialConnectionPoint;
  123979. /**
  123980. * Gets the gradient operand input component
  123981. */
  123982. readonly gradient: NodeMaterialConnectionPoint;
  123983. /**
  123984. * Gets the output component
  123985. */
  123986. readonly output: NodeMaterialConnectionPoint;
  123987. protected _buildBlock(state: NodeMaterialBuildState): this;
  123988. }
  123989. }
  123990. declare module BABYLON {
  123991. /**
  123992. * Block used to divide 2 vectors
  123993. */
  123994. export class DivideBlock extends NodeMaterialBlock {
  123995. /**
  123996. * Creates a new DivideBlock
  123997. * @param name defines the block name
  123998. */
  123999. constructor(name: string);
  124000. /**
  124001. * Gets the current class name
  124002. * @returns the class name
  124003. */
  124004. getClassName(): string;
  124005. /**
  124006. * Gets the left operand input component
  124007. */
  124008. readonly left: NodeMaterialConnectionPoint;
  124009. /**
  124010. * Gets the right operand input component
  124011. */
  124012. readonly right: NodeMaterialConnectionPoint;
  124013. /**
  124014. * Gets the output component
  124015. */
  124016. readonly output: NodeMaterialConnectionPoint;
  124017. protected _buildBlock(state: NodeMaterialBuildState): this;
  124018. }
  124019. }
  124020. declare module BABYLON {
  124021. /**
  124022. * Block used to subtract 2 vectors
  124023. */
  124024. export class SubtractBlock extends NodeMaterialBlock {
  124025. /**
  124026. * Creates a new SubtractBlock
  124027. * @param name defines the block name
  124028. */
  124029. constructor(name: string);
  124030. /**
  124031. * Gets the current class name
  124032. * @returns the class name
  124033. */
  124034. getClassName(): string;
  124035. /**
  124036. * Gets the left operand input component
  124037. */
  124038. readonly left: NodeMaterialConnectionPoint;
  124039. /**
  124040. * Gets the right operand input component
  124041. */
  124042. readonly right: NodeMaterialConnectionPoint;
  124043. /**
  124044. * Gets the output component
  124045. */
  124046. readonly output: NodeMaterialConnectionPoint;
  124047. protected _buildBlock(state: NodeMaterialBuildState): this;
  124048. }
  124049. }
  124050. declare module BABYLON {
  124051. /**
  124052. * Block used to step a value
  124053. */
  124054. export class StepBlock extends NodeMaterialBlock {
  124055. /**
  124056. * Creates a new StepBlock
  124057. * @param name defines the block name
  124058. */
  124059. constructor(name: string);
  124060. /**
  124061. * Gets the current class name
  124062. * @returns the class name
  124063. */
  124064. getClassName(): string;
  124065. /**
  124066. * Gets the value operand input component
  124067. */
  124068. readonly value: NodeMaterialConnectionPoint;
  124069. /**
  124070. * Gets the edge operand input component
  124071. */
  124072. readonly edge: NodeMaterialConnectionPoint;
  124073. /**
  124074. * Gets the output component
  124075. */
  124076. readonly output: NodeMaterialConnectionPoint;
  124077. protected _buildBlock(state: NodeMaterialBuildState): this;
  124078. }
  124079. }
  124080. declare module BABYLON {
  124081. /**
  124082. * Block used to get the opposite (1 - x) of a value
  124083. */
  124084. export class OneMinusBlock extends NodeMaterialBlock {
  124085. /**
  124086. * Creates a new OneMinusBlock
  124087. * @param name defines the block name
  124088. */
  124089. constructor(name: string);
  124090. /**
  124091. * Gets the current class name
  124092. * @returns the class name
  124093. */
  124094. getClassName(): string;
  124095. /**
  124096. * Gets the input component
  124097. */
  124098. readonly input: NodeMaterialConnectionPoint;
  124099. /**
  124100. * Gets the output component
  124101. */
  124102. readonly output: NodeMaterialConnectionPoint;
  124103. protected _buildBlock(state: NodeMaterialBuildState): this;
  124104. }
  124105. }
  124106. declare module BABYLON {
  124107. /**
  124108. * Block used to get the view direction
  124109. */
  124110. export class ViewDirectionBlock extends NodeMaterialBlock {
  124111. /**
  124112. * Creates a new ViewDirectionBlock
  124113. * @param name defines the block name
  124114. */
  124115. constructor(name: string);
  124116. /**
  124117. * Gets the current class name
  124118. * @returns the class name
  124119. */
  124120. getClassName(): string;
  124121. /**
  124122. * Gets the world position component
  124123. */
  124124. readonly worldPosition: NodeMaterialConnectionPoint;
  124125. /**
  124126. * Gets the camera position component
  124127. */
  124128. readonly cameraPosition: NodeMaterialConnectionPoint;
  124129. /**
  124130. * Gets the output component
  124131. */
  124132. readonly output: NodeMaterialConnectionPoint;
  124133. autoConfigure(material: NodeMaterial): void;
  124134. protected _buildBlock(state: NodeMaterialBuildState): this;
  124135. }
  124136. }
  124137. declare module BABYLON {
  124138. /**
  124139. * Block used to compute fresnel value
  124140. */
  124141. export class FresnelBlock extends NodeMaterialBlock {
  124142. /**
  124143. * Create a new FresnelBlock
  124144. * @param name defines the block name
  124145. */
  124146. constructor(name: string);
  124147. /**
  124148. * Gets the current class name
  124149. * @returns the class name
  124150. */
  124151. getClassName(): string;
  124152. /**
  124153. * Gets the world normal input component
  124154. */
  124155. readonly worldNormal: NodeMaterialConnectionPoint;
  124156. /**
  124157. * Gets the view direction input component
  124158. */
  124159. readonly viewDirection: NodeMaterialConnectionPoint;
  124160. /**
  124161. * Gets the bias input component
  124162. */
  124163. readonly bias: NodeMaterialConnectionPoint;
  124164. /**
  124165. * Gets the camera (or eye) position component
  124166. */
  124167. readonly power: NodeMaterialConnectionPoint;
  124168. /**
  124169. * Gets the fresnel output component
  124170. */
  124171. readonly fresnel: NodeMaterialConnectionPoint;
  124172. autoConfigure(material: NodeMaterial): void;
  124173. protected _buildBlock(state: NodeMaterialBuildState): this;
  124174. }
  124175. }
  124176. declare module BABYLON {
  124177. /**
  124178. * Block used to get the max of 2 values
  124179. */
  124180. export class MaxBlock extends NodeMaterialBlock {
  124181. /**
  124182. * Creates a new MaxBlock
  124183. * @param name defines the block name
  124184. */
  124185. constructor(name: string);
  124186. /**
  124187. * Gets the current class name
  124188. * @returns the class name
  124189. */
  124190. getClassName(): string;
  124191. /**
  124192. * Gets the left operand input component
  124193. */
  124194. readonly left: NodeMaterialConnectionPoint;
  124195. /**
  124196. * Gets the right operand input component
  124197. */
  124198. readonly right: NodeMaterialConnectionPoint;
  124199. /**
  124200. * Gets the output component
  124201. */
  124202. readonly output: NodeMaterialConnectionPoint;
  124203. protected _buildBlock(state: NodeMaterialBuildState): this;
  124204. }
  124205. }
  124206. declare module BABYLON {
  124207. /**
  124208. * Block used to get the min of 2 values
  124209. */
  124210. export class MinBlock extends NodeMaterialBlock {
  124211. /**
  124212. * Creates a new MinBlock
  124213. * @param name defines the block name
  124214. */
  124215. constructor(name: string);
  124216. /**
  124217. * Gets the current class name
  124218. * @returns the class name
  124219. */
  124220. getClassName(): string;
  124221. /**
  124222. * Gets the left operand input component
  124223. */
  124224. readonly left: NodeMaterialConnectionPoint;
  124225. /**
  124226. * Gets the right operand input component
  124227. */
  124228. readonly right: NodeMaterialConnectionPoint;
  124229. /**
  124230. * Gets the output component
  124231. */
  124232. readonly output: NodeMaterialConnectionPoint;
  124233. protected _buildBlock(state: NodeMaterialBuildState): this;
  124234. }
  124235. }
  124236. declare module BABYLON {
  124237. /**
  124238. * Block used to get the distance between 2 values
  124239. */
  124240. export class DistanceBlock extends NodeMaterialBlock {
  124241. /**
  124242. * Creates a new DistanceBlock
  124243. * @param name defines the block name
  124244. */
  124245. constructor(name: string);
  124246. /**
  124247. * Gets the current class name
  124248. * @returns the class name
  124249. */
  124250. getClassName(): string;
  124251. /**
  124252. * Gets the left operand input component
  124253. */
  124254. readonly left: NodeMaterialConnectionPoint;
  124255. /**
  124256. * Gets the right operand input component
  124257. */
  124258. readonly right: NodeMaterialConnectionPoint;
  124259. /**
  124260. * Gets the output component
  124261. */
  124262. readonly output: NodeMaterialConnectionPoint;
  124263. protected _buildBlock(state: NodeMaterialBuildState): this;
  124264. }
  124265. }
  124266. declare module BABYLON {
  124267. /**
  124268. * Block used to get the length of a vector
  124269. */
  124270. export class LengthBlock extends NodeMaterialBlock {
  124271. /**
  124272. * Creates a new LengthBlock
  124273. * @param name defines the block name
  124274. */
  124275. constructor(name: string);
  124276. /**
  124277. * Gets the current class name
  124278. * @returns the class name
  124279. */
  124280. getClassName(): string;
  124281. /**
  124282. * Gets the value input component
  124283. */
  124284. readonly value: NodeMaterialConnectionPoint;
  124285. /**
  124286. * Gets the output component
  124287. */
  124288. readonly output: NodeMaterialConnectionPoint;
  124289. protected _buildBlock(state: NodeMaterialBuildState): this;
  124290. }
  124291. }
  124292. declare module BABYLON {
  124293. /**
  124294. * Block used to get negative version of a value (i.e. x * -1)
  124295. */
  124296. export class NegateBlock extends NodeMaterialBlock {
  124297. /**
  124298. * Creates a new NegateBlock
  124299. * @param name defines the block name
  124300. */
  124301. constructor(name: string);
  124302. /**
  124303. * Gets the current class name
  124304. * @returns the class name
  124305. */
  124306. getClassName(): string;
  124307. /**
  124308. * Gets the value input component
  124309. */
  124310. readonly value: NodeMaterialConnectionPoint;
  124311. /**
  124312. * Gets the output component
  124313. */
  124314. readonly output: NodeMaterialConnectionPoint;
  124315. protected _buildBlock(state: NodeMaterialBuildState): this;
  124316. }
  124317. }
  124318. declare module BABYLON {
  124319. /**
  124320. * Block used to get the value of the first parameter raised to the power of the second
  124321. */
  124322. export class PowBlock extends NodeMaterialBlock {
  124323. /**
  124324. * Creates a new PowBlock
  124325. * @param name defines the block name
  124326. */
  124327. constructor(name: string);
  124328. /**
  124329. * Gets the current class name
  124330. * @returns the class name
  124331. */
  124332. getClassName(): string;
  124333. /**
  124334. * Gets the value operand input component
  124335. */
  124336. readonly value: NodeMaterialConnectionPoint;
  124337. /**
  124338. * Gets the power operand input component
  124339. */
  124340. readonly power: NodeMaterialConnectionPoint;
  124341. /**
  124342. * Gets the output component
  124343. */
  124344. readonly output: NodeMaterialConnectionPoint;
  124345. protected _buildBlock(state: NodeMaterialBuildState): this;
  124346. }
  124347. }
  124348. declare module BABYLON {
  124349. /**
  124350. * Block used to get a random number
  124351. */
  124352. export class RandomNumberBlock extends NodeMaterialBlock {
  124353. /**
  124354. * Creates a new RandomNumberBlock
  124355. * @param name defines the block name
  124356. */
  124357. constructor(name: string);
  124358. /**
  124359. * Gets the current class name
  124360. * @returns the class name
  124361. */
  124362. getClassName(): string;
  124363. /**
  124364. * Gets the seed input component
  124365. */
  124366. readonly seed: NodeMaterialConnectionPoint;
  124367. /**
  124368. * Gets the output component
  124369. */
  124370. readonly output: NodeMaterialConnectionPoint;
  124371. protected _buildBlock(state: NodeMaterialBuildState): this;
  124372. }
  124373. }
  124374. declare module BABYLON {
  124375. /**
  124376. * Block used to compute arc tangent of 2 values
  124377. */
  124378. export class ArcTan2Block extends NodeMaterialBlock {
  124379. /**
  124380. * Creates a new ArcTan2Block
  124381. * @param name defines the block name
  124382. */
  124383. constructor(name: string);
  124384. /**
  124385. * Gets the current class name
  124386. * @returns the class name
  124387. */
  124388. getClassName(): string;
  124389. /**
  124390. * Gets the x operand input component
  124391. */
  124392. readonly x: NodeMaterialConnectionPoint;
  124393. /**
  124394. * Gets the y operand input component
  124395. */
  124396. readonly y: NodeMaterialConnectionPoint;
  124397. /**
  124398. * Gets the output component
  124399. */
  124400. readonly output: NodeMaterialConnectionPoint;
  124401. protected _buildBlock(state: NodeMaterialBuildState): this;
  124402. }
  124403. }
  124404. declare module BABYLON {
  124405. /**
  124406. * Block used to smooth step a value
  124407. */
  124408. export class SmoothStepBlock extends NodeMaterialBlock {
  124409. /**
  124410. * Creates a new SmoothStepBlock
  124411. * @param name defines the block name
  124412. */
  124413. constructor(name: string);
  124414. /**
  124415. * Gets the current class name
  124416. * @returns the class name
  124417. */
  124418. getClassName(): string;
  124419. /**
  124420. * Gets the value operand input component
  124421. */
  124422. readonly value: NodeMaterialConnectionPoint;
  124423. /**
  124424. * Gets the first edge operand input component
  124425. */
  124426. readonly edge0: NodeMaterialConnectionPoint;
  124427. /**
  124428. * Gets the second edge operand input component
  124429. */
  124430. readonly edge1: NodeMaterialConnectionPoint;
  124431. /**
  124432. * Gets the output component
  124433. */
  124434. readonly output: NodeMaterialConnectionPoint;
  124435. protected _buildBlock(state: NodeMaterialBuildState): this;
  124436. }
  124437. }
  124438. declare module BABYLON {
  124439. /**
  124440. * Block used to get the reciprocal (1 / x) of a value
  124441. */
  124442. export class ReciprocalBlock extends NodeMaterialBlock {
  124443. /**
  124444. * Creates a new ReciprocalBlock
  124445. * @param name defines the block name
  124446. */
  124447. constructor(name: string);
  124448. /**
  124449. * Gets the current class name
  124450. * @returns the class name
  124451. */
  124452. getClassName(): string;
  124453. /**
  124454. * Gets the input component
  124455. */
  124456. readonly input: NodeMaterialConnectionPoint;
  124457. /**
  124458. * Gets the output component
  124459. */
  124460. readonly output: NodeMaterialConnectionPoint;
  124461. protected _buildBlock(state: NodeMaterialBuildState): this;
  124462. }
  124463. }
  124464. declare module BABYLON {
  124465. /**
  124466. * Block used to replace a color by another one
  124467. */
  124468. export class ReplaceColorBlock extends NodeMaterialBlock {
  124469. /**
  124470. * Creates a new ReplaceColorBlock
  124471. * @param name defines the block name
  124472. */
  124473. constructor(name: string);
  124474. /**
  124475. * Gets the current class name
  124476. * @returns the class name
  124477. */
  124478. getClassName(): string;
  124479. /**
  124480. * Gets the value input component
  124481. */
  124482. readonly value: NodeMaterialConnectionPoint;
  124483. /**
  124484. * Gets the reference input component
  124485. */
  124486. readonly reference: NodeMaterialConnectionPoint;
  124487. /**
  124488. * Gets the distance input component
  124489. */
  124490. readonly distance: NodeMaterialConnectionPoint;
  124491. /**
  124492. * Gets the replacement input component
  124493. */
  124494. readonly replacement: NodeMaterialConnectionPoint;
  124495. /**
  124496. * Gets the output component
  124497. */
  124498. readonly output: NodeMaterialConnectionPoint;
  124499. protected _buildBlock(state: NodeMaterialBuildState): this;
  124500. }
  124501. }
  124502. declare module BABYLON {
  124503. /**
  124504. * Block used to posterize a value
  124505. * @see https://en.wikipedia.org/wiki/Posterization
  124506. */
  124507. export class PosterizeBlock extends NodeMaterialBlock {
  124508. /**
  124509. * Creates a new PosterizeBlock
  124510. * @param name defines the block name
  124511. */
  124512. constructor(name: string);
  124513. /**
  124514. * Gets the current class name
  124515. * @returns the class name
  124516. */
  124517. getClassName(): string;
  124518. /**
  124519. * Gets the value input component
  124520. */
  124521. readonly value: NodeMaterialConnectionPoint;
  124522. /**
  124523. * Gets the steps input component
  124524. */
  124525. readonly steps: NodeMaterialConnectionPoint;
  124526. /**
  124527. * Gets the output component
  124528. */
  124529. readonly output: NodeMaterialConnectionPoint;
  124530. protected _buildBlock(state: NodeMaterialBuildState): this;
  124531. }
  124532. }
  124533. declare module BABYLON {
  124534. /**
  124535. * Operations supported by the Wave block
  124536. */
  124537. export enum WaveBlockKind {
  124538. /** SawTooth */
  124539. SawTooth = 0,
  124540. /** Square */
  124541. Square = 1,
  124542. /** Triangle */
  124543. Triangle = 2
  124544. }
  124545. /**
  124546. * Block used to apply wave operation to floats
  124547. */
  124548. export class WaveBlock extends NodeMaterialBlock {
  124549. /**
  124550. * Gets or sets the kibnd of wave to be applied by the block
  124551. */
  124552. kind: WaveBlockKind;
  124553. /**
  124554. * Creates a new WaveBlock
  124555. * @param name defines the block name
  124556. */
  124557. constructor(name: string);
  124558. /**
  124559. * Gets the current class name
  124560. * @returns the class name
  124561. */
  124562. getClassName(): string;
  124563. /**
  124564. * Gets the input component
  124565. */
  124566. readonly input: NodeMaterialConnectionPoint;
  124567. /**
  124568. * Gets the output component
  124569. */
  124570. readonly output: NodeMaterialConnectionPoint;
  124571. protected _buildBlock(state: NodeMaterialBuildState): this;
  124572. serialize(): any;
  124573. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124574. }
  124575. }
  124576. declare module BABYLON {
  124577. /**
  124578. * Class used to store a color step for the GradientBlock
  124579. */
  124580. export class GradientBlockColorStep {
  124581. /**
  124582. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  124583. */
  124584. step: number;
  124585. /**
  124586. * Gets or sets the color associated with this step
  124587. */
  124588. color: Color3;
  124589. /**
  124590. * Creates a new GradientBlockColorStep
  124591. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  124592. * @param color defines the color associated with this step
  124593. */
  124594. constructor(
  124595. /**
  124596. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  124597. */
  124598. step: number,
  124599. /**
  124600. * Gets or sets the color associated with this step
  124601. */
  124602. color: Color3);
  124603. }
  124604. /**
  124605. * Block used to return a color from a gradient based on an input value between 0 and 1
  124606. */
  124607. export class GradientBlock extends NodeMaterialBlock {
  124608. /**
  124609. * Gets or sets the list of color steps
  124610. */
  124611. colorSteps: GradientBlockColorStep[];
  124612. /**
  124613. * Creates a new GradientBlock
  124614. * @param name defines the block name
  124615. */
  124616. constructor(name: string);
  124617. /**
  124618. * Gets the current class name
  124619. * @returns the class name
  124620. */
  124621. getClassName(): string;
  124622. /**
  124623. * Gets the gradient input component
  124624. */
  124625. readonly gradient: NodeMaterialConnectionPoint;
  124626. /**
  124627. * Gets the output component
  124628. */
  124629. readonly output: NodeMaterialConnectionPoint;
  124630. private _writeColorConstant;
  124631. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124632. serialize(): any;
  124633. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124634. protected _dumpPropertiesCode(): string;
  124635. }
  124636. }
  124637. declare module BABYLON {
  124638. /**
  124639. * Block used to normalize lerp between 2 values
  124640. */
  124641. export class NLerpBlock extends NodeMaterialBlock {
  124642. /**
  124643. * Creates a new NLerpBlock
  124644. * @param name defines the block name
  124645. */
  124646. constructor(name: string);
  124647. /**
  124648. * Gets the current class name
  124649. * @returns the class name
  124650. */
  124651. getClassName(): string;
  124652. /**
  124653. * Gets the left operand input component
  124654. */
  124655. readonly left: NodeMaterialConnectionPoint;
  124656. /**
  124657. * Gets the right operand input component
  124658. */
  124659. readonly right: NodeMaterialConnectionPoint;
  124660. /**
  124661. * Gets the gradient operand input component
  124662. */
  124663. readonly gradient: NodeMaterialConnectionPoint;
  124664. /**
  124665. * Gets the output component
  124666. */
  124667. readonly output: NodeMaterialConnectionPoint;
  124668. protected _buildBlock(state: NodeMaterialBuildState): this;
  124669. }
  124670. }
  124671. declare module BABYLON {
  124672. /**
  124673. * block used to Generate a Worley Noise 3D Noise Pattern
  124674. */
  124675. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  124676. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  124677. manhattanDistance: boolean;
  124678. /**
  124679. * Creates a new WorleyNoise3DBlock
  124680. * @param name defines the block name
  124681. */
  124682. constructor(name: string);
  124683. /**
  124684. * Gets the current class name
  124685. * @returns the class name
  124686. */
  124687. getClassName(): string;
  124688. /**
  124689. * Gets the position input component
  124690. */
  124691. readonly position: NodeMaterialConnectionPoint;
  124692. /**
  124693. * Gets the jitter input component
  124694. */
  124695. readonly jitter: NodeMaterialConnectionPoint;
  124696. /**
  124697. * Gets the output component
  124698. */
  124699. readonly output: NodeMaterialConnectionPoint;
  124700. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124701. /**
  124702. * Exposes the properties to the UI?
  124703. */
  124704. protected _dumpPropertiesCode(): string;
  124705. /**
  124706. * Exposes the properties to the Seralize?
  124707. */
  124708. serialize(): any;
  124709. /**
  124710. * Exposes the properties to the deseralize?
  124711. */
  124712. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124713. }
  124714. }
  124715. declare module BABYLON {
  124716. /**
  124717. * block used to Generate a Simplex Perlin 3d Noise Pattern
  124718. */
  124719. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  124720. /**
  124721. * Creates a new SimplexPerlin3DBlock
  124722. * @param name defines the block name
  124723. */
  124724. constructor(name: string);
  124725. /**
  124726. * Gets the current class name
  124727. * @returns the class name
  124728. */
  124729. getClassName(): string;
  124730. /**
  124731. * Gets the position operand input component
  124732. */
  124733. readonly position: NodeMaterialConnectionPoint;
  124734. /**
  124735. * Gets the output component
  124736. */
  124737. readonly output: NodeMaterialConnectionPoint;
  124738. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124739. }
  124740. }
  124741. declare module BABYLON {
  124742. /**
  124743. * Block used to blend normals
  124744. */
  124745. export class NormalBlendBlock extends NodeMaterialBlock {
  124746. /**
  124747. * Creates a new NormalBlendBlock
  124748. * @param name defines the block name
  124749. */
  124750. constructor(name: string);
  124751. /**
  124752. * Gets the current class name
  124753. * @returns the class name
  124754. */
  124755. getClassName(): string;
  124756. /**
  124757. * Gets the first input component
  124758. */
  124759. readonly input0: NodeMaterialConnectionPoint;
  124760. /**
  124761. * Gets the second input component
  124762. */
  124763. readonly input1: NodeMaterialConnectionPoint;
  124764. /**
  124765. * Gets the output component
  124766. */
  124767. readonly output: NodeMaterialConnectionPoint;
  124768. protected _buildBlock(state: NodeMaterialBuildState): this;
  124769. }
  124770. }
  124771. declare module BABYLON {
  124772. /**
  124773. * Effect Render Options
  124774. */
  124775. export interface IEffectRendererOptions {
  124776. /**
  124777. * Defines the vertices positions.
  124778. */
  124779. positions?: number[];
  124780. /**
  124781. * Defines the indices.
  124782. */
  124783. indices?: number[];
  124784. }
  124785. /**
  124786. * Helper class to render one or more effects
  124787. */
  124788. export class EffectRenderer {
  124789. private engine;
  124790. private static _DefaultOptions;
  124791. private _vertexBuffers;
  124792. private _indexBuffer;
  124793. private _ringBufferIndex;
  124794. private _ringScreenBuffer;
  124795. private _fullscreenViewport;
  124796. private _getNextFrameBuffer;
  124797. /**
  124798. * Creates an effect renderer
  124799. * @param engine the engine to use for rendering
  124800. * @param options defines the options of the effect renderer
  124801. */
  124802. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  124803. /**
  124804. * Sets the current viewport in normalized coordinates 0-1
  124805. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  124806. */
  124807. setViewport(viewport?: Viewport): void;
  124808. /**
  124809. * Binds the embedded attributes buffer to the effect.
  124810. * @param effect Defines the effect to bind the attributes for
  124811. */
  124812. bindBuffers(effect: Effect): void;
  124813. /**
  124814. * Sets the current effect wrapper to use during draw.
  124815. * The effect needs to be ready before calling this api.
  124816. * This also sets the default full screen position attribute.
  124817. * @param effectWrapper Defines the effect to draw with
  124818. */
  124819. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  124820. /**
  124821. * Draws a full screen quad.
  124822. */
  124823. draw(): void;
  124824. /**
  124825. * renders one or more effects to a specified texture
  124826. * @param effectWrappers list of effects to renderer
  124827. * @param outputTexture texture to draw to, if null it will render to the screen
  124828. */
  124829. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  124830. /**
  124831. * Disposes of the effect renderer
  124832. */
  124833. dispose(): void;
  124834. }
  124835. /**
  124836. * Options to create an EffectWrapper
  124837. */
  124838. interface EffectWrapperCreationOptions {
  124839. /**
  124840. * Engine to use to create the effect
  124841. */
  124842. engine: ThinEngine;
  124843. /**
  124844. * Fragment shader for the effect
  124845. */
  124846. fragmentShader: string;
  124847. /**
  124848. * Vertex shader for the effect
  124849. */
  124850. vertexShader?: string;
  124851. /**
  124852. * Attributes to use in the shader
  124853. */
  124854. attributeNames?: Array<string>;
  124855. /**
  124856. * Uniforms to use in the shader
  124857. */
  124858. uniformNames?: Array<string>;
  124859. /**
  124860. * Texture sampler names to use in the shader
  124861. */
  124862. samplerNames?: Array<string>;
  124863. /**
  124864. * The friendly name of the effect displayed in Spector.
  124865. */
  124866. name?: string;
  124867. }
  124868. /**
  124869. * Wraps an effect to be used for rendering
  124870. */
  124871. export class EffectWrapper {
  124872. /**
  124873. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  124874. */
  124875. onApplyObservable: Observable<{}>;
  124876. /**
  124877. * The underlying effect
  124878. */
  124879. effect: Effect;
  124880. /**
  124881. * Creates an effect to be renderer
  124882. * @param creationOptions options to create the effect
  124883. */
  124884. constructor(creationOptions: EffectWrapperCreationOptions);
  124885. /**
  124886. * Disposes of the effect wrapper
  124887. */
  124888. dispose(): void;
  124889. }
  124890. }
  124891. declare module BABYLON {
  124892. /**
  124893. * Helper class to push actions to a pool of workers.
  124894. */
  124895. export class WorkerPool implements IDisposable {
  124896. private _workerInfos;
  124897. private _pendingActions;
  124898. /**
  124899. * Constructor
  124900. * @param workers Array of workers to use for actions
  124901. */
  124902. constructor(workers: Array<Worker>);
  124903. /**
  124904. * Terminates all workers and clears any pending actions.
  124905. */
  124906. dispose(): void;
  124907. /**
  124908. * Pushes an action to the worker pool. If all the workers are active, the action will be
  124909. * pended until a worker has completed its action.
  124910. * @param action The action to perform. Call onComplete when the action is complete.
  124911. */
  124912. push(action: (worker: Worker, onComplete: () => void) => void): void;
  124913. private _execute;
  124914. }
  124915. }
  124916. declare module BABYLON {
  124917. /**
  124918. * Configuration for Draco compression
  124919. */
  124920. export interface IDracoCompressionConfiguration {
  124921. /**
  124922. * Configuration for the decoder.
  124923. */
  124924. decoder: {
  124925. /**
  124926. * The url to the WebAssembly module.
  124927. */
  124928. wasmUrl?: string;
  124929. /**
  124930. * The url to the WebAssembly binary.
  124931. */
  124932. wasmBinaryUrl?: string;
  124933. /**
  124934. * The url to the fallback JavaScript module.
  124935. */
  124936. fallbackUrl?: string;
  124937. };
  124938. }
  124939. /**
  124940. * Draco compression (https://google.github.io/draco/)
  124941. *
  124942. * This class wraps the Draco module.
  124943. *
  124944. * **Encoder**
  124945. *
  124946. * The encoder is not currently implemented.
  124947. *
  124948. * **Decoder**
  124949. *
  124950. * 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.
  124951. *
  124952. * To update the configuration, use the following code:
  124953. * ```javascript
  124954. * DracoCompression.Configuration = {
  124955. * decoder: {
  124956. * wasmUrl: "<url to the WebAssembly library>",
  124957. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  124958. * fallbackUrl: "<url to the fallback JavaScript library>",
  124959. * }
  124960. * };
  124961. * ```
  124962. *
  124963. * 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.
  124964. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  124965. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  124966. *
  124967. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  124968. * ```javascript
  124969. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  124970. * ```
  124971. *
  124972. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  124973. */
  124974. export class DracoCompression implements IDisposable {
  124975. private _workerPoolPromise?;
  124976. private _decoderModulePromise?;
  124977. /**
  124978. * The configuration. Defaults to the following urls:
  124979. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  124980. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  124981. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  124982. */
  124983. static Configuration: IDracoCompressionConfiguration;
  124984. /**
  124985. * Returns true if the decoder configuration is available.
  124986. */
  124987. static readonly DecoderAvailable: boolean;
  124988. /**
  124989. * Default number of workers to create when creating the draco compression object.
  124990. */
  124991. static DefaultNumWorkers: number;
  124992. private static GetDefaultNumWorkers;
  124993. private static _Default;
  124994. /**
  124995. * Default instance for the draco compression object.
  124996. */
  124997. static readonly Default: DracoCompression;
  124998. /**
  124999. * Constructor
  125000. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  125001. */
  125002. constructor(numWorkers?: number);
  125003. /**
  125004. * Stop all async operations and release resources.
  125005. */
  125006. dispose(): void;
  125007. /**
  125008. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  125009. * @returns a promise that resolves when ready
  125010. */
  125011. whenReadyAsync(): Promise<void>;
  125012. /**
  125013. * Decode Draco compressed mesh data to vertex data.
  125014. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  125015. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  125016. * @returns A promise that resolves with the decoded vertex data
  125017. */
  125018. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  125019. [kind: string]: number;
  125020. }): Promise<VertexData>;
  125021. }
  125022. }
  125023. declare module BABYLON {
  125024. /**
  125025. * Class for building Constructive Solid Geometry
  125026. */
  125027. export class CSG {
  125028. private polygons;
  125029. /**
  125030. * The world matrix
  125031. */
  125032. matrix: Matrix;
  125033. /**
  125034. * Stores the position
  125035. */
  125036. position: Vector3;
  125037. /**
  125038. * Stores the rotation
  125039. */
  125040. rotation: Vector3;
  125041. /**
  125042. * Stores the rotation quaternion
  125043. */
  125044. rotationQuaternion: Nullable<Quaternion>;
  125045. /**
  125046. * Stores the scaling vector
  125047. */
  125048. scaling: Vector3;
  125049. /**
  125050. * Convert the Mesh to CSG
  125051. * @param mesh The Mesh to convert to CSG
  125052. * @returns A new CSG from the Mesh
  125053. */
  125054. static FromMesh(mesh: Mesh): CSG;
  125055. /**
  125056. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  125057. * @param polygons Polygons used to construct a CSG solid
  125058. */
  125059. private static FromPolygons;
  125060. /**
  125061. * Clones, or makes a deep copy, of the CSG
  125062. * @returns A new CSG
  125063. */
  125064. clone(): CSG;
  125065. /**
  125066. * Unions this CSG with another CSG
  125067. * @param csg The CSG to union against this CSG
  125068. * @returns The unioned CSG
  125069. */
  125070. union(csg: CSG): CSG;
  125071. /**
  125072. * Unions this CSG with another CSG in place
  125073. * @param csg The CSG to union against this CSG
  125074. */
  125075. unionInPlace(csg: CSG): void;
  125076. /**
  125077. * Subtracts this CSG with another CSG
  125078. * @param csg The CSG to subtract against this CSG
  125079. * @returns A new CSG
  125080. */
  125081. subtract(csg: CSG): CSG;
  125082. /**
  125083. * Subtracts this CSG with another CSG in place
  125084. * @param csg The CSG to subtact against this CSG
  125085. */
  125086. subtractInPlace(csg: CSG): void;
  125087. /**
  125088. * Intersect this CSG with another CSG
  125089. * @param csg The CSG to intersect against this CSG
  125090. * @returns A new CSG
  125091. */
  125092. intersect(csg: CSG): CSG;
  125093. /**
  125094. * Intersects this CSG with another CSG in place
  125095. * @param csg The CSG to intersect against this CSG
  125096. */
  125097. intersectInPlace(csg: CSG): void;
  125098. /**
  125099. * Return a new CSG solid with solid and empty space switched. This solid is
  125100. * not modified.
  125101. * @returns A new CSG solid with solid and empty space switched
  125102. */
  125103. inverse(): CSG;
  125104. /**
  125105. * Inverses the CSG in place
  125106. */
  125107. inverseInPlace(): void;
  125108. /**
  125109. * This is used to keep meshes transformations so they can be restored
  125110. * when we build back a Babylon Mesh
  125111. * NB : All CSG operations are performed in world coordinates
  125112. * @param csg The CSG to copy the transform attributes from
  125113. * @returns This CSG
  125114. */
  125115. copyTransformAttributes(csg: CSG): CSG;
  125116. /**
  125117. * Build Raw mesh from CSG
  125118. * Coordinates here are in world space
  125119. * @param name The name of the mesh geometry
  125120. * @param scene The Scene
  125121. * @param keepSubMeshes Specifies if the submeshes should be kept
  125122. * @returns A new Mesh
  125123. */
  125124. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  125125. /**
  125126. * Build Mesh from CSG taking material and transforms into account
  125127. * @param name The name of the Mesh
  125128. * @param material The material of the Mesh
  125129. * @param scene The Scene
  125130. * @param keepSubMeshes Specifies if submeshes should be kept
  125131. * @returns The new Mesh
  125132. */
  125133. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  125134. }
  125135. }
  125136. declare module BABYLON {
  125137. /**
  125138. * Class used to create a trail following a mesh
  125139. */
  125140. export class TrailMesh extends Mesh {
  125141. private _generator;
  125142. private _autoStart;
  125143. private _running;
  125144. private _diameter;
  125145. private _length;
  125146. private _sectionPolygonPointsCount;
  125147. private _sectionVectors;
  125148. private _sectionNormalVectors;
  125149. private _beforeRenderObserver;
  125150. /**
  125151. * @constructor
  125152. * @param name The value used by scene.getMeshByName() to do a lookup.
  125153. * @param generator The mesh to generate a trail.
  125154. * @param scene The scene to add this mesh to.
  125155. * @param diameter Diameter of trailing mesh. Default is 1.
  125156. * @param length Length of trailing mesh. Default is 60.
  125157. * @param autoStart Automatically start trailing mesh. Default true.
  125158. */
  125159. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  125160. /**
  125161. * "TrailMesh"
  125162. * @returns "TrailMesh"
  125163. */
  125164. getClassName(): string;
  125165. private _createMesh;
  125166. /**
  125167. * Start trailing mesh.
  125168. */
  125169. start(): void;
  125170. /**
  125171. * Stop trailing mesh.
  125172. */
  125173. stop(): void;
  125174. /**
  125175. * Update trailing mesh geometry.
  125176. */
  125177. update(): void;
  125178. /**
  125179. * Returns a new TrailMesh object.
  125180. * @param name is a string, the name given to the new mesh
  125181. * @param newGenerator use new generator object for cloned trail mesh
  125182. * @returns a new mesh
  125183. */
  125184. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  125185. /**
  125186. * Serializes this trail mesh
  125187. * @param serializationObject object to write serialization to
  125188. */
  125189. serialize(serializationObject: any): void;
  125190. /**
  125191. * Parses a serialized trail mesh
  125192. * @param parsedMesh the serialized mesh
  125193. * @param scene the scene to create the trail mesh in
  125194. * @returns the created trail mesh
  125195. */
  125196. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  125197. }
  125198. }
  125199. declare module BABYLON {
  125200. /**
  125201. * Class containing static functions to help procedurally build meshes
  125202. */
  125203. export class TiledBoxBuilder {
  125204. /**
  125205. * Creates a box mesh
  125206. * 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)
  125207. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125208. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125209. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125211. * @param name defines the name of the mesh
  125212. * @param options defines the options used to create the mesh
  125213. * @param scene defines the hosting scene
  125214. * @returns the box mesh
  125215. */
  125216. static CreateTiledBox(name: string, options: {
  125217. pattern?: number;
  125218. width?: number;
  125219. height?: number;
  125220. depth?: number;
  125221. tileSize?: number;
  125222. tileWidth?: number;
  125223. tileHeight?: number;
  125224. alignHorizontal?: number;
  125225. alignVertical?: number;
  125226. faceUV?: Vector4[];
  125227. faceColors?: Color4[];
  125228. sideOrientation?: number;
  125229. updatable?: boolean;
  125230. }, scene?: Nullable<Scene>): Mesh;
  125231. }
  125232. }
  125233. declare module BABYLON {
  125234. /**
  125235. * Class containing static functions to help procedurally build meshes
  125236. */
  125237. export class TorusKnotBuilder {
  125238. /**
  125239. * Creates a torus knot mesh
  125240. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  125241. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  125242. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  125243. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  125244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125245. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125247. * @param name defines the name of the mesh
  125248. * @param options defines the options used to create the mesh
  125249. * @param scene defines the hosting scene
  125250. * @returns the torus knot mesh
  125251. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  125252. */
  125253. static CreateTorusKnot(name: string, options: {
  125254. radius?: number;
  125255. tube?: number;
  125256. radialSegments?: number;
  125257. tubularSegments?: number;
  125258. p?: number;
  125259. q?: number;
  125260. updatable?: boolean;
  125261. sideOrientation?: number;
  125262. frontUVs?: Vector4;
  125263. backUVs?: Vector4;
  125264. }, scene: any): Mesh;
  125265. }
  125266. }
  125267. declare module BABYLON {
  125268. /**
  125269. * Polygon
  125270. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  125271. */
  125272. export class Polygon {
  125273. /**
  125274. * Creates a rectangle
  125275. * @param xmin bottom X coord
  125276. * @param ymin bottom Y coord
  125277. * @param xmax top X coord
  125278. * @param ymax top Y coord
  125279. * @returns points that make the resulting rectation
  125280. */
  125281. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  125282. /**
  125283. * Creates a circle
  125284. * @param radius radius of circle
  125285. * @param cx scale in x
  125286. * @param cy scale in y
  125287. * @param numberOfSides number of sides that make up the circle
  125288. * @returns points that make the resulting circle
  125289. */
  125290. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  125291. /**
  125292. * Creates a polygon from input string
  125293. * @param input Input polygon data
  125294. * @returns the parsed points
  125295. */
  125296. static Parse(input: string): Vector2[];
  125297. /**
  125298. * Starts building a polygon from x and y coordinates
  125299. * @param x x coordinate
  125300. * @param y y coordinate
  125301. * @returns the started path2
  125302. */
  125303. static StartingAt(x: number, y: number): Path2;
  125304. }
  125305. /**
  125306. * Builds a polygon
  125307. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  125308. */
  125309. export class PolygonMeshBuilder {
  125310. private _points;
  125311. private _outlinepoints;
  125312. private _holes;
  125313. private _name;
  125314. private _scene;
  125315. private _epoints;
  125316. private _eholes;
  125317. private _addToepoint;
  125318. /**
  125319. * Babylon reference to the earcut plugin.
  125320. */
  125321. bjsEarcut: any;
  125322. /**
  125323. * Creates a PolygonMeshBuilder
  125324. * @param name name of the builder
  125325. * @param contours Path of the polygon
  125326. * @param scene scene to add to when creating the mesh
  125327. * @param earcutInjection can be used to inject your own earcut reference
  125328. */
  125329. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  125330. /**
  125331. * Adds a whole within the polygon
  125332. * @param hole Array of points defining the hole
  125333. * @returns this
  125334. */
  125335. addHole(hole: Vector2[]): PolygonMeshBuilder;
  125336. /**
  125337. * Creates the polygon
  125338. * @param updatable If the mesh should be updatable
  125339. * @param depth The depth of the mesh created
  125340. * @returns the created mesh
  125341. */
  125342. build(updatable?: boolean, depth?: number): Mesh;
  125343. /**
  125344. * Creates the polygon
  125345. * @param depth The depth of the mesh created
  125346. * @returns the created VertexData
  125347. */
  125348. buildVertexData(depth?: number): VertexData;
  125349. /**
  125350. * Adds a side to the polygon
  125351. * @param positions points that make the polygon
  125352. * @param normals normals of the polygon
  125353. * @param uvs uvs of the polygon
  125354. * @param indices indices of the polygon
  125355. * @param bounds bounds of the polygon
  125356. * @param points points of the polygon
  125357. * @param depth depth of the polygon
  125358. * @param flip flip of the polygon
  125359. */
  125360. private addSide;
  125361. }
  125362. }
  125363. declare module BABYLON {
  125364. /**
  125365. * Class containing static functions to help procedurally build meshes
  125366. */
  125367. export class PolygonBuilder {
  125368. /**
  125369. * Creates a polygon mesh
  125370. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  125371. * * 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
  125372. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125374. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  125375. * * Remember you can only change the shape positions, not their number when updating a polygon
  125376. * @param name defines the name of the mesh
  125377. * @param options defines the options used to create the mesh
  125378. * @param scene defines the hosting scene
  125379. * @param earcutInjection can be used to inject your own earcut reference
  125380. * @returns the polygon mesh
  125381. */
  125382. static CreatePolygon(name: string, options: {
  125383. shape: Vector3[];
  125384. holes?: Vector3[][];
  125385. depth?: number;
  125386. faceUV?: Vector4[];
  125387. faceColors?: Color4[];
  125388. updatable?: boolean;
  125389. sideOrientation?: number;
  125390. frontUVs?: Vector4;
  125391. backUVs?: Vector4;
  125392. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125393. /**
  125394. * Creates an extruded polygon mesh, with depth in the Y direction.
  125395. * * 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)
  125396. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125397. * @param name defines the name of the mesh
  125398. * @param options defines the options used to create the mesh
  125399. * @param scene defines the hosting scene
  125400. * @param earcutInjection can be used to inject your own earcut reference
  125401. * @returns the polygon mesh
  125402. */
  125403. static ExtrudePolygon(name: string, options: {
  125404. shape: Vector3[];
  125405. holes?: Vector3[][];
  125406. depth?: number;
  125407. faceUV?: Vector4[];
  125408. faceColors?: Color4[];
  125409. updatable?: boolean;
  125410. sideOrientation?: number;
  125411. frontUVs?: Vector4;
  125412. backUVs?: Vector4;
  125413. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125414. }
  125415. }
  125416. declare module BABYLON {
  125417. /**
  125418. * Class containing static functions to help procedurally build meshes
  125419. */
  125420. export class LatheBuilder {
  125421. /**
  125422. * Creates lathe mesh.
  125423. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  125424. * * 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
  125425. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  125426. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  125427. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  125428. * * 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
  125429. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  125430. * * 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
  125431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125432. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125433. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125435. * @param name defines the name of the mesh
  125436. * @param options defines the options used to create the mesh
  125437. * @param scene defines the hosting scene
  125438. * @returns the lathe mesh
  125439. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  125440. */
  125441. static CreateLathe(name: string, options: {
  125442. shape: Vector3[];
  125443. radius?: number;
  125444. tessellation?: number;
  125445. clip?: number;
  125446. arc?: number;
  125447. closed?: boolean;
  125448. updatable?: boolean;
  125449. sideOrientation?: number;
  125450. frontUVs?: Vector4;
  125451. backUVs?: Vector4;
  125452. cap?: number;
  125453. invertUV?: boolean;
  125454. }, scene?: Nullable<Scene>): Mesh;
  125455. }
  125456. }
  125457. declare module BABYLON {
  125458. /**
  125459. * Class containing static functions to help procedurally build meshes
  125460. */
  125461. export class TiledPlaneBuilder {
  125462. /**
  125463. * Creates a tiled plane mesh
  125464. * * The parameter `pattern` will, depending on value, do nothing or
  125465. * * * flip (reflect about central vertical) alternate tiles across and up
  125466. * * * flip every tile on alternate rows
  125467. * * * rotate (180 degs) alternate tiles across and up
  125468. * * * rotate every tile on alternate rows
  125469. * * * flip and rotate alternate tiles across and up
  125470. * * * flip and rotate every tile on alternate rows
  125471. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  125472. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  125473. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125474. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125475. * * 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)
  125476. * * 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)
  125477. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  125478. * @param name defines the name of the mesh
  125479. * @param options defines the options used to create the mesh
  125480. * @param scene defines the hosting scene
  125481. * @returns the box mesh
  125482. */
  125483. static CreateTiledPlane(name: string, options: {
  125484. pattern?: number;
  125485. tileSize?: number;
  125486. tileWidth?: number;
  125487. tileHeight?: number;
  125488. size?: number;
  125489. width?: number;
  125490. height?: number;
  125491. alignHorizontal?: number;
  125492. alignVertical?: number;
  125493. sideOrientation?: number;
  125494. frontUVs?: Vector4;
  125495. backUVs?: Vector4;
  125496. updatable?: boolean;
  125497. }, scene?: Nullable<Scene>): Mesh;
  125498. }
  125499. }
  125500. declare module BABYLON {
  125501. /**
  125502. * Class containing static functions to help procedurally build meshes
  125503. */
  125504. export class TubeBuilder {
  125505. /**
  125506. * Creates a tube mesh.
  125507. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125508. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  125509. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  125510. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  125511. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  125512. * * 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)
  125513. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  125514. * * 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
  125515. * * 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
  125516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125517. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125518. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125520. * @param name defines the name of the mesh
  125521. * @param options defines the options used to create the mesh
  125522. * @param scene defines the hosting scene
  125523. * @returns the tube mesh
  125524. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125525. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  125526. */
  125527. static CreateTube(name: string, options: {
  125528. path: Vector3[];
  125529. radius?: number;
  125530. tessellation?: number;
  125531. radiusFunction?: {
  125532. (i: number, distance: number): number;
  125533. };
  125534. cap?: number;
  125535. arc?: number;
  125536. updatable?: boolean;
  125537. sideOrientation?: number;
  125538. frontUVs?: Vector4;
  125539. backUVs?: Vector4;
  125540. instance?: Mesh;
  125541. invertUV?: boolean;
  125542. }, scene?: Nullable<Scene>): Mesh;
  125543. }
  125544. }
  125545. declare module BABYLON {
  125546. /**
  125547. * Class containing static functions to help procedurally build meshes
  125548. */
  125549. export class IcoSphereBuilder {
  125550. /**
  125551. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  125552. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  125553. * * 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`)
  125554. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  125555. * * 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
  125556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125557. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125559. * @param name defines the name of the mesh
  125560. * @param options defines the options used to create the mesh
  125561. * @param scene defines the hosting scene
  125562. * @returns the icosahedron mesh
  125563. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  125564. */
  125565. static CreateIcoSphere(name: string, options: {
  125566. radius?: number;
  125567. radiusX?: number;
  125568. radiusY?: number;
  125569. radiusZ?: number;
  125570. flat?: boolean;
  125571. subdivisions?: number;
  125572. sideOrientation?: number;
  125573. frontUVs?: Vector4;
  125574. backUVs?: Vector4;
  125575. updatable?: boolean;
  125576. }, scene?: Nullable<Scene>): Mesh;
  125577. }
  125578. }
  125579. declare module BABYLON {
  125580. /**
  125581. * Class containing static functions to help procedurally build meshes
  125582. */
  125583. export class DecalBuilder {
  125584. /**
  125585. * Creates a decal mesh.
  125586. * 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
  125587. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  125588. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  125589. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  125590. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  125591. * @param name defines the name of the mesh
  125592. * @param sourceMesh defines the mesh where the decal must be applied
  125593. * @param options defines the options used to create the mesh
  125594. * @param scene defines the hosting scene
  125595. * @returns the decal mesh
  125596. * @see https://doc.babylonjs.com/how_to/decals
  125597. */
  125598. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  125599. position?: Vector3;
  125600. normal?: Vector3;
  125601. size?: Vector3;
  125602. angle?: number;
  125603. }): Mesh;
  125604. }
  125605. }
  125606. declare module BABYLON {
  125607. /**
  125608. * Class containing static functions to help procedurally build meshes
  125609. */
  125610. export class MeshBuilder {
  125611. /**
  125612. * Creates a box mesh
  125613. * * The parameter `size` sets the size (float) of each box side (default 1)
  125614. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  125615. * * 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)
  125616. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125618. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125620. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  125621. * @param name defines the name of the mesh
  125622. * @param options defines the options used to create the mesh
  125623. * @param scene defines the hosting scene
  125624. * @returns the box mesh
  125625. */
  125626. static CreateBox(name: string, options: {
  125627. size?: number;
  125628. width?: number;
  125629. height?: number;
  125630. depth?: number;
  125631. faceUV?: Vector4[];
  125632. faceColors?: Color4[];
  125633. sideOrientation?: number;
  125634. frontUVs?: Vector4;
  125635. backUVs?: Vector4;
  125636. updatable?: boolean;
  125637. }, scene?: Nullable<Scene>): Mesh;
  125638. /**
  125639. * Creates a tiled box mesh
  125640. * * faceTiles sets the pattern, tile size and number of tiles for a face
  125641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125642. * @param name defines the name of the mesh
  125643. * @param options defines the options used to create the mesh
  125644. * @param scene defines the hosting scene
  125645. * @returns the tiled box mesh
  125646. */
  125647. static CreateTiledBox(name: string, options: {
  125648. pattern?: number;
  125649. size?: number;
  125650. width?: number;
  125651. height?: number;
  125652. depth: number;
  125653. tileSize?: number;
  125654. tileWidth?: number;
  125655. tileHeight?: number;
  125656. faceUV?: Vector4[];
  125657. faceColors?: Color4[];
  125658. alignHorizontal?: number;
  125659. alignVertical?: number;
  125660. sideOrientation?: number;
  125661. updatable?: boolean;
  125662. }, scene?: Nullable<Scene>): Mesh;
  125663. /**
  125664. * Creates a sphere mesh
  125665. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  125666. * * 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`)
  125667. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  125668. * * 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
  125669. * * 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)
  125670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125671. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125673. * @param name defines the name of the mesh
  125674. * @param options defines the options used to create the mesh
  125675. * @param scene defines the hosting scene
  125676. * @returns the sphere mesh
  125677. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  125678. */
  125679. static CreateSphere(name: string, options: {
  125680. segments?: number;
  125681. diameter?: number;
  125682. diameterX?: number;
  125683. diameterY?: number;
  125684. diameterZ?: number;
  125685. arc?: number;
  125686. slice?: number;
  125687. sideOrientation?: number;
  125688. frontUVs?: Vector4;
  125689. backUVs?: Vector4;
  125690. updatable?: boolean;
  125691. }, scene?: Nullable<Scene>): Mesh;
  125692. /**
  125693. * Creates a plane polygonal mesh. By default, this is a disc
  125694. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  125695. * * 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
  125696. * * 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
  125697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125698. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125700. * @param name defines the name of the mesh
  125701. * @param options defines the options used to create the mesh
  125702. * @param scene defines the hosting scene
  125703. * @returns the plane polygonal mesh
  125704. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  125705. */
  125706. static CreateDisc(name: string, options: {
  125707. radius?: number;
  125708. tessellation?: number;
  125709. arc?: number;
  125710. updatable?: boolean;
  125711. sideOrientation?: number;
  125712. frontUVs?: Vector4;
  125713. backUVs?: Vector4;
  125714. }, scene?: Nullable<Scene>): Mesh;
  125715. /**
  125716. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  125717. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  125718. * * 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`)
  125719. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  125720. * * 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
  125721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125722. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125724. * @param name defines the name of the mesh
  125725. * @param options defines the options used to create the mesh
  125726. * @param scene defines the hosting scene
  125727. * @returns the icosahedron mesh
  125728. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  125729. */
  125730. static CreateIcoSphere(name: string, options: {
  125731. radius?: number;
  125732. radiusX?: number;
  125733. radiusY?: number;
  125734. radiusZ?: number;
  125735. flat?: boolean;
  125736. subdivisions?: number;
  125737. sideOrientation?: number;
  125738. frontUVs?: Vector4;
  125739. backUVs?: Vector4;
  125740. updatable?: boolean;
  125741. }, scene?: Nullable<Scene>): Mesh;
  125742. /**
  125743. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125744. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  125745. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  125746. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  125747. * * 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
  125748. * * 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
  125749. * * 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
  125750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125752. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125753. * * 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
  125754. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  125755. * * 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
  125756. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  125757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125758. * @param name defines the name of the mesh
  125759. * @param options defines the options used to create the mesh
  125760. * @param scene defines the hosting scene
  125761. * @returns the ribbon mesh
  125762. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  125763. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125764. */
  125765. static CreateRibbon(name: string, options: {
  125766. pathArray: Vector3[][];
  125767. closeArray?: boolean;
  125768. closePath?: boolean;
  125769. offset?: number;
  125770. updatable?: boolean;
  125771. sideOrientation?: number;
  125772. frontUVs?: Vector4;
  125773. backUVs?: Vector4;
  125774. instance?: Mesh;
  125775. invertUV?: boolean;
  125776. uvs?: Vector2[];
  125777. colors?: Color4[];
  125778. }, scene?: Nullable<Scene>): Mesh;
  125779. /**
  125780. * Creates a cylinder or a cone mesh
  125781. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  125782. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  125783. * * 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.
  125784. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  125785. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  125786. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  125787. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  125788. * * 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).
  125789. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  125790. * * 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).
  125791. * * 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
  125792. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  125793. * * 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
  125794. * * 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.
  125795. * * If `enclose` is false, a ring surface is one element.
  125796. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  125797. * * 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
  125798. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125799. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125801. * @param name defines the name of the mesh
  125802. * @param options defines the options used to create the mesh
  125803. * @param scene defines the hosting scene
  125804. * @returns the cylinder mesh
  125805. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  125806. */
  125807. static CreateCylinder(name: string, options: {
  125808. height?: number;
  125809. diameterTop?: number;
  125810. diameterBottom?: number;
  125811. diameter?: number;
  125812. tessellation?: number;
  125813. subdivisions?: number;
  125814. arc?: number;
  125815. faceColors?: Color4[];
  125816. faceUV?: Vector4[];
  125817. updatable?: boolean;
  125818. hasRings?: boolean;
  125819. enclose?: boolean;
  125820. cap?: number;
  125821. sideOrientation?: number;
  125822. frontUVs?: Vector4;
  125823. backUVs?: Vector4;
  125824. }, scene?: Nullable<Scene>): Mesh;
  125825. /**
  125826. * Creates a torus mesh
  125827. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  125828. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  125829. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  125830. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125831. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125833. * @param name defines the name of the mesh
  125834. * @param options defines the options used to create the mesh
  125835. * @param scene defines the hosting scene
  125836. * @returns the torus mesh
  125837. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  125838. */
  125839. static CreateTorus(name: string, options: {
  125840. diameter?: number;
  125841. thickness?: number;
  125842. tessellation?: number;
  125843. updatable?: boolean;
  125844. sideOrientation?: number;
  125845. frontUVs?: Vector4;
  125846. backUVs?: Vector4;
  125847. }, scene?: Nullable<Scene>): Mesh;
  125848. /**
  125849. * Creates a torus knot mesh
  125850. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  125851. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  125852. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  125853. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  125854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125855. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125857. * @param name defines the name of the mesh
  125858. * @param options defines the options used to create the mesh
  125859. * @param scene defines the hosting scene
  125860. * @returns the torus knot mesh
  125861. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  125862. */
  125863. static CreateTorusKnot(name: string, options: {
  125864. radius?: number;
  125865. tube?: number;
  125866. radialSegments?: number;
  125867. tubularSegments?: number;
  125868. p?: number;
  125869. q?: number;
  125870. updatable?: boolean;
  125871. sideOrientation?: number;
  125872. frontUVs?: Vector4;
  125873. backUVs?: Vector4;
  125874. }, scene?: Nullable<Scene>): Mesh;
  125875. /**
  125876. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  125877. * * 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
  125878. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  125879. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  125880. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  125881. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  125882. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125883. * * 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
  125884. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  125885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125886. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  125887. * @param name defines the name of the new line system
  125888. * @param options defines the options used to create the line system
  125889. * @param scene defines the hosting scene
  125890. * @returns a new line system mesh
  125891. */
  125892. static CreateLineSystem(name: string, options: {
  125893. lines: Vector3[][];
  125894. updatable?: boolean;
  125895. instance?: Nullable<LinesMesh>;
  125896. colors?: Nullable<Color4[][]>;
  125897. useVertexAlpha?: boolean;
  125898. }, scene: Nullable<Scene>): LinesMesh;
  125899. /**
  125900. * Creates a line mesh
  125901. * 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
  125902. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125903. * * The parameter `points` is an array successive Vector3
  125904. * * 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
  125905. * * The optional parameter `colors` is an array of successive Color4, one per line point
  125906. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  125907. * * When updating an instance, remember that only point positions can change, not the number of points
  125908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125909. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  125910. * @param name defines the name of the new line system
  125911. * @param options defines the options used to create the line system
  125912. * @param scene defines the hosting scene
  125913. * @returns a new line mesh
  125914. */
  125915. static CreateLines(name: string, options: {
  125916. points: Vector3[];
  125917. updatable?: boolean;
  125918. instance?: Nullable<LinesMesh>;
  125919. colors?: Color4[];
  125920. useVertexAlpha?: boolean;
  125921. }, scene?: Nullable<Scene>): LinesMesh;
  125922. /**
  125923. * Creates a dashed line mesh
  125924. * * 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
  125925. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125926. * * The parameter `points` is an array successive Vector3
  125927. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  125928. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  125929. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  125930. * * 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
  125931. * * When updating an instance, remember that only point positions can change, not the number of points
  125932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125933. * @param name defines the name of the mesh
  125934. * @param options defines the options used to create the mesh
  125935. * @param scene defines the hosting scene
  125936. * @returns the dashed line mesh
  125937. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  125938. */
  125939. static CreateDashedLines(name: string, options: {
  125940. points: Vector3[];
  125941. dashSize?: number;
  125942. gapSize?: number;
  125943. dashNb?: number;
  125944. updatable?: boolean;
  125945. instance?: LinesMesh;
  125946. }, scene?: Nullable<Scene>): LinesMesh;
  125947. /**
  125948. * 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.
  125949. * * 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.
  125950. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125951. * * 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.
  125952. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  125953. * * 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
  125954. * * 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
  125955. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  125956. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125957. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125958. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  125959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125960. * @param name defines the name of the mesh
  125961. * @param options defines the options used to create the mesh
  125962. * @param scene defines the hosting scene
  125963. * @returns the extruded shape mesh
  125964. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125965. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125966. */
  125967. static ExtrudeShape(name: string, options: {
  125968. shape: Vector3[];
  125969. path: Vector3[];
  125970. scale?: number;
  125971. rotation?: number;
  125972. cap?: number;
  125973. updatable?: boolean;
  125974. sideOrientation?: number;
  125975. frontUVs?: Vector4;
  125976. backUVs?: Vector4;
  125977. instance?: Mesh;
  125978. invertUV?: boolean;
  125979. }, scene?: Nullable<Scene>): Mesh;
  125980. /**
  125981. * Creates an custom extruded shape mesh.
  125982. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  125983. * * 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.
  125984. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125985. * * 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
  125986. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  125987. * * 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
  125988. * * It must returns a float value that will be the scale value applied to the shape on each path point
  125989. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  125990. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  125991. * * 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
  125992. * * 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
  125993. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  125994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125995. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125996. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125998. * @param name defines the name of the mesh
  125999. * @param options defines the options used to create the mesh
  126000. * @param scene defines the hosting scene
  126001. * @returns the custom extruded shape mesh
  126002. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  126003. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126004. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  126005. */
  126006. static ExtrudeShapeCustom(name: string, options: {
  126007. shape: Vector3[];
  126008. path: Vector3[];
  126009. scaleFunction?: any;
  126010. rotationFunction?: any;
  126011. ribbonCloseArray?: boolean;
  126012. ribbonClosePath?: boolean;
  126013. cap?: number;
  126014. updatable?: boolean;
  126015. sideOrientation?: number;
  126016. frontUVs?: Vector4;
  126017. backUVs?: Vector4;
  126018. instance?: Mesh;
  126019. invertUV?: boolean;
  126020. }, scene?: Nullable<Scene>): Mesh;
  126021. /**
  126022. * Creates lathe mesh.
  126023. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  126024. * * 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
  126025. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  126026. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  126027. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  126028. * * 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
  126029. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  126030. * * 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
  126031. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126032. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126033. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126035. * @param name defines the name of the mesh
  126036. * @param options defines the options used to create the mesh
  126037. * @param scene defines the hosting scene
  126038. * @returns the lathe mesh
  126039. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  126040. */
  126041. static CreateLathe(name: string, options: {
  126042. shape: Vector3[];
  126043. radius?: number;
  126044. tessellation?: number;
  126045. clip?: number;
  126046. arc?: number;
  126047. closed?: boolean;
  126048. updatable?: boolean;
  126049. sideOrientation?: number;
  126050. frontUVs?: Vector4;
  126051. backUVs?: Vector4;
  126052. cap?: number;
  126053. invertUV?: boolean;
  126054. }, scene?: Nullable<Scene>): Mesh;
  126055. /**
  126056. * Creates a tiled plane mesh
  126057. * * You can set a limited pattern arrangement with the tiles
  126058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126059. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126061. * @param name defines the name of the mesh
  126062. * @param options defines the options used to create the mesh
  126063. * @param scene defines the hosting scene
  126064. * @returns the plane mesh
  126065. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  126066. */
  126067. static CreateTiledPlane(name: string, options: {
  126068. pattern?: number;
  126069. tileSize?: number;
  126070. tileWidth?: number;
  126071. tileHeight?: number;
  126072. size?: number;
  126073. width?: number;
  126074. height?: number;
  126075. alignHorizontal?: number;
  126076. alignVertical?: number;
  126077. sideOrientation?: number;
  126078. frontUVs?: Vector4;
  126079. backUVs?: Vector4;
  126080. updatable?: boolean;
  126081. }, scene?: Nullable<Scene>): Mesh;
  126082. /**
  126083. * Creates a plane mesh
  126084. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  126085. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  126086. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  126087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126088. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126090. * @param name defines the name of the mesh
  126091. * @param options defines the options used to create the mesh
  126092. * @param scene defines the hosting scene
  126093. * @returns the plane mesh
  126094. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  126095. */
  126096. static CreatePlane(name: string, options: {
  126097. size?: number;
  126098. width?: number;
  126099. height?: number;
  126100. sideOrientation?: number;
  126101. frontUVs?: Vector4;
  126102. backUVs?: Vector4;
  126103. updatable?: boolean;
  126104. sourcePlane?: Plane;
  126105. }, scene?: Nullable<Scene>): Mesh;
  126106. /**
  126107. * Creates a ground mesh
  126108. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  126109. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  126110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126111. * @param name defines the name of the mesh
  126112. * @param options defines the options used to create the mesh
  126113. * @param scene defines the hosting scene
  126114. * @returns the ground mesh
  126115. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  126116. */
  126117. static CreateGround(name: string, options: {
  126118. width?: number;
  126119. height?: number;
  126120. subdivisions?: number;
  126121. subdivisionsX?: number;
  126122. subdivisionsY?: number;
  126123. updatable?: boolean;
  126124. }, scene?: Nullable<Scene>): Mesh;
  126125. /**
  126126. * Creates a tiled ground mesh
  126127. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  126128. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  126129. * * 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
  126130. * * 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
  126131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126132. * @param name defines the name of the mesh
  126133. * @param options defines the options used to create the mesh
  126134. * @param scene defines the hosting scene
  126135. * @returns the tiled ground mesh
  126136. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  126137. */
  126138. static CreateTiledGround(name: string, options: {
  126139. xmin: number;
  126140. zmin: number;
  126141. xmax: number;
  126142. zmax: number;
  126143. subdivisions?: {
  126144. w: number;
  126145. h: number;
  126146. };
  126147. precision?: {
  126148. w: number;
  126149. h: number;
  126150. };
  126151. updatable?: boolean;
  126152. }, scene?: Nullable<Scene>): Mesh;
  126153. /**
  126154. * Creates a ground mesh from a height map
  126155. * * The parameter `url` sets the URL of the height map image resource.
  126156. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  126157. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  126158. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  126159. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  126160. * * 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.
  126161. * * 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).
  126162. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  126163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126164. * @param name defines the name of the mesh
  126165. * @param url defines the url to the height map
  126166. * @param options defines the options used to create the mesh
  126167. * @param scene defines the hosting scene
  126168. * @returns the ground mesh
  126169. * @see https://doc.babylonjs.com/babylon101/height_map
  126170. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  126171. */
  126172. static CreateGroundFromHeightMap(name: string, url: string, options: {
  126173. width?: number;
  126174. height?: number;
  126175. subdivisions?: number;
  126176. minHeight?: number;
  126177. maxHeight?: number;
  126178. colorFilter?: Color3;
  126179. alphaFilter?: number;
  126180. updatable?: boolean;
  126181. onReady?: (mesh: GroundMesh) => void;
  126182. }, scene?: Nullable<Scene>): GroundMesh;
  126183. /**
  126184. * Creates a polygon mesh
  126185. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  126186. * * 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
  126187. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  126188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126189. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  126190. * * Remember you can only change the shape positions, not their number when updating a polygon
  126191. * @param name defines the name of the mesh
  126192. * @param options defines the options used to create the mesh
  126193. * @param scene defines the hosting scene
  126194. * @param earcutInjection can be used to inject your own earcut reference
  126195. * @returns the polygon mesh
  126196. */
  126197. static CreatePolygon(name: string, options: {
  126198. shape: Vector3[];
  126199. holes?: Vector3[][];
  126200. depth?: number;
  126201. faceUV?: Vector4[];
  126202. faceColors?: Color4[];
  126203. updatable?: boolean;
  126204. sideOrientation?: number;
  126205. frontUVs?: Vector4;
  126206. backUVs?: Vector4;
  126207. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126208. /**
  126209. * Creates an extruded polygon mesh, with depth in the Y direction.
  126210. * * 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)
  126211. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126212. * @param name defines the name of the mesh
  126213. * @param options defines the options used to create the mesh
  126214. * @param scene defines the hosting scene
  126215. * @param earcutInjection can be used to inject your own earcut reference
  126216. * @returns the polygon mesh
  126217. */
  126218. static ExtrudePolygon(name: string, options: {
  126219. shape: Vector3[];
  126220. holes?: Vector3[][];
  126221. depth?: number;
  126222. faceUV?: Vector4[];
  126223. faceColors?: Color4[];
  126224. updatable?: boolean;
  126225. sideOrientation?: number;
  126226. frontUVs?: Vector4;
  126227. backUVs?: Vector4;
  126228. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126229. /**
  126230. * Creates a tube mesh.
  126231. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  126232. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  126233. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  126234. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  126235. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  126236. * * 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)
  126237. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  126238. * * 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
  126239. * * 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
  126240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126241. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126242. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126244. * @param name defines the name of the mesh
  126245. * @param options defines the options used to create the mesh
  126246. * @param scene defines the hosting scene
  126247. * @returns the tube mesh
  126248. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126249. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  126250. */
  126251. static CreateTube(name: string, options: {
  126252. path: Vector3[];
  126253. radius?: number;
  126254. tessellation?: number;
  126255. radiusFunction?: {
  126256. (i: number, distance: number): number;
  126257. };
  126258. cap?: number;
  126259. arc?: number;
  126260. updatable?: boolean;
  126261. sideOrientation?: number;
  126262. frontUVs?: Vector4;
  126263. backUVs?: Vector4;
  126264. instance?: Mesh;
  126265. invertUV?: boolean;
  126266. }, scene?: Nullable<Scene>): Mesh;
  126267. /**
  126268. * Creates a polyhedron mesh
  126269. * * 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
  126270. * * The parameter `size` (positive float, default 1) sets the polygon size
  126271. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  126272. * * 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`
  126273. * * 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
  126274. * * 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)`)
  126275. * * 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
  126276. * * 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
  126277. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126278. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126280. * @param name defines the name of the mesh
  126281. * @param options defines the options used to create the mesh
  126282. * @param scene defines the hosting scene
  126283. * @returns the polyhedron mesh
  126284. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  126285. */
  126286. static CreatePolyhedron(name: string, options: {
  126287. type?: number;
  126288. size?: number;
  126289. sizeX?: number;
  126290. sizeY?: number;
  126291. sizeZ?: number;
  126292. custom?: any;
  126293. faceUV?: Vector4[];
  126294. faceColors?: Color4[];
  126295. flat?: boolean;
  126296. updatable?: boolean;
  126297. sideOrientation?: number;
  126298. frontUVs?: Vector4;
  126299. backUVs?: Vector4;
  126300. }, scene?: Nullable<Scene>): Mesh;
  126301. /**
  126302. * Creates a decal mesh.
  126303. * 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
  126304. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  126305. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  126306. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  126307. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  126308. * @param name defines the name of the mesh
  126309. * @param sourceMesh defines the mesh where the decal must be applied
  126310. * @param options defines the options used to create the mesh
  126311. * @param scene defines the hosting scene
  126312. * @returns the decal mesh
  126313. * @see https://doc.babylonjs.com/how_to/decals
  126314. */
  126315. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  126316. position?: Vector3;
  126317. normal?: Vector3;
  126318. size?: Vector3;
  126319. angle?: number;
  126320. }): Mesh;
  126321. }
  126322. }
  126323. declare module BABYLON {
  126324. /**
  126325. * A simplifier interface for future simplification implementations
  126326. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126327. */
  126328. export interface ISimplifier {
  126329. /**
  126330. * Simplification of a given mesh according to the given settings.
  126331. * Since this requires computation, it is assumed that the function runs async.
  126332. * @param settings The settings of the simplification, including quality and distance
  126333. * @param successCallback A callback that will be called after the mesh was simplified.
  126334. * @param errorCallback in case of an error, this callback will be called. optional.
  126335. */
  126336. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  126337. }
  126338. /**
  126339. * Expected simplification settings.
  126340. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  126341. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126342. */
  126343. export interface ISimplificationSettings {
  126344. /**
  126345. * Gets or sets the expected quality
  126346. */
  126347. quality: number;
  126348. /**
  126349. * Gets or sets the distance when this optimized version should be used
  126350. */
  126351. distance: number;
  126352. /**
  126353. * Gets an already optimized mesh
  126354. */
  126355. optimizeMesh?: boolean;
  126356. }
  126357. /**
  126358. * Class used to specify simplification options
  126359. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126360. */
  126361. export class SimplificationSettings implements ISimplificationSettings {
  126362. /** expected quality */
  126363. quality: number;
  126364. /** distance when this optimized version should be used */
  126365. distance: number;
  126366. /** already optimized mesh */
  126367. optimizeMesh?: boolean | undefined;
  126368. /**
  126369. * Creates a SimplificationSettings
  126370. * @param quality expected quality
  126371. * @param distance distance when this optimized version should be used
  126372. * @param optimizeMesh already optimized mesh
  126373. */
  126374. constructor(
  126375. /** expected quality */
  126376. quality: number,
  126377. /** distance when this optimized version should be used */
  126378. distance: number,
  126379. /** already optimized mesh */
  126380. optimizeMesh?: boolean | undefined);
  126381. }
  126382. /**
  126383. * Interface used to define a simplification task
  126384. */
  126385. export interface ISimplificationTask {
  126386. /**
  126387. * Array of settings
  126388. */
  126389. settings: Array<ISimplificationSettings>;
  126390. /**
  126391. * Simplification type
  126392. */
  126393. simplificationType: SimplificationType;
  126394. /**
  126395. * Mesh to simplify
  126396. */
  126397. mesh: Mesh;
  126398. /**
  126399. * Callback called on success
  126400. */
  126401. successCallback?: () => void;
  126402. /**
  126403. * Defines if parallel processing can be used
  126404. */
  126405. parallelProcessing: boolean;
  126406. }
  126407. /**
  126408. * Queue used to order the simplification tasks
  126409. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126410. */
  126411. export class SimplificationQueue {
  126412. private _simplificationArray;
  126413. /**
  126414. * Gets a boolean indicating that the process is still running
  126415. */
  126416. running: boolean;
  126417. /**
  126418. * Creates a new queue
  126419. */
  126420. constructor();
  126421. /**
  126422. * Adds a new simplification task
  126423. * @param task defines a task to add
  126424. */
  126425. addTask(task: ISimplificationTask): void;
  126426. /**
  126427. * Execute next task
  126428. */
  126429. executeNext(): void;
  126430. /**
  126431. * Execute a simplification task
  126432. * @param task defines the task to run
  126433. */
  126434. runSimplification(task: ISimplificationTask): void;
  126435. private getSimplifier;
  126436. }
  126437. /**
  126438. * The implemented types of simplification
  126439. * At the moment only Quadratic Error Decimation is implemented
  126440. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126441. */
  126442. export enum SimplificationType {
  126443. /** Quadratic error decimation */
  126444. QUADRATIC = 0
  126445. }
  126446. }
  126447. declare module BABYLON {
  126448. interface Scene {
  126449. /** @hidden (Backing field) */
  126450. _simplificationQueue: SimplificationQueue;
  126451. /**
  126452. * Gets or sets the simplification queue attached to the scene
  126453. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126454. */
  126455. simplificationQueue: SimplificationQueue;
  126456. }
  126457. interface Mesh {
  126458. /**
  126459. * Simplify the mesh according to the given array of settings.
  126460. * Function will return immediately and will simplify async
  126461. * @param settings a collection of simplification settings
  126462. * @param parallelProcessing should all levels calculate parallel or one after the other
  126463. * @param simplificationType the type of simplification to run
  126464. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  126465. * @returns the current mesh
  126466. */
  126467. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  126468. }
  126469. /**
  126470. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  126471. * created in a scene
  126472. */
  126473. export class SimplicationQueueSceneComponent implements ISceneComponent {
  126474. /**
  126475. * The component name helpfull to identify the component in the list of scene components.
  126476. */
  126477. readonly name: string;
  126478. /**
  126479. * The scene the component belongs to.
  126480. */
  126481. scene: Scene;
  126482. /**
  126483. * Creates a new instance of the component for the given scene
  126484. * @param scene Defines the scene to register the component in
  126485. */
  126486. constructor(scene: Scene);
  126487. /**
  126488. * Registers the component in a given scene
  126489. */
  126490. register(): void;
  126491. /**
  126492. * Rebuilds the elements related to this component in case of
  126493. * context lost for instance.
  126494. */
  126495. rebuild(): void;
  126496. /**
  126497. * Disposes the component and the associated ressources
  126498. */
  126499. dispose(): void;
  126500. private _beforeCameraUpdate;
  126501. }
  126502. }
  126503. declare module BABYLON {
  126504. /**
  126505. * Navigation plugin interface to add navigation constrained by a navigation mesh
  126506. */
  126507. export interface INavigationEnginePlugin {
  126508. /**
  126509. * plugin name
  126510. */
  126511. name: string;
  126512. /**
  126513. * Creates a navigation mesh
  126514. * @param meshes array of all the geometry used to compute the navigatio mesh
  126515. * @param parameters bunch of parameters used to filter geometry
  126516. */
  126517. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  126518. /**
  126519. * Create a navigation mesh debug mesh
  126520. * @param scene is where the mesh will be added
  126521. * @returns debug display mesh
  126522. */
  126523. createDebugNavMesh(scene: Scene): Mesh;
  126524. /**
  126525. * Get a navigation mesh constrained position, closest to the parameter position
  126526. * @param position world position
  126527. * @returns the closest point to position constrained by the navigation mesh
  126528. */
  126529. getClosestPoint(position: Vector3): Vector3;
  126530. /**
  126531. * Get a navigation mesh constrained position, within a particular radius
  126532. * @param position world position
  126533. * @param maxRadius the maximum distance to the constrained world position
  126534. * @returns the closest point to position constrained by the navigation mesh
  126535. */
  126536. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  126537. /**
  126538. * Compute the final position from a segment made of destination-position
  126539. * @param position world position
  126540. * @param destination world position
  126541. * @returns the resulting point along the navmesh
  126542. */
  126543. moveAlong(position: Vector3, destination: Vector3): Vector3;
  126544. /**
  126545. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  126546. * @param start world position
  126547. * @param end world position
  126548. * @returns array containing world position composing the path
  126549. */
  126550. computePath(start: Vector3, end: Vector3): Vector3[];
  126551. /**
  126552. * If this plugin is supported
  126553. * @returns true if plugin is supported
  126554. */
  126555. isSupported(): boolean;
  126556. /**
  126557. * Create a new Crowd so you can add agents
  126558. * @param maxAgents the maximum agent count in the crowd
  126559. * @param maxAgentRadius the maximum radius an agent can have
  126560. * @param scene to attach the crowd to
  126561. * @returns the crowd you can add agents to
  126562. */
  126563. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  126564. /**
  126565. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126566. * The queries will try to find a solution within those bounds
  126567. * default is (1,1,1)
  126568. * @param extent x,y,z value that define the extent around the queries point of reference
  126569. */
  126570. setDefaultQueryExtent(extent: Vector3): void;
  126571. /**
  126572. * Get the Bounding box extent specified by setDefaultQueryExtent
  126573. * @returns the box extent values
  126574. */
  126575. getDefaultQueryExtent(): Vector3;
  126576. /**
  126577. * Release all resources
  126578. */
  126579. dispose(): void;
  126580. }
  126581. /**
  126582. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  126583. */
  126584. export interface ICrowd {
  126585. /**
  126586. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  126587. * You can attach anything to that node. The node position is updated in the scene update tick.
  126588. * @param pos world position that will be constrained by the navigation mesh
  126589. * @param parameters agent parameters
  126590. * @param transform hooked to the agent that will be update by the scene
  126591. * @returns agent index
  126592. */
  126593. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  126594. /**
  126595. * Returns the agent position in world space
  126596. * @param index agent index returned by addAgent
  126597. * @returns world space position
  126598. */
  126599. getAgentPosition(index: number): Vector3;
  126600. /**
  126601. * Gets the agent velocity in world space
  126602. * @param index agent index returned by addAgent
  126603. * @returns world space velocity
  126604. */
  126605. getAgentVelocity(index: number): Vector3;
  126606. /**
  126607. * remove a particular agent previously created
  126608. * @param index agent index returned by addAgent
  126609. */
  126610. removeAgent(index: number): void;
  126611. /**
  126612. * get the list of all agents attached to this crowd
  126613. * @returns list of agent indices
  126614. */
  126615. getAgents(): number[];
  126616. /**
  126617. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  126618. * @param deltaTime in seconds
  126619. */
  126620. update(deltaTime: number): void;
  126621. /**
  126622. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  126623. * @param index agent index returned by addAgent
  126624. * @param destination targeted world position
  126625. */
  126626. agentGoto(index: number, destination: Vector3): void;
  126627. /**
  126628. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126629. * The queries will try to find a solution within those bounds
  126630. * default is (1,1,1)
  126631. * @param extent x,y,z value that define the extent around the queries point of reference
  126632. */
  126633. setDefaultQueryExtent(extent: Vector3): void;
  126634. /**
  126635. * Get the Bounding box extent specified by setDefaultQueryExtent
  126636. * @returns the box extent values
  126637. */
  126638. getDefaultQueryExtent(): Vector3;
  126639. /**
  126640. * Release all resources
  126641. */
  126642. dispose(): void;
  126643. }
  126644. /**
  126645. * Configures an agent
  126646. */
  126647. export interface IAgentParameters {
  126648. /**
  126649. * Agent radius. [Limit: >= 0]
  126650. */
  126651. radius: number;
  126652. /**
  126653. * Agent height. [Limit: > 0]
  126654. */
  126655. height: number;
  126656. /**
  126657. * Maximum allowed acceleration. [Limit: >= 0]
  126658. */
  126659. maxAcceleration: number;
  126660. /**
  126661. * Maximum allowed speed. [Limit: >= 0]
  126662. */
  126663. maxSpeed: number;
  126664. /**
  126665. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  126666. */
  126667. collisionQueryRange: number;
  126668. /**
  126669. * The path visibility optimization range. [Limit: > 0]
  126670. */
  126671. pathOptimizationRange: number;
  126672. /**
  126673. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  126674. */
  126675. separationWeight: number;
  126676. }
  126677. /**
  126678. * Configures the navigation mesh creation
  126679. */
  126680. export interface INavMeshParameters {
  126681. /**
  126682. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  126683. */
  126684. cs: number;
  126685. /**
  126686. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  126687. */
  126688. ch: number;
  126689. /**
  126690. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  126691. */
  126692. walkableSlopeAngle: number;
  126693. /**
  126694. * Minimum floor to 'ceiling' height that will still allow the floor area to
  126695. * be considered walkable. [Limit: >= 3] [Units: vx]
  126696. */
  126697. walkableHeight: number;
  126698. /**
  126699. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  126700. */
  126701. walkableClimb: number;
  126702. /**
  126703. * The distance to erode/shrink the walkable area of the heightfield away from
  126704. * obstructions. [Limit: >=0] [Units: vx]
  126705. */
  126706. walkableRadius: number;
  126707. /**
  126708. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  126709. */
  126710. maxEdgeLen: number;
  126711. /**
  126712. * The maximum distance a simplfied contour's border edges should deviate
  126713. * the original raw contour. [Limit: >=0] [Units: vx]
  126714. */
  126715. maxSimplificationError: number;
  126716. /**
  126717. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  126718. */
  126719. minRegionArea: number;
  126720. /**
  126721. * Any regions with a span count smaller than this value will, if possible,
  126722. * be merged with larger regions. [Limit: >=0] [Units: vx]
  126723. */
  126724. mergeRegionArea: number;
  126725. /**
  126726. * The maximum number of vertices allowed for polygons generated during the
  126727. * contour to polygon conversion process. [Limit: >= 3]
  126728. */
  126729. maxVertsPerPoly: number;
  126730. /**
  126731. * Sets the sampling distance to use when generating the detail mesh.
  126732. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  126733. */
  126734. detailSampleDist: number;
  126735. /**
  126736. * The maximum distance the detail mesh surface should deviate from heightfield
  126737. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  126738. */
  126739. detailSampleMaxError: number;
  126740. }
  126741. }
  126742. declare module BABYLON {
  126743. /**
  126744. * RecastJS navigation plugin
  126745. */
  126746. export class RecastJSPlugin implements INavigationEnginePlugin {
  126747. /**
  126748. * Reference to the Recast library
  126749. */
  126750. bjsRECAST: any;
  126751. /**
  126752. * plugin name
  126753. */
  126754. name: string;
  126755. /**
  126756. * the first navmesh created. We might extend this to support multiple navmeshes
  126757. */
  126758. navMesh: any;
  126759. /**
  126760. * Initializes the recastJS plugin
  126761. * @param recastInjection can be used to inject your own recast reference
  126762. */
  126763. constructor(recastInjection?: any);
  126764. /**
  126765. * Creates a navigation mesh
  126766. * @param meshes array of all the geometry used to compute the navigatio mesh
  126767. * @param parameters bunch of parameters used to filter geometry
  126768. */
  126769. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  126770. /**
  126771. * Create a navigation mesh debug mesh
  126772. * @param scene is where the mesh will be added
  126773. * @returns debug display mesh
  126774. */
  126775. createDebugNavMesh(scene: Scene): Mesh;
  126776. /**
  126777. * Get a navigation mesh constrained position, closest to the parameter position
  126778. * @param position world position
  126779. * @returns the closest point to position constrained by the navigation mesh
  126780. */
  126781. getClosestPoint(position: Vector3): Vector3;
  126782. /**
  126783. * Get a navigation mesh constrained position, within a particular radius
  126784. * @param position world position
  126785. * @param maxRadius the maximum distance to the constrained world position
  126786. * @returns the closest point to position constrained by the navigation mesh
  126787. */
  126788. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  126789. /**
  126790. * Compute the final position from a segment made of destination-position
  126791. * @param position world position
  126792. * @param destination world position
  126793. * @returns the resulting point along the navmesh
  126794. */
  126795. moveAlong(position: Vector3, destination: Vector3): Vector3;
  126796. /**
  126797. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  126798. * @param start world position
  126799. * @param end world position
  126800. * @returns array containing world position composing the path
  126801. */
  126802. computePath(start: Vector3, end: Vector3): Vector3[];
  126803. /**
  126804. * Create a new Crowd so you can add agents
  126805. * @param maxAgents the maximum agent count in the crowd
  126806. * @param maxAgentRadius the maximum radius an agent can have
  126807. * @param scene to attach the crowd to
  126808. * @returns the crowd you can add agents to
  126809. */
  126810. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  126811. /**
  126812. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126813. * The queries will try to find a solution within those bounds
  126814. * default is (1,1,1)
  126815. * @param extent x,y,z value that define the extent around the queries point of reference
  126816. */
  126817. setDefaultQueryExtent(extent: Vector3): void;
  126818. /**
  126819. * Get the Bounding box extent specified by setDefaultQueryExtent
  126820. * @returns the box extent values
  126821. */
  126822. getDefaultQueryExtent(): Vector3;
  126823. /**
  126824. * Disposes
  126825. */
  126826. dispose(): void;
  126827. /**
  126828. * If this plugin is supported
  126829. * @returns true if plugin is supported
  126830. */
  126831. isSupported(): boolean;
  126832. }
  126833. /**
  126834. * Recast detour crowd implementation
  126835. */
  126836. export class RecastJSCrowd implements ICrowd {
  126837. /**
  126838. * Recast/detour plugin
  126839. */
  126840. bjsRECASTPlugin: RecastJSPlugin;
  126841. /**
  126842. * Link to the detour crowd
  126843. */
  126844. recastCrowd: any;
  126845. /**
  126846. * One transform per agent
  126847. */
  126848. transforms: TransformNode[];
  126849. /**
  126850. * All agents created
  126851. */
  126852. agents: number[];
  126853. /**
  126854. * Link to the scene is kept to unregister the crowd from the scene
  126855. */
  126856. private _scene;
  126857. /**
  126858. * Observer for crowd updates
  126859. */
  126860. private _onBeforeAnimationsObserver;
  126861. /**
  126862. * Constructor
  126863. * @param plugin recastJS plugin
  126864. * @param maxAgents the maximum agent count in the crowd
  126865. * @param maxAgentRadius the maximum radius an agent can have
  126866. * @param scene to attach the crowd to
  126867. * @returns the crowd you can add agents to
  126868. */
  126869. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  126870. /**
  126871. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  126872. * You can attach anything to that node. The node position is updated in the scene update tick.
  126873. * @param pos world position that will be constrained by the navigation mesh
  126874. * @param parameters agent parameters
  126875. * @param transform hooked to the agent that will be update by the scene
  126876. * @returns agent index
  126877. */
  126878. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  126879. /**
  126880. * Returns the agent position in world space
  126881. * @param index agent index returned by addAgent
  126882. * @returns world space position
  126883. */
  126884. getAgentPosition(index: number): Vector3;
  126885. /**
  126886. * Returns the agent velocity in world space
  126887. * @param index agent index returned by addAgent
  126888. * @returns world space velocity
  126889. */
  126890. getAgentVelocity(index: number): Vector3;
  126891. /**
  126892. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  126893. * @param index agent index returned by addAgent
  126894. * @param destination targeted world position
  126895. */
  126896. agentGoto(index: number, destination: Vector3): void;
  126897. /**
  126898. * remove a particular agent previously created
  126899. * @param index agent index returned by addAgent
  126900. */
  126901. removeAgent(index: number): void;
  126902. /**
  126903. * get the list of all agents attached to this crowd
  126904. * @returns list of agent indices
  126905. */
  126906. getAgents(): number[];
  126907. /**
  126908. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  126909. * @param deltaTime in seconds
  126910. */
  126911. update(deltaTime: number): void;
  126912. /**
  126913. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126914. * The queries will try to find a solution within those bounds
  126915. * default is (1,1,1)
  126916. * @param extent x,y,z value that define the extent around the queries point of reference
  126917. */
  126918. setDefaultQueryExtent(extent: Vector3): void;
  126919. /**
  126920. * Get the Bounding box extent specified by setDefaultQueryExtent
  126921. * @returns the box extent values
  126922. */
  126923. getDefaultQueryExtent(): Vector3;
  126924. /**
  126925. * Release all resources
  126926. */
  126927. dispose(): void;
  126928. }
  126929. }
  126930. declare module BABYLON {
  126931. /**
  126932. * Class used to enable access to IndexedDB
  126933. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  126934. */
  126935. export class Database implements IOfflineProvider {
  126936. private _callbackManifestChecked;
  126937. private _currentSceneUrl;
  126938. private _db;
  126939. private _enableSceneOffline;
  126940. private _enableTexturesOffline;
  126941. private _manifestVersionFound;
  126942. private _mustUpdateRessources;
  126943. private _hasReachedQuota;
  126944. private _isSupported;
  126945. private _idbFactory;
  126946. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  126947. private static IsUASupportingBlobStorage;
  126948. /**
  126949. * Gets a boolean indicating if Database storate is enabled (off by default)
  126950. */
  126951. static IDBStorageEnabled: boolean;
  126952. /**
  126953. * Gets a boolean indicating if scene must be saved in the database
  126954. */
  126955. readonly enableSceneOffline: boolean;
  126956. /**
  126957. * Gets a boolean indicating if textures must be saved in the database
  126958. */
  126959. readonly enableTexturesOffline: boolean;
  126960. /**
  126961. * Creates a new Database
  126962. * @param urlToScene defines the url to load the scene
  126963. * @param callbackManifestChecked defines the callback to use when manifest is checked
  126964. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  126965. */
  126966. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  126967. private static _ParseURL;
  126968. private static _ReturnFullUrlLocation;
  126969. private _checkManifestFile;
  126970. /**
  126971. * Open the database and make it available
  126972. * @param successCallback defines the callback to call on success
  126973. * @param errorCallback defines the callback to call on error
  126974. */
  126975. open(successCallback: () => void, errorCallback: () => void): void;
  126976. /**
  126977. * Loads an image from the database
  126978. * @param url defines the url to load from
  126979. * @param image defines the target DOM image
  126980. */
  126981. loadImage(url: string, image: HTMLImageElement): void;
  126982. private _loadImageFromDBAsync;
  126983. private _saveImageIntoDBAsync;
  126984. private _checkVersionFromDB;
  126985. private _loadVersionFromDBAsync;
  126986. private _saveVersionIntoDBAsync;
  126987. /**
  126988. * Loads a file from database
  126989. * @param url defines the URL to load from
  126990. * @param sceneLoaded defines a callback to call on success
  126991. * @param progressCallBack defines a callback to call when progress changed
  126992. * @param errorCallback defines a callback to call on error
  126993. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  126994. */
  126995. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  126996. private _loadFileAsync;
  126997. private _saveFileAsync;
  126998. /**
  126999. * Validates if xhr data is correct
  127000. * @param xhr defines the request to validate
  127001. * @param dataType defines the expected data type
  127002. * @returns true if data is correct
  127003. */
  127004. private static _ValidateXHRData;
  127005. }
  127006. }
  127007. declare module BABYLON {
  127008. /** @hidden */
  127009. export var gpuUpdateParticlesPixelShader: {
  127010. name: string;
  127011. shader: string;
  127012. };
  127013. }
  127014. declare module BABYLON {
  127015. /** @hidden */
  127016. export var gpuUpdateParticlesVertexShader: {
  127017. name: string;
  127018. shader: string;
  127019. };
  127020. }
  127021. declare module BABYLON {
  127022. /** @hidden */
  127023. export var clipPlaneFragmentDeclaration2: {
  127024. name: string;
  127025. shader: string;
  127026. };
  127027. }
  127028. declare module BABYLON {
  127029. /** @hidden */
  127030. export var gpuRenderParticlesPixelShader: {
  127031. name: string;
  127032. shader: string;
  127033. };
  127034. }
  127035. declare module BABYLON {
  127036. /** @hidden */
  127037. export var clipPlaneVertexDeclaration2: {
  127038. name: string;
  127039. shader: string;
  127040. };
  127041. }
  127042. declare module BABYLON {
  127043. /** @hidden */
  127044. export var gpuRenderParticlesVertexShader: {
  127045. name: string;
  127046. shader: string;
  127047. };
  127048. }
  127049. declare module BABYLON {
  127050. /**
  127051. * This represents a GPU particle system in Babylon
  127052. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  127053. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  127054. */
  127055. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  127056. /**
  127057. * The layer mask we are rendering the particles through.
  127058. */
  127059. layerMask: number;
  127060. private _capacity;
  127061. private _activeCount;
  127062. private _currentActiveCount;
  127063. private _accumulatedCount;
  127064. private _renderEffect;
  127065. private _updateEffect;
  127066. private _buffer0;
  127067. private _buffer1;
  127068. private _spriteBuffer;
  127069. private _updateVAO;
  127070. private _renderVAO;
  127071. private _targetIndex;
  127072. private _sourceBuffer;
  127073. private _targetBuffer;
  127074. private _engine;
  127075. private _currentRenderId;
  127076. private _started;
  127077. private _stopped;
  127078. private _timeDelta;
  127079. private _randomTexture;
  127080. private _randomTexture2;
  127081. private _attributesStrideSize;
  127082. private _updateEffectOptions;
  127083. private _randomTextureSize;
  127084. private _actualFrame;
  127085. private readonly _rawTextureWidth;
  127086. /**
  127087. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  127088. */
  127089. static readonly IsSupported: boolean;
  127090. /**
  127091. * An event triggered when the system is disposed.
  127092. */
  127093. onDisposeObservable: Observable<GPUParticleSystem>;
  127094. /**
  127095. * Gets the maximum number of particles active at the same time.
  127096. * @returns The max number of active particles.
  127097. */
  127098. getCapacity(): number;
  127099. /**
  127100. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  127101. * to override the particles.
  127102. */
  127103. forceDepthWrite: boolean;
  127104. /**
  127105. * Gets or set the number of active particles
  127106. */
  127107. activeParticleCount: number;
  127108. private _preWarmDone;
  127109. /**
  127110. * Is this system ready to be used/rendered
  127111. * @return true if the system is ready
  127112. */
  127113. isReady(): boolean;
  127114. /**
  127115. * Gets if the system has been started. (Note: this will still be true after stop is called)
  127116. * @returns True if it has been started, otherwise false.
  127117. */
  127118. isStarted(): boolean;
  127119. /**
  127120. * Starts the particle system and begins to emit
  127121. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  127122. */
  127123. start(delay?: number): void;
  127124. /**
  127125. * Stops the particle system.
  127126. */
  127127. stop(): void;
  127128. /**
  127129. * Remove all active particles
  127130. */
  127131. reset(): void;
  127132. /**
  127133. * Returns the string "GPUParticleSystem"
  127134. * @returns a string containing the class name
  127135. */
  127136. getClassName(): string;
  127137. private _colorGradientsTexture;
  127138. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  127139. /**
  127140. * Adds a new color gradient
  127141. * @param gradient defines the gradient to use (between 0 and 1)
  127142. * @param color1 defines the color to affect to the specified gradient
  127143. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  127144. * @returns the current particle system
  127145. */
  127146. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  127147. /**
  127148. * Remove a specific color gradient
  127149. * @param gradient defines the gradient to remove
  127150. * @returns the current particle system
  127151. */
  127152. removeColorGradient(gradient: number): GPUParticleSystem;
  127153. private _angularSpeedGradientsTexture;
  127154. private _sizeGradientsTexture;
  127155. private _velocityGradientsTexture;
  127156. private _limitVelocityGradientsTexture;
  127157. private _dragGradientsTexture;
  127158. private _addFactorGradient;
  127159. /**
  127160. * Adds a new size gradient
  127161. * @param gradient defines the gradient to use (between 0 and 1)
  127162. * @param factor defines the size factor to affect to the specified gradient
  127163. * @returns the current particle system
  127164. */
  127165. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  127166. /**
  127167. * Remove a specific size gradient
  127168. * @param gradient defines the gradient to remove
  127169. * @returns the current particle system
  127170. */
  127171. removeSizeGradient(gradient: number): GPUParticleSystem;
  127172. /**
  127173. * Adds a new angular speed gradient
  127174. * @param gradient defines the gradient to use (between 0 and 1)
  127175. * @param factor defines the angular speed to affect to the specified gradient
  127176. * @returns the current particle system
  127177. */
  127178. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  127179. /**
  127180. * Remove a specific angular speed gradient
  127181. * @param gradient defines the gradient to remove
  127182. * @returns the current particle system
  127183. */
  127184. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  127185. /**
  127186. * Adds a new velocity gradient
  127187. * @param gradient defines the gradient to use (between 0 and 1)
  127188. * @param factor defines the velocity to affect to the specified gradient
  127189. * @returns the current particle system
  127190. */
  127191. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  127192. /**
  127193. * Remove a specific velocity gradient
  127194. * @param gradient defines the gradient to remove
  127195. * @returns the current particle system
  127196. */
  127197. removeVelocityGradient(gradient: number): GPUParticleSystem;
  127198. /**
  127199. * Adds a new limit velocity gradient
  127200. * @param gradient defines the gradient to use (between 0 and 1)
  127201. * @param factor defines the limit velocity value to affect to the specified gradient
  127202. * @returns the current particle system
  127203. */
  127204. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  127205. /**
  127206. * Remove a specific limit velocity gradient
  127207. * @param gradient defines the gradient to remove
  127208. * @returns the current particle system
  127209. */
  127210. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  127211. /**
  127212. * Adds a new drag gradient
  127213. * @param gradient defines the gradient to use (between 0 and 1)
  127214. * @param factor defines the drag value to affect to the specified gradient
  127215. * @returns the current particle system
  127216. */
  127217. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  127218. /**
  127219. * Remove a specific drag gradient
  127220. * @param gradient defines the gradient to remove
  127221. * @returns the current particle system
  127222. */
  127223. removeDragGradient(gradient: number): GPUParticleSystem;
  127224. /**
  127225. * Not supported by GPUParticleSystem
  127226. * @param gradient defines the gradient to use (between 0 and 1)
  127227. * @param factor defines the emit rate value to affect to the specified gradient
  127228. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  127229. * @returns the current particle system
  127230. */
  127231. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  127232. /**
  127233. * Not supported by GPUParticleSystem
  127234. * @param gradient defines the gradient to remove
  127235. * @returns the current particle system
  127236. */
  127237. removeEmitRateGradient(gradient: number): IParticleSystem;
  127238. /**
  127239. * Not supported by GPUParticleSystem
  127240. * @param gradient defines the gradient to use (between 0 and 1)
  127241. * @param factor defines the start size value to affect to the specified gradient
  127242. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  127243. * @returns the current particle system
  127244. */
  127245. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  127246. /**
  127247. * Not supported by GPUParticleSystem
  127248. * @param gradient defines the gradient to remove
  127249. * @returns the current particle system
  127250. */
  127251. removeStartSizeGradient(gradient: number): IParticleSystem;
  127252. /**
  127253. * Not supported by GPUParticleSystem
  127254. * @param gradient defines the gradient to use (between 0 and 1)
  127255. * @param min defines the color remap minimal range
  127256. * @param max defines the color remap maximal range
  127257. * @returns the current particle system
  127258. */
  127259. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  127260. /**
  127261. * Not supported by GPUParticleSystem
  127262. * @param gradient defines the gradient to remove
  127263. * @returns the current particle system
  127264. */
  127265. removeColorRemapGradient(): IParticleSystem;
  127266. /**
  127267. * Not supported by GPUParticleSystem
  127268. * @param gradient defines the gradient to use (between 0 and 1)
  127269. * @param min defines the alpha remap minimal range
  127270. * @param max defines the alpha remap maximal range
  127271. * @returns the current particle system
  127272. */
  127273. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  127274. /**
  127275. * Not supported by GPUParticleSystem
  127276. * @param gradient defines the gradient to remove
  127277. * @returns the current particle system
  127278. */
  127279. removeAlphaRemapGradient(): IParticleSystem;
  127280. /**
  127281. * Not supported by GPUParticleSystem
  127282. * @param gradient defines the gradient to use (between 0 and 1)
  127283. * @param color defines the color to affect to the specified gradient
  127284. * @returns the current particle system
  127285. */
  127286. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  127287. /**
  127288. * Not supported by GPUParticleSystem
  127289. * @param gradient defines the gradient to remove
  127290. * @returns the current particle system
  127291. */
  127292. removeRampGradient(): IParticleSystem;
  127293. /**
  127294. * Not supported by GPUParticleSystem
  127295. * @returns the list of ramp gradients
  127296. */
  127297. getRampGradients(): Nullable<Array<Color3Gradient>>;
  127298. /**
  127299. * Not supported by GPUParticleSystem
  127300. * Gets or sets a boolean indicating that ramp gradients must be used
  127301. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  127302. */
  127303. useRampGradients: boolean;
  127304. /**
  127305. * Not supported by GPUParticleSystem
  127306. * @param gradient defines the gradient to use (between 0 and 1)
  127307. * @param factor defines the life time factor to affect to the specified gradient
  127308. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  127309. * @returns the current particle system
  127310. */
  127311. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  127312. /**
  127313. * Not supported by GPUParticleSystem
  127314. * @param gradient defines the gradient to remove
  127315. * @returns the current particle system
  127316. */
  127317. removeLifeTimeGradient(gradient: number): IParticleSystem;
  127318. /**
  127319. * Instantiates a GPU particle system.
  127320. * 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.
  127321. * @param name The name of the particle system
  127322. * @param options The options used to create the system
  127323. * @param scene The scene the particle system belongs to
  127324. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  127325. */
  127326. constructor(name: string, options: Partial<{
  127327. capacity: number;
  127328. randomTextureSize: number;
  127329. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  127330. protected _reset(): void;
  127331. private _createUpdateVAO;
  127332. private _createRenderVAO;
  127333. private _initialize;
  127334. /** @hidden */
  127335. _recreateUpdateEffect(): void;
  127336. /** @hidden */
  127337. _recreateRenderEffect(): void;
  127338. /**
  127339. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  127340. * @param preWarm defines if we are in the pre-warmimg phase
  127341. */
  127342. animate(preWarm?: boolean): void;
  127343. private _createFactorGradientTexture;
  127344. private _createSizeGradientTexture;
  127345. private _createAngularSpeedGradientTexture;
  127346. private _createVelocityGradientTexture;
  127347. private _createLimitVelocityGradientTexture;
  127348. private _createDragGradientTexture;
  127349. private _createColorGradientTexture;
  127350. /**
  127351. * Renders the particle system in its current state
  127352. * @param preWarm defines if the system should only update the particles but not render them
  127353. * @returns the current number of particles
  127354. */
  127355. render(preWarm?: boolean): number;
  127356. /**
  127357. * Rebuilds the particle system
  127358. */
  127359. rebuild(): void;
  127360. private _releaseBuffers;
  127361. private _releaseVAOs;
  127362. /**
  127363. * Disposes the particle system and free the associated resources
  127364. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  127365. */
  127366. dispose(disposeTexture?: boolean): void;
  127367. /**
  127368. * Clones the particle system.
  127369. * @param name The name of the cloned object
  127370. * @param newEmitter The new emitter to use
  127371. * @returns the cloned particle system
  127372. */
  127373. clone(name: string, newEmitter: any): GPUParticleSystem;
  127374. /**
  127375. * Serializes the particle system to a JSON object.
  127376. * @returns the JSON object
  127377. */
  127378. serialize(): any;
  127379. /**
  127380. * Parses a JSON object to create a GPU particle system.
  127381. * @param parsedParticleSystem The JSON object to parse
  127382. * @param scene The scene to create the particle system in
  127383. * @param rootUrl The root url to use to load external dependencies like texture
  127384. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  127385. * @returns the parsed GPU particle system
  127386. */
  127387. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  127388. }
  127389. }
  127390. declare module BABYLON {
  127391. /**
  127392. * Represents a set of particle systems working together to create a specific effect
  127393. */
  127394. export class ParticleSystemSet implements IDisposable {
  127395. /**
  127396. * Gets or sets base Assets URL
  127397. */
  127398. static BaseAssetsUrl: string;
  127399. private _emitterCreationOptions;
  127400. private _emitterNode;
  127401. /**
  127402. * Gets the particle system list
  127403. */
  127404. systems: IParticleSystem[];
  127405. /**
  127406. * Gets the emitter node used with this set
  127407. */
  127408. readonly emitterNode: Nullable<TransformNode>;
  127409. /**
  127410. * Creates a new emitter mesh as a sphere
  127411. * @param options defines the options used to create the sphere
  127412. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  127413. * @param scene defines the hosting scene
  127414. */
  127415. setEmitterAsSphere(options: {
  127416. diameter: number;
  127417. segments: number;
  127418. color: Color3;
  127419. }, renderingGroupId: number, scene: Scene): void;
  127420. /**
  127421. * Starts all particle systems of the set
  127422. * @param emitter defines an optional mesh to use as emitter for the particle systems
  127423. */
  127424. start(emitter?: AbstractMesh): void;
  127425. /**
  127426. * Release all associated resources
  127427. */
  127428. dispose(): void;
  127429. /**
  127430. * Serialize the set into a JSON compatible object
  127431. * @returns a JSON compatible representation of the set
  127432. */
  127433. serialize(): any;
  127434. /**
  127435. * Parse a new ParticleSystemSet from a serialized source
  127436. * @param data defines a JSON compatible representation of the set
  127437. * @param scene defines the hosting scene
  127438. * @param gpu defines if we want GPU particles or CPU particles
  127439. * @returns a new ParticleSystemSet
  127440. */
  127441. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  127442. }
  127443. }
  127444. declare module BABYLON {
  127445. /**
  127446. * This class is made for on one-liner static method to help creating particle system set.
  127447. */
  127448. export class ParticleHelper {
  127449. /**
  127450. * Gets or sets base Assets URL
  127451. */
  127452. static BaseAssetsUrl: string;
  127453. /**
  127454. * Create a default particle system that you can tweak
  127455. * @param emitter defines the emitter to use
  127456. * @param capacity defines the system capacity (default is 500 particles)
  127457. * @param scene defines the hosting scene
  127458. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  127459. * @returns the new Particle system
  127460. */
  127461. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  127462. /**
  127463. * This is the main static method (one-liner) of this helper to create different particle systems
  127464. * @param type This string represents the type to the particle system to create
  127465. * @param scene The scene where the particle system should live
  127466. * @param gpu If the system will use gpu
  127467. * @returns the ParticleSystemSet created
  127468. */
  127469. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  127470. /**
  127471. * Static function used to export a particle system to a ParticleSystemSet variable.
  127472. * Please note that the emitter shape is not exported
  127473. * @param systems defines the particle systems to export
  127474. * @returns the created particle system set
  127475. */
  127476. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  127477. }
  127478. }
  127479. declare module BABYLON {
  127480. interface Engine {
  127481. /**
  127482. * Create an effect to use with particle systems.
  127483. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  127484. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  127485. * @param uniformsNames defines a list of attribute names
  127486. * @param samplers defines an array of string used to represent textures
  127487. * @param defines defines the string containing the defines to use to compile the shaders
  127488. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  127489. * @param onCompiled defines a function to call when the effect creation is successful
  127490. * @param onError defines a function to call when the effect creation has failed
  127491. * @returns the new Effect
  127492. */
  127493. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  127494. }
  127495. interface Mesh {
  127496. /**
  127497. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  127498. * @returns an array of IParticleSystem
  127499. */
  127500. getEmittedParticleSystems(): IParticleSystem[];
  127501. /**
  127502. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  127503. * @returns an array of IParticleSystem
  127504. */
  127505. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  127506. }
  127507. /**
  127508. * @hidden
  127509. */
  127510. export var _IDoNeedToBeInTheBuild: number;
  127511. }
  127512. declare module BABYLON {
  127513. /** Defines the 4 color options */
  127514. export enum PointColor {
  127515. /** color value */
  127516. Color = 2,
  127517. /** uv value */
  127518. UV = 1,
  127519. /** random value */
  127520. Random = 0,
  127521. /** stated value */
  127522. Stated = 3
  127523. }
  127524. /**
  127525. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  127526. * 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.
  127527. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  127528. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  127529. *
  127530. * Full documentation here : TO BE ENTERED
  127531. */
  127532. export class PointsCloudSystem implements IDisposable {
  127533. /**
  127534. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  127535. * Example : var p = SPS.particles[i];
  127536. */
  127537. particles: CloudPoint[];
  127538. /**
  127539. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  127540. */
  127541. nbParticles: number;
  127542. /**
  127543. * This a counter for your own usage. It's not set by any SPS functions.
  127544. */
  127545. counter: number;
  127546. /**
  127547. * The PCS name. This name is also given to the underlying mesh.
  127548. */
  127549. name: string;
  127550. /**
  127551. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  127552. */
  127553. mesh: Mesh;
  127554. /**
  127555. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  127556. * Please read :
  127557. */
  127558. vars: any;
  127559. /**
  127560. * @hidden
  127561. */
  127562. _size: number;
  127563. private _scene;
  127564. private _promises;
  127565. private _positions;
  127566. private _indices;
  127567. private _normals;
  127568. private _colors;
  127569. private _uvs;
  127570. private _indices32;
  127571. private _positions32;
  127572. private _colors32;
  127573. private _uvs32;
  127574. private _updatable;
  127575. private _isVisibilityBoxLocked;
  127576. private _alwaysVisible;
  127577. private _groups;
  127578. private _groupCounter;
  127579. private _computeParticleColor;
  127580. private _computeParticleTexture;
  127581. private _computeParticleRotation;
  127582. private _computeBoundingBox;
  127583. private _isReady;
  127584. /**
  127585. * Creates a PCS (Points Cloud System) object
  127586. * @param name (String) is the PCS name, this will be the underlying mesh name
  127587. * @param pointSize (number) is the size for each point
  127588. * @param scene (Scene) is the scene in which the PCS is added
  127589. * @param options defines the options of the PCS e.g.
  127590. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  127591. */
  127592. constructor(name: string, pointSize: number, scene: Scene, options?: {
  127593. updatable?: boolean;
  127594. });
  127595. /**
  127596. * Builds the PCS underlying mesh. Returns a standard Mesh.
  127597. * If no points were added to the PCS, the returned mesh is just a single point.
  127598. * @returns a promise for the created mesh
  127599. */
  127600. buildMeshAsync(): Promise<Mesh>;
  127601. /**
  127602. * @hidden
  127603. */
  127604. private _buildMesh;
  127605. private _addParticle;
  127606. private _randomUnitVector;
  127607. private _getColorIndicesForCoord;
  127608. private _setPointsColorOrUV;
  127609. private _colorFromTexture;
  127610. private _calculateDensity;
  127611. /**
  127612. * Adds points to the PCS in random positions within a unit sphere
  127613. * @param nb (positive integer) the number of particles to be created from this model
  127614. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  127615. * @returns the number of groups in the system
  127616. */
  127617. addPoints(nb: number, pointFunction?: any): number;
  127618. /**
  127619. * Adds points to the PCS from the surface of the model shape
  127620. * @param mesh is any Mesh object that will be used as a surface model for the points
  127621. * @param nb (positive integer) the number of particles to be created from this model
  127622. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  127623. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  127624. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  127625. * @returns the number of groups in the system
  127626. */
  127627. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  127628. /**
  127629. * Adds points to the PCS inside the model shape
  127630. * @param mesh is any Mesh object that will be used as a surface model for the points
  127631. * @param nb (positive integer) the number of particles to be created from this model
  127632. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  127633. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  127634. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  127635. * @returns the number of groups in the system
  127636. */
  127637. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  127638. /**
  127639. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  127640. * This method calls `updateParticle()` for each particle of the SPS.
  127641. * For an animated SPS, it is usually called within the render loop.
  127642. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  127643. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  127644. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  127645. * @returns the PCS.
  127646. */
  127647. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  127648. /**
  127649. * Disposes the PCS.
  127650. */
  127651. dispose(): void;
  127652. /**
  127653. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  127654. * doc :
  127655. * @returns the PCS.
  127656. */
  127657. refreshVisibleSize(): PointsCloudSystem;
  127658. /**
  127659. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  127660. * @param size the size (float) of the visibility box
  127661. * note : this doesn't lock the PCS mesh bounding box.
  127662. * doc :
  127663. */
  127664. setVisibilityBox(size: number): void;
  127665. /**
  127666. * Gets whether the PCS is always visible or not
  127667. * doc :
  127668. */
  127669. /**
  127670. * Sets the PCS as always visible or not
  127671. * doc :
  127672. */
  127673. isAlwaysVisible: boolean;
  127674. /**
  127675. * Tells to `setParticles()` to compute the particle rotations or not
  127676. * Default value : false. The PCS is faster when it's set to false
  127677. * Note : particle rotations are only applied to parent particles
  127678. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  127679. */
  127680. computeParticleRotation: boolean;
  127681. /**
  127682. * Tells to `setParticles()` to compute the particle colors or not.
  127683. * Default value : true. The PCS is faster when it's set to false.
  127684. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  127685. */
  127686. /**
  127687. * Gets if `setParticles()` computes the particle colors or not.
  127688. * Default value : false. The PCS is faster when it's set to false.
  127689. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  127690. */
  127691. computeParticleColor: boolean;
  127692. /**
  127693. * Gets if `setParticles()` computes the particle textures or not.
  127694. * Default value : false. The PCS is faster when it's set to false.
  127695. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  127696. */
  127697. computeParticleTexture: boolean;
  127698. /**
  127699. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  127700. */
  127701. /**
  127702. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  127703. */
  127704. computeBoundingBox: boolean;
  127705. /**
  127706. * This function does nothing. It may be overwritten to set all the particle first values.
  127707. * The PCS doesn't call this function, you may have to call it by your own.
  127708. * doc :
  127709. */
  127710. initParticles(): void;
  127711. /**
  127712. * This function does nothing. It may be overwritten to recycle a particle
  127713. * The PCS doesn't call this function, you can to call it
  127714. * doc :
  127715. * @param particle The particle to recycle
  127716. * @returns the recycled particle
  127717. */
  127718. recycleParticle(particle: CloudPoint): CloudPoint;
  127719. /**
  127720. * Updates a particle : this function should be overwritten by the user.
  127721. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  127722. * doc :
  127723. * @example : just set a particle position or velocity and recycle conditions
  127724. * @param particle The particle to update
  127725. * @returns the updated particle
  127726. */
  127727. updateParticle(particle: CloudPoint): CloudPoint;
  127728. /**
  127729. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  127730. * This does nothing and may be overwritten by the user.
  127731. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  127732. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  127733. * @param update the boolean update value actually passed to setParticles()
  127734. */
  127735. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  127736. /**
  127737. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  127738. * This will be passed three parameters.
  127739. * This does nothing and may be overwritten by the user.
  127740. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  127741. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  127742. * @param update the boolean update value actually passed to setParticles()
  127743. */
  127744. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  127745. }
  127746. }
  127747. declare module BABYLON {
  127748. /**
  127749. * Represents one particle of a points cloud system.
  127750. */
  127751. export class CloudPoint {
  127752. /**
  127753. * particle global index
  127754. */
  127755. idx: number;
  127756. /**
  127757. * The color of the particle
  127758. */
  127759. color: Nullable<Color4>;
  127760. /**
  127761. * The world space position of the particle.
  127762. */
  127763. position: Vector3;
  127764. /**
  127765. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  127766. */
  127767. rotation: Vector3;
  127768. /**
  127769. * The world space rotation quaternion of the particle.
  127770. */
  127771. rotationQuaternion: Nullable<Quaternion>;
  127772. /**
  127773. * The uv of the particle.
  127774. */
  127775. uv: Nullable<Vector2>;
  127776. /**
  127777. * The current speed of the particle.
  127778. */
  127779. velocity: Vector3;
  127780. /**
  127781. * The pivot point in the particle local space.
  127782. */
  127783. pivot: Vector3;
  127784. /**
  127785. * Must the particle be translated from its pivot point in its local space ?
  127786. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  127787. * Default : false
  127788. */
  127789. translateFromPivot: boolean;
  127790. /**
  127791. * Index of this particle in the global "positions" array (Internal use)
  127792. * @hidden
  127793. */
  127794. _pos: number;
  127795. /**
  127796. * @hidden Index of this particle in the global "indices" array (Internal use)
  127797. */
  127798. _ind: number;
  127799. /**
  127800. * Group this particle belongs to
  127801. */
  127802. _group: PointsGroup;
  127803. /**
  127804. * Group id of this particle
  127805. */
  127806. groupId: number;
  127807. /**
  127808. * Index of the particle in its group id (Internal use)
  127809. */
  127810. idxInGroup: number;
  127811. /**
  127812. * @hidden Particle BoundingInfo object (Internal use)
  127813. */
  127814. _boundingInfo: BoundingInfo;
  127815. /**
  127816. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  127817. */
  127818. _pcs: PointsCloudSystem;
  127819. /**
  127820. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  127821. */
  127822. _stillInvisible: boolean;
  127823. /**
  127824. * @hidden Last computed particle rotation matrix
  127825. */
  127826. _rotationMatrix: number[];
  127827. /**
  127828. * Parent particle Id, if any.
  127829. * Default null.
  127830. */
  127831. parentId: Nullable<number>;
  127832. /**
  127833. * @hidden Internal global position in the PCS.
  127834. */
  127835. _globalPosition: Vector3;
  127836. /**
  127837. * Creates a Point Cloud object.
  127838. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  127839. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  127840. * @param group (PointsGroup) is the group the particle belongs to
  127841. * @param groupId (integer) is the group identifier in the PCS.
  127842. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  127843. * @param pcs defines the PCS it is associated to
  127844. */
  127845. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  127846. /**
  127847. * get point size
  127848. */
  127849. /**
  127850. * Set point size
  127851. */
  127852. size: Vector3;
  127853. /**
  127854. * Legacy support, changed quaternion to rotationQuaternion
  127855. */
  127856. /**
  127857. * Legacy support, changed quaternion to rotationQuaternion
  127858. */
  127859. quaternion: Nullable<Quaternion>;
  127860. /**
  127861. * Returns a boolean. True if the particle intersects a mesh, else false
  127862. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  127863. * @param target is the object (point or mesh) what the intersection is computed against
  127864. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  127865. * @returns true if it intersects
  127866. */
  127867. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  127868. /**
  127869. * get the rotation matrix of the particle
  127870. * @hidden
  127871. */
  127872. getRotationMatrix(m: Matrix): void;
  127873. }
  127874. /**
  127875. * Represents a group of points in a points cloud system
  127876. * * PCS internal tool, don't use it manually.
  127877. */
  127878. export class PointsGroup {
  127879. /**
  127880. * The group id
  127881. * @hidden
  127882. */
  127883. groupID: number;
  127884. /**
  127885. * image data for group (internal use)
  127886. * @hidden
  127887. */
  127888. _groupImageData: Nullable<ArrayBufferView>;
  127889. /**
  127890. * Image Width (internal use)
  127891. * @hidden
  127892. */
  127893. _groupImgWidth: number;
  127894. /**
  127895. * Image Height (internal use)
  127896. * @hidden
  127897. */
  127898. _groupImgHeight: number;
  127899. /**
  127900. * Custom position function (internal use)
  127901. * @hidden
  127902. */
  127903. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  127904. /**
  127905. * density per facet for surface points
  127906. * @hidden
  127907. */
  127908. _groupDensity: number[];
  127909. /**
  127910. * Only when points are colored by texture carries pointer to texture list array
  127911. * @hidden
  127912. */
  127913. _textureNb: number;
  127914. /**
  127915. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  127916. * PCS internal tool, don't use it manually.
  127917. * @hidden
  127918. */
  127919. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  127920. }
  127921. }
  127922. declare module BABYLON {
  127923. interface Scene {
  127924. /** @hidden (Backing field) */
  127925. _physicsEngine: Nullable<IPhysicsEngine>;
  127926. /**
  127927. * Gets the current physics engine
  127928. * @returns a IPhysicsEngine or null if none attached
  127929. */
  127930. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  127931. /**
  127932. * Enables physics to the current scene
  127933. * @param gravity defines the scene's gravity for the physics engine
  127934. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  127935. * @return a boolean indicating if the physics engine was initialized
  127936. */
  127937. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  127938. /**
  127939. * Disables and disposes the physics engine associated with the scene
  127940. */
  127941. disablePhysicsEngine(): void;
  127942. /**
  127943. * Gets a boolean indicating if there is an active physics engine
  127944. * @returns a boolean indicating if there is an active physics engine
  127945. */
  127946. isPhysicsEnabled(): boolean;
  127947. /**
  127948. * Deletes a physics compound impostor
  127949. * @param compound defines the compound to delete
  127950. */
  127951. deleteCompoundImpostor(compound: any): void;
  127952. /**
  127953. * An event triggered when physic simulation is about to be run
  127954. */
  127955. onBeforePhysicsObservable: Observable<Scene>;
  127956. /**
  127957. * An event triggered when physic simulation has been done
  127958. */
  127959. onAfterPhysicsObservable: Observable<Scene>;
  127960. }
  127961. interface AbstractMesh {
  127962. /** @hidden */
  127963. _physicsImpostor: Nullable<PhysicsImpostor>;
  127964. /**
  127965. * Gets or sets impostor used for physic simulation
  127966. * @see http://doc.babylonjs.com/features/physics_engine
  127967. */
  127968. physicsImpostor: Nullable<PhysicsImpostor>;
  127969. /**
  127970. * Gets the current physics impostor
  127971. * @see http://doc.babylonjs.com/features/physics_engine
  127972. * @returns a physics impostor or null
  127973. */
  127974. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  127975. /** Apply a physic impulse to the mesh
  127976. * @param force defines the force to apply
  127977. * @param contactPoint defines where to apply the force
  127978. * @returns the current mesh
  127979. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127980. */
  127981. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  127982. /**
  127983. * Creates a physic joint between two meshes
  127984. * @param otherMesh defines the other mesh to use
  127985. * @param pivot1 defines the pivot to use on this mesh
  127986. * @param pivot2 defines the pivot to use on the other mesh
  127987. * @param options defines additional options (can be plugin dependent)
  127988. * @returns the current mesh
  127989. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  127990. */
  127991. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  127992. /** @hidden */
  127993. _disposePhysicsObserver: Nullable<Observer<Node>>;
  127994. }
  127995. /**
  127996. * Defines the physics engine scene component responsible to manage a physics engine
  127997. */
  127998. export class PhysicsEngineSceneComponent implements ISceneComponent {
  127999. /**
  128000. * The component name helpful to identify the component in the list of scene components.
  128001. */
  128002. readonly name: string;
  128003. /**
  128004. * The scene the component belongs to.
  128005. */
  128006. scene: Scene;
  128007. /**
  128008. * Creates a new instance of the component for the given scene
  128009. * @param scene Defines the scene to register the component in
  128010. */
  128011. constructor(scene: Scene);
  128012. /**
  128013. * Registers the component in a given scene
  128014. */
  128015. register(): void;
  128016. /**
  128017. * Rebuilds the elements related to this component in case of
  128018. * context lost for instance.
  128019. */
  128020. rebuild(): void;
  128021. /**
  128022. * Disposes the component and the associated ressources
  128023. */
  128024. dispose(): void;
  128025. }
  128026. }
  128027. declare module BABYLON {
  128028. /**
  128029. * A helper for physics simulations
  128030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128031. */
  128032. export class PhysicsHelper {
  128033. private _scene;
  128034. private _physicsEngine;
  128035. /**
  128036. * Initializes the Physics helper
  128037. * @param scene Babylon.js scene
  128038. */
  128039. constructor(scene: Scene);
  128040. /**
  128041. * Applies a radial explosion impulse
  128042. * @param origin the origin of the explosion
  128043. * @param radiusOrEventOptions the radius or the options of radial explosion
  128044. * @param strength the explosion strength
  128045. * @param falloff possible options: Constant & Linear. Defaults to Constant
  128046. * @returns A physics radial explosion event, or null
  128047. */
  128048. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  128049. /**
  128050. * Applies a radial explosion force
  128051. * @param origin the origin of the explosion
  128052. * @param radiusOrEventOptions the radius or the options of radial explosion
  128053. * @param strength the explosion strength
  128054. * @param falloff possible options: Constant & Linear. Defaults to Constant
  128055. * @returns A physics radial explosion event, or null
  128056. */
  128057. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  128058. /**
  128059. * Creates a gravitational field
  128060. * @param origin the origin of the explosion
  128061. * @param radiusOrEventOptions the radius or the options of radial explosion
  128062. * @param strength the explosion strength
  128063. * @param falloff possible options: Constant & Linear. Defaults to Constant
  128064. * @returns A physics gravitational field event, or null
  128065. */
  128066. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  128067. /**
  128068. * Creates a physics updraft event
  128069. * @param origin the origin of the updraft
  128070. * @param radiusOrEventOptions the radius or the options of the updraft
  128071. * @param strength the strength of the updraft
  128072. * @param height the height of the updraft
  128073. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  128074. * @returns A physics updraft event, or null
  128075. */
  128076. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  128077. /**
  128078. * Creates a physics vortex event
  128079. * @param origin the of the vortex
  128080. * @param radiusOrEventOptions the radius or the options of the vortex
  128081. * @param strength the strength of the vortex
  128082. * @param height the height of the vortex
  128083. * @returns a Physics vortex event, or null
  128084. * A physics vortex event or null
  128085. */
  128086. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  128087. }
  128088. /**
  128089. * Represents a physics radial explosion event
  128090. */
  128091. class PhysicsRadialExplosionEvent {
  128092. private _scene;
  128093. private _options;
  128094. private _sphere;
  128095. private _dataFetched;
  128096. /**
  128097. * Initializes a radial explosioin event
  128098. * @param _scene BabylonJS scene
  128099. * @param _options The options for the vortex event
  128100. */
  128101. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  128102. /**
  128103. * Returns the data related to the radial explosion event (sphere).
  128104. * @returns The radial explosion event data
  128105. */
  128106. getData(): PhysicsRadialExplosionEventData;
  128107. /**
  128108. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  128109. * @param impostor A physics imposter
  128110. * @param origin the origin of the explosion
  128111. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  128112. */
  128113. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  128114. /**
  128115. * Triggers affecterd impostors callbacks
  128116. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  128117. */
  128118. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  128119. /**
  128120. * Disposes the sphere.
  128121. * @param force Specifies if the sphere should be disposed by force
  128122. */
  128123. dispose(force?: boolean): void;
  128124. /*** Helpers ***/
  128125. private _prepareSphere;
  128126. private _intersectsWithSphere;
  128127. }
  128128. /**
  128129. * Represents a gravitational field event
  128130. */
  128131. class PhysicsGravitationalFieldEvent {
  128132. private _physicsHelper;
  128133. private _scene;
  128134. private _origin;
  128135. private _options;
  128136. private _tickCallback;
  128137. private _sphere;
  128138. private _dataFetched;
  128139. /**
  128140. * Initializes the physics gravitational field event
  128141. * @param _physicsHelper A physics helper
  128142. * @param _scene BabylonJS scene
  128143. * @param _origin The origin position of the gravitational field event
  128144. * @param _options The options for the vortex event
  128145. */
  128146. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  128147. /**
  128148. * Returns the data related to the gravitational field event (sphere).
  128149. * @returns A gravitational field event
  128150. */
  128151. getData(): PhysicsGravitationalFieldEventData;
  128152. /**
  128153. * Enables the gravitational field.
  128154. */
  128155. enable(): void;
  128156. /**
  128157. * Disables the gravitational field.
  128158. */
  128159. disable(): void;
  128160. /**
  128161. * Disposes the sphere.
  128162. * @param force The force to dispose from the gravitational field event
  128163. */
  128164. dispose(force?: boolean): void;
  128165. private _tick;
  128166. }
  128167. /**
  128168. * Represents a physics updraft event
  128169. */
  128170. class PhysicsUpdraftEvent {
  128171. private _scene;
  128172. private _origin;
  128173. private _options;
  128174. private _physicsEngine;
  128175. private _originTop;
  128176. private _originDirection;
  128177. private _tickCallback;
  128178. private _cylinder;
  128179. private _cylinderPosition;
  128180. private _dataFetched;
  128181. /**
  128182. * Initializes the physics updraft event
  128183. * @param _scene BabylonJS scene
  128184. * @param _origin The origin position of the updraft
  128185. * @param _options The options for the updraft event
  128186. */
  128187. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  128188. /**
  128189. * Returns the data related to the updraft event (cylinder).
  128190. * @returns A physics updraft event
  128191. */
  128192. getData(): PhysicsUpdraftEventData;
  128193. /**
  128194. * Enables the updraft.
  128195. */
  128196. enable(): void;
  128197. /**
  128198. * Disables the updraft.
  128199. */
  128200. disable(): void;
  128201. /**
  128202. * Disposes the cylinder.
  128203. * @param force Specifies if the updraft should be disposed by force
  128204. */
  128205. dispose(force?: boolean): void;
  128206. private getImpostorHitData;
  128207. private _tick;
  128208. /*** Helpers ***/
  128209. private _prepareCylinder;
  128210. private _intersectsWithCylinder;
  128211. }
  128212. /**
  128213. * Represents a physics vortex event
  128214. */
  128215. class PhysicsVortexEvent {
  128216. private _scene;
  128217. private _origin;
  128218. private _options;
  128219. private _physicsEngine;
  128220. private _originTop;
  128221. private _tickCallback;
  128222. private _cylinder;
  128223. private _cylinderPosition;
  128224. private _dataFetched;
  128225. /**
  128226. * Initializes the physics vortex event
  128227. * @param _scene The BabylonJS scene
  128228. * @param _origin The origin position of the vortex
  128229. * @param _options The options for the vortex event
  128230. */
  128231. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  128232. /**
  128233. * Returns the data related to the vortex event (cylinder).
  128234. * @returns The physics vortex event data
  128235. */
  128236. getData(): PhysicsVortexEventData;
  128237. /**
  128238. * Enables the vortex.
  128239. */
  128240. enable(): void;
  128241. /**
  128242. * Disables the cortex.
  128243. */
  128244. disable(): void;
  128245. /**
  128246. * Disposes the sphere.
  128247. * @param force
  128248. */
  128249. dispose(force?: boolean): void;
  128250. private getImpostorHitData;
  128251. private _tick;
  128252. /*** Helpers ***/
  128253. private _prepareCylinder;
  128254. private _intersectsWithCylinder;
  128255. }
  128256. /**
  128257. * Options fot the radial explosion event
  128258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128259. */
  128260. export class PhysicsRadialExplosionEventOptions {
  128261. /**
  128262. * The radius of the sphere for the radial explosion.
  128263. */
  128264. radius: number;
  128265. /**
  128266. * The strenth of the explosion.
  128267. */
  128268. strength: number;
  128269. /**
  128270. * The strenght of the force in correspondence to the distance of the affected object
  128271. */
  128272. falloff: PhysicsRadialImpulseFalloff;
  128273. /**
  128274. * Sphere options for the radial explosion.
  128275. */
  128276. sphere: {
  128277. segments: number;
  128278. diameter: number;
  128279. };
  128280. /**
  128281. * Sphere options for the radial explosion.
  128282. */
  128283. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  128284. }
  128285. /**
  128286. * Options fot the updraft event
  128287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128288. */
  128289. export class PhysicsUpdraftEventOptions {
  128290. /**
  128291. * The radius of the cylinder for the vortex
  128292. */
  128293. radius: number;
  128294. /**
  128295. * The strenth of the updraft.
  128296. */
  128297. strength: number;
  128298. /**
  128299. * The height of the cylinder for the updraft.
  128300. */
  128301. height: number;
  128302. /**
  128303. * The mode for the the updraft.
  128304. */
  128305. updraftMode: PhysicsUpdraftMode;
  128306. }
  128307. /**
  128308. * Options fot the vortex event
  128309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128310. */
  128311. export class PhysicsVortexEventOptions {
  128312. /**
  128313. * The radius of the cylinder for the vortex
  128314. */
  128315. radius: number;
  128316. /**
  128317. * The strenth of the vortex.
  128318. */
  128319. strength: number;
  128320. /**
  128321. * The height of the cylinder for the vortex.
  128322. */
  128323. height: number;
  128324. /**
  128325. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  128326. */
  128327. centripetalForceThreshold: number;
  128328. /**
  128329. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  128330. */
  128331. centripetalForceMultiplier: number;
  128332. /**
  128333. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  128334. */
  128335. centrifugalForceMultiplier: number;
  128336. /**
  128337. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  128338. */
  128339. updraftForceMultiplier: number;
  128340. }
  128341. /**
  128342. * The strenght of the force in correspondence to the distance of the affected object
  128343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128344. */
  128345. export enum PhysicsRadialImpulseFalloff {
  128346. /** Defines that impulse is constant in strength across it's whole radius */
  128347. Constant = 0,
  128348. /** Defines that impulse gets weaker if it's further from the origin */
  128349. Linear = 1
  128350. }
  128351. /**
  128352. * The strength of the force in correspondence to the distance of the affected object
  128353. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128354. */
  128355. export enum PhysicsUpdraftMode {
  128356. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  128357. Center = 0,
  128358. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  128359. Perpendicular = 1
  128360. }
  128361. /**
  128362. * Interface for a physics hit data
  128363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128364. */
  128365. export interface PhysicsHitData {
  128366. /**
  128367. * The force applied at the contact point
  128368. */
  128369. force: Vector3;
  128370. /**
  128371. * The contact point
  128372. */
  128373. contactPoint: Vector3;
  128374. /**
  128375. * The distance from the origin to the contact point
  128376. */
  128377. distanceFromOrigin: number;
  128378. }
  128379. /**
  128380. * Interface for radial explosion event data
  128381. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128382. */
  128383. export interface PhysicsRadialExplosionEventData {
  128384. /**
  128385. * A sphere used for the radial explosion event
  128386. */
  128387. sphere: Mesh;
  128388. }
  128389. /**
  128390. * Interface for gravitational field event data
  128391. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128392. */
  128393. export interface PhysicsGravitationalFieldEventData {
  128394. /**
  128395. * A sphere mesh used for the gravitational field event
  128396. */
  128397. sphere: Mesh;
  128398. }
  128399. /**
  128400. * Interface for updraft event data
  128401. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128402. */
  128403. export interface PhysicsUpdraftEventData {
  128404. /**
  128405. * A cylinder used for the updraft event
  128406. */
  128407. cylinder: Mesh;
  128408. }
  128409. /**
  128410. * Interface for vortex event data
  128411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128412. */
  128413. export interface PhysicsVortexEventData {
  128414. /**
  128415. * A cylinder used for the vortex event
  128416. */
  128417. cylinder: Mesh;
  128418. }
  128419. /**
  128420. * Interface for an affected physics impostor
  128421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128422. */
  128423. export interface PhysicsAffectedImpostorWithData {
  128424. /**
  128425. * The impostor affected by the effect
  128426. */
  128427. impostor: PhysicsImpostor;
  128428. /**
  128429. * The data about the hit/horce from the explosion
  128430. */
  128431. hitData: PhysicsHitData;
  128432. }
  128433. }
  128434. declare module BABYLON {
  128435. /** @hidden */
  128436. export var blackAndWhitePixelShader: {
  128437. name: string;
  128438. shader: string;
  128439. };
  128440. }
  128441. declare module BABYLON {
  128442. /**
  128443. * Post process used to render in black and white
  128444. */
  128445. export class BlackAndWhitePostProcess extends PostProcess {
  128446. /**
  128447. * Linear about to convert he result to black and white (default: 1)
  128448. */
  128449. degree: number;
  128450. /**
  128451. * Creates a black and white post process
  128452. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  128453. * @param name The name of the effect.
  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. */
  128460. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128461. }
  128462. }
  128463. declare module BABYLON {
  128464. /**
  128465. * This represents a set of one or more post processes in Babylon.
  128466. * A post process can be used to apply a shader to a texture after it is rendered.
  128467. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128468. */
  128469. export class PostProcessRenderEffect {
  128470. private _postProcesses;
  128471. private _getPostProcesses;
  128472. private _singleInstance;
  128473. private _cameras;
  128474. private _indicesForCamera;
  128475. /**
  128476. * Name of the effect
  128477. * @hidden
  128478. */
  128479. _name: string;
  128480. /**
  128481. * Instantiates a post process render effect.
  128482. * A post process can be used to apply a shader to a texture after it is rendered.
  128483. * @param engine The engine the effect is tied to
  128484. * @param name The name of the effect
  128485. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  128486. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  128487. */
  128488. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  128489. /**
  128490. * Checks if all the post processes in the effect are supported.
  128491. */
  128492. readonly isSupported: boolean;
  128493. /**
  128494. * Updates the current state of the effect
  128495. * @hidden
  128496. */
  128497. _update(): void;
  128498. /**
  128499. * Attaches the effect on cameras
  128500. * @param cameras The camera to attach to.
  128501. * @hidden
  128502. */
  128503. _attachCameras(cameras: Camera): void;
  128504. /**
  128505. * Attaches the effect on cameras
  128506. * @param cameras The camera to attach to.
  128507. * @hidden
  128508. */
  128509. _attachCameras(cameras: Camera[]): void;
  128510. /**
  128511. * Detaches the effect on cameras
  128512. * @param cameras The camera to detatch from.
  128513. * @hidden
  128514. */
  128515. _detachCameras(cameras: Camera): void;
  128516. /**
  128517. * Detatches the effect on cameras
  128518. * @param cameras The camera to detatch from.
  128519. * @hidden
  128520. */
  128521. _detachCameras(cameras: Camera[]): void;
  128522. /**
  128523. * Enables the effect on given cameras
  128524. * @param cameras The camera to enable.
  128525. * @hidden
  128526. */
  128527. _enable(cameras: Camera): void;
  128528. /**
  128529. * Enables the effect on given cameras
  128530. * @param cameras The camera to enable.
  128531. * @hidden
  128532. */
  128533. _enable(cameras: Nullable<Camera[]>): void;
  128534. /**
  128535. * Disables the effect on the given cameras
  128536. * @param cameras The camera to disable.
  128537. * @hidden
  128538. */
  128539. _disable(cameras: Camera): void;
  128540. /**
  128541. * Disables the effect on the given cameras
  128542. * @param cameras The camera to disable.
  128543. * @hidden
  128544. */
  128545. _disable(cameras: Nullable<Camera[]>): void;
  128546. /**
  128547. * Gets a list of the post processes contained in the effect.
  128548. * @param camera The camera to get the post processes on.
  128549. * @returns The list of the post processes in the effect.
  128550. */
  128551. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  128552. }
  128553. }
  128554. declare module BABYLON {
  128555. /** @hidden */
  128556. export var extractHighlightsPixelShader: {
  128557. name: string;
  128558. shader: string;
  128559. };
  128560. }
  128561. declare module BABYLON {
  128562. /**
  128563. * 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.
  128564. */
  128565. export class ExtractHighlightsPostProcess extends PostProcess {
  128566. /**
  128567. * The luminance threshold, pixels below this value will be set to black.
  128568. */
  128569. threshold: number;
  128570. /** @hidden */
  128571. _exposure: number;
  128572. /**
  128573. * Post process which has the input texture to be used when performing highlight extraction
  128574. * @hidden
  128575. */
  128576. _inputPostProcess: Nullable<PostProcess>;
  128577. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128578. }
  128579. }
  128580. declare module BABYLON {
  128581. /** @hidden */
  128582. export var bloomMergePixelShader: {
  128583. name: string;
  128584. shader: string;
  128585. };
  128586. }
  128587. declare module BABYLON {
  128588. /**
  128589. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  128590. */
  128591. export class BloomMergePostProcess extends PostProcess {
  128592. /** Weight of the bloom to be added to the original input. */
  128593. weight: number;
  128594. /**
  128595. * Creates a new instance of @see BloomMergePostProcess
  128596. * @param name The name of the effect.
  128597. * @param originalFromInput Post process which's input will be used for the merge.
  128598. * @param blurred Blurred highlights post process which's output will be used.
  128599. * @param weight Weight of the bloom to be added to the original input.
  128600. * @param options The required width/height ratio to downsize to before computing the render pass.
  128601. * @param camera The camera to apply the render pass to.
  128602. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128603. * @param engine The engine which the post process will be applied. (default: current engine)
  128604. * @param reusable If the post process can be reused on the same frame. (default: false)
  128605. * @param textureType Type of textures used when performing the post process. (default: 0)
  128606. * @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)
  128607. */
  128608. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  128609. /** Weight of the bloom to be added to the original input. */
  128610. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128611. }
  128612. }
  128613. declare module BABYLON {
  128614. /**
  128615. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  128616. */
  128617. export class BloomEffect extends PostProcessRenderEffect {
  128618. private bloomScale;
  128619. /**
  128620. * @hidden Internal
  128621. */
  128622. _effects: Array<PostProcess>;
  128623. /**
  128624. * @hidden Internal
  128625. */
  128626. _downscale: ExtractHighlightsPostProcess;
  128627. private _blurX;
  128628. private _blurY;
  128629. private _merge;
  128630. /**
  128631. * The luminance threshold to find bright areas of the image to bloom.
  128632. */
  128633. threshold: number;
  128634. /**
  128635. * The strength of the bloom.
  128636. */
  128637. weight: number;
  128638. /**
  128639. * Specifies the size of the bloom blur kernel, relative to the final output size
  128640. */
  128641. kernel: number;
  128642. /**
  128643. * Creates a new instance of @see BloomEffect
  128644. * @param scene The scene the effect belongs to.
  128645. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  128646. * @param bloomKernel The size of the kernel to be used when applying the blur.
  128647. * @param bloomWeight The the strength of bloom.
  128648. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  128649. * @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)
  128650. */
  128651. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  128652. /**
  128653. * Disposes each of the internal effects for a given camera.
  128654. * @param camera The camera to dispose the effect on.
  128655. */
  128656. disposeEffects(camera: Camera): void;
  128657. /**
  128658. * @hidden Internal
  128659. */
  128660. _updateEffects(): void;
  128661. /**
  128662. * Internal
  128663. * @returns if all the contained post processes are ready.
  128664. * @hidden
  128665. */
  128666. _isReady(): boolean;
  128667. }
  128668. }
  128669. declare module BABYLON {
  128670. /** @hidden */
  128671. export var chromaticAberrationPixelShader: {
  128672. name: string;
  128673. shader: string;
  128674. };
  128675. }
  128676. declare module BABYLON {
  128677. /**
  128678. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  128679. */
  128680. export class ChromaticAberrationPostProcess extends PostProcess {
  128681. /**
  128682. * The amount of seperation of rgb channels (default: 30)
  128683. */
  128684. aberrationAmount: number;
  128685. /**
  128686. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  128687. */
  128688. radialIntensity: number;
  128689. /**
  128690. * 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))
  128691. */
  128692. direction: Vector2;
  128693. /**
  128694. * 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))
  128695. */
  128696. centerPosition: Vector2;
  128697. /**
  128698. * Creates a new instance ChromaticAberrationPostProcess
  128699. * @param name The name of the effect.
  128700. * @param screenWidth The width of the screen to apply the effect on.
  128701. * @param screenHeight The height of the screen to apply the effect on.
  128702. * @param options The required width/height ratio to downsize to before computing the render pass.
  128703. * @param camera The camera to apply the render pass to.
  128704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128705. * @param engine The engine which the post process will be applied. (default: current engine)
  128706. * @param reusable If the post process can be reused on the same frame. (default: false)
  128707. * @param textureType Type of textures used when performing the post process. (default: 0)
  128708. * @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)
  128709. */
  128710. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128711. }
  128712. }
  128713. declare module BABYLON {
  128714. /** @hidden */
  128715. export var circleOfConfusionPixelShader: {
  128716. name: string;
  128717. shader: string;
  128718. };
  128719. }
  128720. declare module BABYLON {
  128721. /**
  128722. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  128723. */
  128724. export class CircleOfConfusionPostProcess extends PostProcess {
  128725. /**
  128726. * 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.
  128727. */
  128728. lensSize: number;
  128729. /**
  128730. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  128731. */
  128732. fStop: number;
  128733. /**
  128734. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  128735. */
  128736. focusDistance: number;
  128737. /**
  128738. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  128739. */
  128740. focalLength: number;
  128741. private _depthTexture;
  128742. /**
  128743. * Creates a new instance CircleOfConfusionPostProcess
  128744. * @param name The name of the effect.
  128745. * @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.
  128746. * @param options The required width/height ratio to downsize to before computing the render pass.
  128747. * @param camera The camera to apply the render pass to.
  128748. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128749. * @param engine The engine which the post process will be applied. (default: current engine)
  128750. * @param reusable If the post process can be reused on the same frame. (default: false)
  128751. * @param textureType Type of textures used when performing the post process. (default: 0)
  128752. * @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)
  128753. */
  128754. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128755. /**
  128756. * 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.
  128757. */
  128758. depthTexture: RenderTargetTexture;
  128759. }
  128760. }
  128761. declare module BABYLON {
  128762. /** @hidden */
  128763. export var colorCorrectionPixelShader: {
  128764. name: string;
  128765. shader: string;
  128766. };
  128767. }
  128768. declare module BABYLON {
  128769. /**
  128770. *
  128771. * This post-process allows the modification of rendered colors by using
  128772. * a 'look-up table' (LUT). This effect is also called Color Grading.
  128773. *
  128774. * The object needs to be provided an url to a texture containing the color
  128775. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  128776. * Use an image editing software to tweak the LUT to match your needs.
  128777. *
  128778. * For an example of a color LUT, see here:
  128779. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  128780. * For explanations on color grading, see here:
  128781. * @see http://udn.epicgames.com/Three/ColorGrading.html
  128782. *
  128783. */
  128784. export class ColorCorrectionPostProcess extends PostProcess {
  128785. private _colorTableTexture;
  128786. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128787. }
  128788. }
  128789. declare module BABYLON {
  128790. /** @hidden */
  128791. export var convolutionPixelShader: {
  128792. name: string;
  128793. shader: string;
  128794. };
  128795. }
  128796. declare module BABYLON {
  128797. /**
  128798. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  128799. * input texture to perform effects such as edge detection or sharpening
  128800. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  128801. */
  128802. export class ConvolutionPostProcess extends PostProcess {
  128803. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  128804. kernel: number[];
  128805. /**
  128806. * Creates a new instance ConvolutionPostProcess
  128807. * @param name The name of the effect.
  128808. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  128809. * @param options The required width/height ratio to downsize to before computing the render pass.
  128810. * @param camera The camera to apply the render pass to.
  128811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128812. * @param engine The engine which the post process will be applied. (default: current engine)
  128813. * @param reusable If the post process can be reused on the same frame. (default: false)
  128814. * @param textureType Type of textures used when performing the post process. (default: 0)
  128815. */
  128816. constructor(name: string,
  128817. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  128818. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128819. /**
  128820. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128821. */
  128822. static EdgeDetect0Kernel: number[];
  128823. /**
  128824. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128825. */
  128826. static EdgeDetect1Kernel: number[];
  128827. /**
  128828. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128829. */
  128830. static EdgeDetect2Kernel: number[];
  128831. /**
  128832. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128833. */
  128834. static SharpenKernel: number[];
  128835. /**
  128836. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128837. */
  128838. static EmbossKernel: number[];
  128839. /**
  128840. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128841. */
  128842. static GaussianKernel: number[];
  128843. }
  128844. }
  128845. declare module BABYLON {
  128846. /**
  128847. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  128848. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  128849. * based on samples that have a large difference in distance than the center pixel.
  128850. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  128851. */
  128852. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  128853. direction: Vector2;
  128854. /**
  128855. * Creates a new instance CircleOfConfusionPostProcess
  128856. * @param name The name of the effect.
  128857. * @param scene The scene the effect belongs to.
  128858. * @param direction The direction the blur should be applied.
  128859. * @param kernel The size of the kernel used to blur.
  128860. * @param options The required width/height ratio to downsize to before computing the render pass.
  128861. * @param camera The camera to apply the render pass to.
  128862. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  128863. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  128864. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128865. * @param engine The engine which the post process will be applied. (default: current engine)
  128866. * @param reusable If the post process can be reused on the same frame. (default: false)
  128867. * @param textureType Type of textures used when performing the post process. (default: 0)
  128868. * @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)
  128869. */
  128870. 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);
  128871. }
  128872. }
  128873. declare module BABYLON {
  128874. /** @hidden */
  128875. export var depthOfFieldMergePixelShader: {
  128876. name: string;
  128877. shader: string;
  128878. };
  128879. }
  128880. declare module BABYLON {
  128881. /**
  128882. * Options to be set when merging outputs from the default pipeline.
  128883. */
  128884. export class DepthOfFieldMergePostProcessOptions {
  128885. /**
  128886. * The original image to merge on top of
  128887. */
  128888. originalFromInput: PostProcess;
  128889. /**
  128890. * Parameters to perform the merge of the depth of field effect
  128891. */
  128892. depthOfField?: {
  128893. circleOfConfusion: PostProcess;
  128894. blurSteps: Array<PostProcess>;
  128895. };
  128896. /**
  128897. * Parameters to perform the merge of bloom effect
  128898. */
  128899. bloom?: {
  128900. blurred: PostProcess;
  128901. weight: number;
  128902. };
  128903. }
  128904. /**
  128905. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  128906. */
  128907. export class DepthOfFieldMergePostProcess extends PostProcess {
  128908. private blurSteps;
  128909. /**
  128910. * Creates a new instance of DepthOfFieldMergePostProcess
  128911. * @param name The name of the effect.
  128912. * @param originalFromInput Post process which's input will be used for the merge.
  128913. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  128914. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  128915. * @param options The required width/height ratio to downsize to before computing the render pass.
  128916. * @param camera The camera to apply the render pass to.
  128917. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128918. * @param engine The engine which the post process will be applied. (default: current engine)
  128919. * @param reusable If the post process can be reused on the same frame. (default: false)
  128920. * @param textureType Type of textures used when performing the post process. (default: 0)
  128921. * @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)
  128922. */
  128923. 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);
  128924. /**
  128925. * Updates the effect with the current post process compile time values and recompiles the shader.
  128926. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  128927. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  128928. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  128929. * @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
  128930. * @param onCompiled Called when the shader has been compiled.
  128931. * @param onError Called if there is an error when compiling a shader.
  128932. */
  128933. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  128934. }
  128935. }
  128936. declare module BABYLON {
  128937. /**
  128938. * Specifies the level of max blur that should be applied when using the depth of field effect
  128939. */
  128940. export enum DepthOfFieldEffectBlurLevel {
  128941. /**
  128942. * Subtle blur
  128943. */
  128944. Low = 0,
  128945. /**
  128946. * Medium blur
  128947. */
  128948. Medium = 1,
  128949. /**
  128950. * Large blur
  128951. */
  128952. High = 2
  128953. }
  128954. /**
  128955. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  128956. */
  128957. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  128958. private _circleOfConfusion;
  128959. /**
  128960. * @hidden Internal, blurs from high to low
  128961. */
  128962. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  128963. private _depthOfFieldBlurY;
  128964. private _dofMerge;
  128965. /**
  128966. * @hidden Internal post processes in depth of field effect
  128967. */
  128968. _effects: Array<PostProcess>;
  128969. /**
  128970. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  128971. */
  128972. focalLength: number;
  128973. /**
  128974. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  128975. */
  128976. fStop: number;
  128977. /**
  128978. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  128979. */
  128980. focusDistance: number;
  128981. /**
  128982. * 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.
  128983. */
  128984. lensSize: number;
  128985. /**
  128986. * Creates a new instance DepthOfFieldEffect
  128987. * @param scene The scene the effect belongs to.
  128988. * @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.
  128989. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  128990. * @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)
  128991. */
  128992. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  128993. /**
  128994. * Get the current class name of the current effet
  128995. * @returns "DepthOfFieldEffect"
  128996. */
  128997. getClassName(): string;
  128998. /**
  128999. * 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.
  129000. */
  129001. depthTexture: RenderTargetTexture;
  129002. /**
  129003. * Disposes each of the internal effects for a given camera.
  129004. * @param camera The camera to dispose the effect on.
  129005. */
  129006. disposeEffects(camera: Camera): void;
  129007. /**
  129008. * @hidden Internal
  129009. */
  129010. _updateEffects(): void;
  129011. /**
  129012. * Internal
  129013. * @returns if all the contained post processes are ready.
  129014. * @hidden
  129015. */
  129016. _isReady(): boolean;
  129017. }
  129018. }
  129019. declare module BABYLON {
  129020. /** @hidden */
  129021. export var displayPassPixelShader: {
  129022. name: string;
  129023. shader: string;
  129024. };
  129025. }
  129026. declare module BABYLON {
  129027. /**
  129028. * DisplayPassPostProcess which produces an output the same as it's input
  129029. */
  129030. export class DisplayPassPostProcess extends PostProcess {
  129031. /**
  129032. * Creates the DisplayPassPostProcess
  129033. * @param name The name of the effect.
  129034. * @param options The required width/height ratio to downsize to before computing the render pass.
  129035. * @param camera The camera to apply the render pass to.
  129036. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129037. * @param engine The engine which the post process will be applied. (default: current engine)
  129038. * @param reusable If the post process can be reused on the same frame. (default: false)
  129039. */
  129040. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129041. }
  129042. }
  129043. declare module BABYLON {
  129044. /** @hidden */
  129045. export var filterPixelShader: {
  129046. name: string;
  129047. shader: string;
  129048. };
  129049. }
  129050. declare module BABYLON {
  129051. /**
  129052. * Applies a kernel filter to the image
  129053. */
  129054. export class FilterPostProcess extends PostProcess {
  129055. /** The matrix to be applied to the image */
  129056. kernelMatrix: Matrix;
  129057. /**
  129058. *
  129059. * @param name The name of the effect.
  129060. * @param kernelMatrix The matrix to be applied to the image
  129061. * @param options The required width/height ratio to downsize to before computing the render pass.
  129062. * @param camera The camera to apply the render pass to.
  129063. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129064. * @param engine The engine which the post process will be applied. (default: current engine)
  129065. * @param reusable If the post process can be reused on the same frame. (default: false)
  129066. */
  129067. constructor(name: string,
  129068. /** The matrix to be applied to the image */
  129069. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129070. }
  129071. }
  129072. declare module BABYLON {
  129073. /** @hidden */
  129074. export var fxaaPixelShader: {
  129075. name: string;
  129076. shader: string;
  129077. };
  129078. }
  129079. declare module BABYLON {
  129080. /** @hidden */
  129081. export var fxaaVertexShader: {
  129082. name: string;
  129083. shader: string;
  129084. };
  129085. }
  129086. declare module BABYLON {
  129087. /**
  129088. * Fxaa post process
  129089. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  129090. */
  129091. export class FxaaPostProcess extends PostProcess {
  129092. /** @hidden */
  129093. texelWidth: number;
  129094. /** @hidden */
  129095. texelHeight: number;
  129096. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  129097. private _getDefines;
  129098. }
  129099. }
  129100. declare module BABYLON {
  129101. /** @hidden */
  129102. export var grainPixelShader: {
  129103. name: string;
  129104. shader: string;
  129105. };
  129106. }
  129107. declare module BABYLON {
  129108. /**
  129109. * The GrainPostProcess adds noise to the image at mid luminance levels
  129110. */
  129111. export class GrainPostProcess extends PostProcess {
  129112. /**
  129113. * The intensity of the grain added (default: 30)
  129114. */
  129115. intensity: number;
  129116. /**
  129117. * If the grain should be randomized on every frame
  129118. */
  129119. animated: boolean;
  129120. /**
  129121. * Creates a new instance of @see GrainPostProcess
  129122. * @param name The name of the effect.
  129123. * @param options The required width/height ratio to downsize to before computing the render pass.
  129124. * @param camera The camera to apply the render pass to.
  129125. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129126. * @param engine The engine which the post process will be applied. (default: current engine)
  129127. * @param reusable If the post process can be reused on the same frame. (default: false)
  129128. * @param textureType Type of textures used when performing the post process. (default: 0)
  129129. * @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)
  129130. */
  129131. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129132. }
  129133. }
  129134. declare module BABYLON {
  129135. /** @hidden */
  129136. export var highlightsPixelShader: {
  129137. name: string;
  129138. shader: string;
  129139. };
  129140. }
  129141. declare module BABYLON {
  129142. /**
  129143. * Extracts highlights from the image
  129144. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  129145. */
  129146. export class HighlightsPostProcess extends PostProcess {
  129147. /**
  129148. * Extracts highlights from the image
  129149. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  129150. * @param name The name of the effect.
  129151. * @param options The required width/height ratio to downsize to before computing the render pass.
  129152. * @param camera The camera to apply the render pass to.
  129153. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129154. * @param engine The engine which the post process will be applied. (default: current engine)
  129155. * @param reusable If the post process can be reused on the same frame. (default: false)
  129156. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  129157. */
  129158. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  129159. }
  129160. }
  129161. declare module BABYLON {
  129162. /** @hidden */
  129163. export var mrtFragmentDeclaration: {
  129164. name: string;
  129165. shader: string;
  129166. };
  129167. }
  129168. declare module BABYLON {
  129169. /** @hidden */
  129170. export var geometryPixelShader: {
  129171. name: string;
  129172. shader: string;
  129173. };
  129174. }
  129175. declare module BABYLON {
  129176. /** @hidden */
  129177. export var geometryVertexShader: {
  129178. name: string;
  129179. shader: string;
  129180. };
  129181. }
  129182. declare module BABYLON {
  129183. /** @hidden */
  129184. interface ISavedTransformationMatrix {
  129185. world: Matrix;
  129186. viewProjection: Matrix;
  129187. }
  129188. /**
  129189. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  129190. */
  129191. export class GeometryBufferRenderer {
  129192. /**
  129193. * Constant used to retrieve the position texture index in the G-Buffer textures array
  129194. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  129195. */
  129196. static readonly POSITION_TEXTURE_TYPE: number;
  129197. /**
  129198. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  129199. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  129200. */
  129201. static readonly VELOCITY_TEXTURE_TYPE: number;
  129202. /**
  129203. * Dictionary used to store the previous transformation matrices of each rendered mesh
  129204. * in order to compute objects velocities when enableVelocity is set to "true"
  129205. * @hidden
  129206. */
  129207. _previousTransformationMatrices: {
  129208. [index: number]: ISavedTransformationMatrix;
  129209. };
  129210. /**
  129211. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  129212. * in order to compute objects velocities when enableVelocity is set to "true"
  129213. * @hidden
  129214. */
  129215. _previousBonesTransformationMatrices: {
  129216. [index: number]: Float32Array;
  129217. };
  129218. /**
  129219. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  129220. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  129221. */
  129222. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  129223. private _scene;
  129224. private _multiRenderTarget;
  129225. private _ratio;
  129226. private _enablePosition;
  129227. private _enableVelocity;
  129228. private _positionIndex;
  129229. private _velocityIndex;
  129230. protected _effect: Effect;
  129231. protected _cachedDefines: string;
  129232. /**
  129233. * Set the render list (meshes to be rendered) used in the G buffer.
  129234. */
  129235. renderList: Mesh[];
  129236. /**
  129237. * Gets wether or not G buffer are supported by the running hardware.
  129238. * This requires draw buffer supports
  129239. */
  129240. readonly isSupported: boolean;
  129241. /**
  129242. * Returns the index of the given texture type in the G-Buffer textures array
  129243. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  129244. * @returns the index of the given texture type in the G-Buffer textures array
  129245. */
  129246. getTextureIndex(textureType: number): number;
  129247. /**
  129248. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  129249. */
  129250. /**
  129251. * Sets whether or not objects positions are enabled for the G buffer.
  129252. */
  129253. enablePosition: boolean;
  129254. /**
  129255. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  129256. */
  129257. /**
  129258. * Sets wether or not objects velocities are enabled for the G buffer.
  129259. */
  129260. enableVelocity: boolean;
  129261. /**
  129262. * Gets the scene associated with the buffer.
  129263. */
  129264. readonly scene: Scene;
  129265. /**
  129266. * Gets the ratio used by the buffer during its creation.
  129267. * How big is the buffer related to the main canvas.
  129268. */
  129269. readonly ratio: number;
  129270. /** @hidden */
  129271. static _SceneComponentInitialization: (scene: Scene) => void;
  129272. /**
  129273. * Creates a new G Buffer for the scene
  129274. * @param scene The scene the buffer belongs to
  129275. * @param ratio How big is the buffer related to the main canvas.
  129276. */
  129277. constructor(scene: Scene, ratio?: number);
  129278. /**
  129279. * Checks wether everything is ready to render a submesh to the G buffer.
  129280. * @param subMesh the submesh to check readiness for
  129281. * @param useInstances is the mesh drawn using instance or not
  129282. * @returns true if ready otherwise false
  129283. */
  129284. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129285. /**
  129286. * Gets the current underlying G Buffer.
  129287. * @returns the buffer
  129288. */
  129289. getGBuffer(): MultiRenderTarget;
  129290. /**
  129291. * Gets the number of samples used to render the buffer (anti aliasing).
  129292. */
  129293. /**
  129294. * Sets the number of samples used to render the buffer (anti aliasing).
  129295. */
  129296. samples: number;
  129297. /**
  129298. * Disposes the renderer and frees up associated resources.
  129299. */
  129300. dispose(): void;
  129301. protected _createRenderTargets(): void;
  129302. private _copyBonesTransformationMatrices;
  129303. }
  129304. }
  129305. declare module BABYLON {
  129306. interface Scene {
  129307. /** @hidden (Backing field) */
  129308. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  129309. /**
  129310. * Gets or Sets the current geometry buffer associated to the scene.
  129311. */
  129312. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  129313. /**
  129314. * Enables a GeometryBufferRender and associates it with the scene
  129315. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  129316. * @returns the GeometryBufferRenderer
  129317. */
  129318. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  129319. /**
  129320. * Disables the GeometryBufferRender associated with the scene
  129321. */
  129322. disableGeometryBufferRenderer(): void;
  129323. }
  129324. /**
  129325. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  129326. * in several rendering techniques.
  129327. */
  129328. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  129329. /**
  129330. * The component name helpful to identify the component in the list of scene components.
  129331. */
  129332. readonly name: string;
  129333. /**
  129334. * The scene the component belongs to.
  129335. */
  129336. scene: Scene;
  129337. /**
  129338. * Creates a new instance of the component for the given scene
  129339. * @param scene Defines the scene to register the component in
  129340. */
  129341. constructor(scene: Scene);
  129342. /**
  129343. * Registers the component in a given scene
  129344. */
  129345. register(): void;
  129346. /**
  129347. * Rebuilds the elements related to this component in case of
  129348. * context lost for instance.
  129349. */
  129350. rebuild(): void;
  129351. /**
  129352. * Disposes the component and the associated ressources
  129353. */
  129354. dispose(): void;
  129355. private _gatherRenderTargets;
  129356. }
  129357. }
  129358. declare module BABYLON {
  129359. /** @hidden */
  129360. export var motionBlurPixelShader: {
  129361. name: string;
  129362. shader: string;
  129363. };
  129364. }
  129365. declare module BABYLON {
  129366. /**
  129367. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  129368. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  129369. * As an example, all you have to do is to create the post-process:
  129370. * var mb = new BABYLON.MotionBlurPostProcess(
  129371. * 'mb', // The name of the effect.
  129372. * scene, // The scene containing the objects to blur according to their velocity.
  129373. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  129374. * camera // The camera to apply the render pass to.
  129375. * );
  129376. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  129377. */
  129378. export class MotionBlurPostProcess extends PostProcess {
  129379. /**
  129380. * Defines how much the image is blurred by the movement. Default value is equal to 1
  129381. */
  129382. motionStrength: number;
  129383. /**
  129384. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  129385. */
  129386. /**
  129387. * Sets the number of iterations to be used for motion blur quality
  129388. */
  129389. motionBlurSamples: number;
  129390. private _motionBlurSamples;
  129391. private _geometryBufferRenderer;
  129392. /**
  129393. * Creates a new instance MotionBlurPostProcess
  129394. * @param name The name of the effect.
  129395. * @param scene The scene containing the objects to blur according to their velocity.
  129396. * @param options The required width/height ratio to downsize to before computing the render pass.
  129397. * @param camera The camera to apply the render pass to.
  129398. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129399. * @param engine The engine which the post process will be applied. (default: current engine)
  129400. * @param reusable If the post process can be reused on the same frame. (default: false)
  129401. * @param textureType Type of textures used when performing the post process. (default: 0)
  129402. * @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)
  129403. */
  129404. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129405. /**
  129406. * Excludes the given skinned mesh from computing bones velocities.
  129407. * 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.
  129408. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  129409. */
  129410. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  129411. /**
  129412. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  129413. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  129414. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  129415. */
  129416. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  129417. /**
  129418. * Disposes the post process.
  129419. * @param camera The camera to dispose the post process on.
  129420. */
  129421. dispose(camera?: Camera): void;
  129422. }
  129423. }
  129424. declare module BABYLON {
  129425. /** @hidden */
  129426. export var refractionPixelShader: {
  129427. name: string;
  129428. shader: string;
  129429. };
  129430. }
  129431. declare module BABYLON {
  129432. /**
  129433. * Post process which applies a refractin texture
  129434. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  129435. */
  129436. export class RefractionPostProcess extends PostProcess {
  129437. /** the base color of the refraction (used to taint the rendering) */
  129438. color: Color3;
  129439. /** simulated refraction depth */
  129440. depth: number;
  129441. /** the coefficient of the base color (0 to remove base color tainting) */
  129442. colorLevel: number;
  129443. private _refTexture;
  129444. private _ownRefractionTexture;
  129445. /**
  129446. * Gets or sets the refraction texture
  129447. * Please note that you are responsible for disposing the texture if you set it manually
  129448. */
  129449. refractionTexture: Texture;
  129450. /**
  129451. * Initializes the RefractionPostProcess
  129452. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  129453. * @param name The name of the effect.
  129454. * @param refractionTextureUrl Url of the refraction texture to use
  129455. * @param color the base color of the refraction (used to taint the rendering)
  129456. * @param depth simulated refraction depth
  129457. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  129458. * @param camera The camera to apply the render pass to.
  129459. * @param options The required width/height ratio to downsize to before computing the render pass.
  129460. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129461. * @param engine The engine which the post process will be applied. (default: current engine)
  129462. * @param reusable If the post process can be reused on the same frame. (default: false)
  129463. */
  129464. constructor(name: string, refractionTextureUrl: string,
  129465. /** the base color of the refraction (used to taint the rendering) */
  129466. color: Color3,
  129467. /** simulated refraction depth */
  129468. depth: number,
  129469. /** the coefficient of the base color (0 to remove base color tainting) */
  129470. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129471. /**
  129472. * Disposes of the post process
  129473. * @param camera Camera to dispose post process on
  129474. */
  129475. dispose(camera: Camera): void;
  129476. }
  129477. }
  129478. declare module BABYLON {
  129479. /** @hidden */
  129480. export var sharpenPixelShader: {
  129481. name: string;
  129482. shader: string;
  129483. };
  129484. }
  129485. declare module BABYLON {
  129486. /**
  129487. * The SharpenPostProcess applies a sharpen kernel to every pixel
  129488. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  129489. */
  129490. export class SharpenPostProcess extends PostProcess {
  129491. /**
  129492. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  129493. */
  129494. colorAmount: number;
  129495. /**
  129496. * How much sharpness should be applied (default: 0.3)
  129497. */
  129498. edgeAmount: number;
  129499. /**
  129500. * Creates a new instance ConvolutionPostProcess
  129501. * @param name The name of the effect.
  129502. * @param options The required width/height ratio to downsize to before computing the render pass.
  129503. * @param camera The camera to apply the render pass to.
  129504. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129505. * @param engine The engine which the post process will be applied. (default: current engine)
  129506. * @param reusable If the post process can be reused on the same frame. (default: false)
  129507. * @param textureType Type of textures used when performing the post process. (default: 0)
  129508. * @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)
  129509. */
  129510. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129511. }
  129512. }
  129513. declare module BABYLON {
  129514. /**
  129515. * PostProcessRenderPipeline
  129516. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129517. */
  129518. export class PostProcessRenderPipeline {
  129519. private engine;
  129520. private _renderEffects;
  129521. private _renderEffectsForIsolatedPass;
  129522. /**
  129523. * List of inspectable custom properties (used by the Inspector)
  129524. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  129525. */
  129526. inspectableCustomProperties: IInspectable[];
  129527. /**
  129528. * @hidden
  129529. */
  129530. protected _cameras: Camera[];
  129531. /** @hidden */
  129532. _name: string;
  129533. /**
  129534. * Gets pipeline name
  129535. */
  129536. readonly name: string;
  129537. /** Gets the list of attached cameras */
  129538. readonly cameras: Camera[];
  129539. /**
  129540. * Initializes a PostProcessRenderPipeline
  129541. * @param engine engine to add the pipeline to
  129542. * @param name name of the pipeline
  129543. */
  129544. constructor(engine: Engine, name: string);
  129545. /**
  129546. * Gets the class name
  129547. * @returns "PostProcessRenderPipeline"
  129548. */
  129549. getClassName(): string;
  129550. /**
  129551. * If all the render effects in the pipeline are supported
  129552. */
  129553. readonly isSupported: boolean;
  129554. /**
  129555. * Adds an effect to the pipeline
  129556. * @param renderEffect the effect to add
  129557. */
  129558. addEffect(renderEffect: PostProcessRenderEffect): void;
  129559. /** @hidden */
  129560. _rebuild(): void;
  129561. /** @hidden */
  129562. _enableEffect(renderEffectName: string, cameras: Camera): void;
  129563. /** @hidden */
  129564. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  129565. /** @hidden */
  129566. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  129567. /** @hidden */
  129568. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  129569. /** @hidden */
  129570. _attachCameras(cameras: Camera, unique: boolean): void;
  129571. /** @hidden */
  129572. _attachCameras(cameras: Camera[], unique: boolean): void;
  129573. /** @hidden */
  129574. _detachCameras(cameras: Camera): void;
  129575. /** @hidden */
  129576. _detachCameras(cameras: Nullable<Camera[]>): void;
  129577. /** @hidden */
  129578. _update(): void;
  129579. /** @hidden */
  129580. _reset(): void;
  129581. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  129582. /**
  129583. * Disposes of the pipeline
  129584. */
  129585. dispose(): void;
  129586. }
  129587. }
  129588. declare module BABYLON {
  129589. /**
  129590. * PostProcessRenderPipelineManager class
  129591. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129592. */
  129593. export class PostProcessRenderPipelineManager {
  129594. private _renderPipelines;
  129595. /**
  129596. * Initializes a PostProcessRenderPipelineManager
  129597. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129598. */
  129599. constructor();
  129600. /**
  129601. * Gets the list of supported render pipelines
  129602. */
  129603. readonly supportedPipelines: PostProcessRenderPipeline[];
  129604. /**
  129605. * Adds a pipeline to the manager
  129606. * @param renderPipeline The pipeline to add
  129607. */
  129608. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  129609. /**
  129610. * Attaches a camera to the pipeline
  129611. * @param renderPipelineName The name of the pipeline to attach to
  129612. * @param cameras the camera to attach
  129613. * @param unique if the camera can be attached multiple times to the pipeline
  129614. */
  129615. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  129616. /**
  129617. * Detaches a camera from the pipeline
  129618. * @param renderPipelineName The name of the pipeline to detach from
  129619. * @param cameras the camera to detach
  129620. */
  129621. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  129622. /**
  129623. * Enables an effect by name on a pipeline
  129624. * @param renderPipelineName the name of the pipeline to enable the effect in
  129625. * @param renderEffectName the name of the effect to enable
  129626. * @param cameras the cameras that the effect should be enabled on
  129627. */
  129628. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  129629. /**
  129630. * Disables an effect by name on a pipeline
  129631. * @param renderPipelineName the name of the pipeline to disable the effect in
  129632. * @param renderEffectName the name of the effect to disable
  129633. * @param cameras the cameras that the effect should be disabled on
  129634. */
  129635. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  129636. /**
  129637. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  129638. */
  129639. update(): void;
  129640. /** @hidden */
  129641. _rebuild(): void;
  129642. /**
  129643. * Disposes of the manager and pipelines
  129644. */
  129645. dispose(): void;
  129646. }
  129647. }
  129648. declare module BABYLON {
  129649. interface Scene {
  129650. /** @hidden (Backing field) */
  129651. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  129652. /**
  129653. * Gets the postprocess render pipeline manager
  129654. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129655. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  129656. */
  129657. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  129658. }
  129659. /**
  129660. * Defines the Render Pipeline scene component responsible to rendering pipelines
  129661. */
  129662. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  129663. /**
  129664. * The component name helpfull to identify the component in the list of scene components.
  129665. */
  129666. readonly name: string;
  129667. /**
  129668. * The scene the component belongs to.
  129669. */
  129670. scene: Scene;
  129671. /**
  129672. * Creates a new instance of the component for the given scene
  129673. * @param scene Defines the scene to register the component in
  129674. */
  129675. constructor(scene: Scene);
  129676. /**
  129677. * Registers the component in a given scene
  129678. */
  129679. register(): void;
  129680. /**
  129681. * Rebuilds the elements related to this component in case of
  129682. * context lost for instance.
  129683. */
  129684. rebuild(): void;
  129685. /**
  129686. * Disposes the component and the associated ressources
  129687. */
  129688. dispose(): void;
  129689. private _gatherRenderTargets;
  129690. }
  129691. }
  129692. declare module BABYLON {
  129693. /**
  129694. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  129695. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  129696. */
  129697. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  129698. private _scene;
  129699. private _camerasToBeAttached;
  129700. /**
  129701. * ID of the sharpen post process,
  129702. */
  129703. private readonly SharpenPostProcessId;
  129704. /**
  129705. * @ignore
  129706. * ID of the image processing post process;
  129707. */
  129708. readonly ImageProcessingPostProcessId: string;
  129709. /**
  129710. * @ignore
  129711. * ID of the Fast Approximate Anti-Aliasing post process;
  129712. */
  129713. readonly FxaaPostProcessId: string;
  129714. /**
  129715. * ID of the chromatic aberration post process,
  129716. */
  129717. private readonly ChromaticAberrationPostProcessId;
  129718. /**
  129719. * ID of the grain post process
  129720. */
  129721. private readonly GrainPostProcessId;
  129722. /**
  129723. * Sharpen post process which will apply a sharpen convolution to enhance edges
  129724. */
  129725. sharpen: SharpenPostProcess;
  129726. private _sharpenEffect;
  129727. private bloom;
  129728. /**
  129729. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  129730. */
  129731. depthOfField: DepthOfFieldEffect;
  129732. /**
  129733. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  129734. */
  129735. fxaa: FxaaPostProcess;
  129736. /**
  129737. * Image post processing pass used to perform operations such as tone mapping or color grading.
  129738. */
  129739. imageProcessing: ImageProcessingPostProcess;
  129740. /**
  129741. * Chromatic aberration post process which will shift rgb colors in the image
  129742. */
  129743. chromaticAberration: ChromaticAberrationPostProcess;
  129744. private _chromaticAberrationEffect;
  129745. /**
  129746. * Grain post process which add noise to the image
  129747. */
  129748. grain: GrainPostProcess;
  129749. private _grainEffect;
  129750. /**
  129751. * Glow post process which adds a glow to emissive areas of the image
  129752. */
  129753. private _glowLayer;
  129754. /**
  129755. * Animations which can be used to tweak settings over a period of time
  129756. */
  129757. animations: Animation[];
  129758. private _imageProcessingConfigurationObserver;
  129759. private _sharpenEnabled;
  129760. private _bloomEnabled;
  129761. private _depthOfFieldEnabled;
  129762. private _depthOfFieldBlurLevel;
  129763. private _fxaaEnabled;
  129764. private _imageProcessingEnabled;
  129765. private _defaultPipelineTextureType;
  129766. private _bloomScale;
  129767. private _chromaticAberrationEnabled;
  129768. private _grainEnabled;
  129769. private _buildAllowed;
  129770. /**
  129771. * Gets active scene
  129772. */
  129773. readonly scene: Scene;
  129774. /**
  129775. * Enable or disable the sharpen process from the pipeline
  129776. */
  129777. sharpenEnabled: boolean;
  129778. private _resizeObserver;
  129779. private _hardwareScaleLevel;
  129780. private _bloomKernel;
  129781. /**
  129782. * Specifies the size of the bloom blur kernel, relative to the final output size
  129783. */
  129784. bloomKernel: number;
  129785. /**
  129786. * Specifies the weight of the bloom in the final rendering
  129787. */
  129788. private _bloomWeight;
  129789. /**
  129790. * Specifies the luma threshold for the area that will be blurred by the bloom
  129791. */
  129792. private _bloomThreshold;
  129793. private _hdr;
  129794. /**
  129795. * The strength of the bloom.
  129796. */
  129797. bloomWeight: number;
  129798. /**
  129799. * The strength of the bloom.
  129800. */
  129801. bloomThreshold: number;
  129802. /**
  129803. * The scale of the bloom, lower value will provide better performance.
  129804. */
  129805. bloomScale: number;
  129806. /**
  129807. * Enable or disable the bloom from the pipeline
  129808. */
  129809. bloomEnabled: boolean;
  129810. private _rebuildBloom;
  129811. /**
  129812. * If the depth of field is enabled.
  129813. */
  129814. depthOfFieldEnabled: boolean;
  129815. /**
  129816. * Blur level of the depth of field effect. (Higher blur will effect performance)
  129817. */
  129818. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  129819. /**
  129820. * If the anti aliasing is enabled.
  129821. */
  129822. fxaaEnabled: boolean;
  129823. private _samples;
  129824. /**
  129825. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  129826. */
  129827. samples: number;
  129828. /**
  129829. * If image processing is enabled.
  129830. */
  129831. imageProcessingEnabled: boolean;
  129832. /**
  129833. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  129834. */
  129835. glowLayerEnabled: boolean;
  129836. /**
  129837. * Gets the glow layer (or null if not defined)
  129838. */
  129839. readonly glowLayer: Nullable<GlowLayer>;
  129840. /**
  129841. * Enable or disable the chromaticAberration process from the pipeline
  129842. */
  129843. chromaticAberrationEnabled: boolean;
  129844. /**
  129845. * Enable or disable the grain process from the pipeline
  129846. */
  129847. grainEnabled: boolean;
  129848. /**
  129849. * @constructor
  129850. * @param name - The rendering pipeline name (default: "")
  129851. * @param hdr - If high dynamic range textures should be used (default: true)
  129852. * @param scene - The scene linked to this pipeline (default: the last created scene)
  129853. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  129854. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  129855. */
  129856. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  129857. /**
  129858. * Get the class name
  129859. * @returns "DefaultRenderingPipeline"
  129860. */
  129861. getClassName(): string;
  129862. /**
  129863. * Force the compilation of the entire pipeline.
  129864. */
  129865. prepare(): void;
  129866. private _hasCleared;
  129867. private _prevPostProcess;
  129868. private _prevPrevPostProcess;
  129869. private _setAutoClearAndTextureSharing;
  129870. private _depthOfFieldSceneObserver;
  129871. private _buildPipeline;
  129872. private _disposePostProcesses;
  129873. /**
  129874. * Adds a camera to the pipeline
  129875. * @param camera the camera to be added
  129876. */
  129877. addCamera(camera: Camera): void;
  129878. /**
  129879. * Removes a camera from the pipeline
  129880. * @param camera the camera to remove
  129881. */
  129882. removeCamera(camera: Camera): void;
  129883. /**
  129884. * Dispose of the pipeline and stop all post processes
  129885. */
  129886. dispose(): void;
  129887. /**
  129888. * Serialize the rendering pipeline (Used when exporting)
  129889. * @returns the serialized object
  129890. */
  129891. serialize(): any;
  129892. /**
  129893. * Parse the serialized pipeline
  129894. * @param source Source pipeline.
  129895. * @param scene The scene to load the pipeline to.
  129896. * @param rootUrl The URL of the serialized pipeline.
  129897. * @returns An instantiated pipeline from the serialized object.
  129898. */
  129899. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  129900. }
  129901. }
  129902. declare module BABYLON {
  129903. /** @hidden */
  129904. export var lensHighlightsPixelShader: {
  129905. name: string;
  129906. shader: string;
  129907. };
  129908. }
  129909. declare module BABYLON {
  129910. /** @hidden */
  129911. export var depthOfFieldPixelShader: {
  129912. name: string;
  129913. shader: string;
  129914. };
  129915. }
  129916. declare module BABYLON {
  129917. /**
  129918. * BABYLON.JS Chromatic Aberration GLSL Shader
  129919. * Author: Olivier Guyot
  129920. * Separates very slightly R, G and B colors on the edges of the screen
  129921. * Inspired by Francois Tarlier & Martins Upitis
  129922. */
  129923. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  129924. /**
  129925. * @ignore
  129926. * The chromatic aberration PostProcess id in the pipeline
  129927. */
  129928. LensChromaticAberrationEffect: string;
  129929. /**
  129930. * @ignore
  129931. * The highlights enhancing PostProcess id in the pipeline
  129932. */
  129933. HighlightsEnhancingEffect: string;
  129934. /**
  129935. * @ignore
  129936. * The depth-of-field PostProcess id in the pipeline
  129937. */
  129938. LensDepthOfFieldEffect: string;
  129939. private _scene;
  129940. private _depthTexture;
  129941. private _grainTexture;
  129942. private _chromaticAberrationPostProcess;
  129943. private _highlightsPostProcess;
  129944. private _depthOfFieldPostProcess;
  129945. private _edgeBlur;
  129946. private _grainAmount;
  129947. private _chromaticAberration;
  129948. private _distortion;
  129949. private _highlightsGain;
  129950. private _highlightsThreshold;
  129951. private _dofDistance;
  129952. private _dofAperture;
  129953. private _dofDarken;
  129954. private _dofPentagon;
  129955. private _blurNoise;
  129956. /**
  129957. * @constructor
  129958. *
  129959. * Effect parameters are as follow:
  129960. * {
  129961. * chromatic_aberration: number; // from 0 to x (1 for realism)
  129962. * edge_blur: number; // from 0 to x (1 for realism)
  129963. * distortion: number; // from 0 to x (1 for realism)
  129964. * grain_amount: number; // from 0 to 1
  129965. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  129966. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  129967. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  129968. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  129969. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  129970. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  129971. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  129972. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  129973. * }
  129974. * Note: if an effect parameter is unset, effect is disabled
  129975. *
  129976. * @param name The rendering pipeline name
  129977. * @param parameters - An object containing all parameters (see above)
  129978. * @param scene The scene linked to this pipeline
  129979. * @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)
  129980. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129981. */
  129982. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  129983. /**
  129984. * Get the class name
  129985. * @returns "LensRenderingPipeline"
  129986. */
  129987. getClassName(): string;
  129988. /**
  129989. * Gets associated scene
  129990. */
  129991. readonly scene: Scene;
  129992. /**
  129993. * Gets or sets the edge blur
  129994. */
  129995. edgeBlur: number;
  129996. /**
  129997. * Gets or sets the grain amount
  129998. */
  129999. grainAmount: number;
  130000. /**
  130001. * Gets or sets the chromatic aberration amount
  130002. */
  130003. chromaticAberration: number;
  130004. /**
  130005. * Gets or sets the depth of field aperture
  130006. */
  130007. dofAperture: number;
  130008. /**
  130009. * Gets or sets the edge distortion
  130010. */
  130011. edgeDistortion: number;
  130012. /**
  130013. * Gets or sets the depth of field distortion
  130014. */
  130015. dofDistortion: number;
  130016. /**
  130017. * Gets or sets the darken out of focus amount
  130018. */
  130019. darkenOutOfFocus: number;
  130020. /**
  130021. * Gets or sets a boolean indicating if blur noise is enabled
  130022. */
  130023. blurNoise: boolean;
  130024. /**
  130025. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  130026. */
  130027. pentagonBokeh: boolean;
  130028. /**
  130029. * Gets or sets the highlight grain amount
  130030. */
  130031. highlightsGain: number;
  130032. /**
  130033. * Gets or sets the highlight threshold
  130034. */
  130035. highlightsThreshold: number;
  130036. /**
  130037. * Sets the amount of blur at the edges
  130038. * @param amount blur amount
  130039. */
  130040. setEdgeBlur(amount: number): void;
  130041. /**
  130042. * Sets edge blur to 0
  130043. */
  130044. disableEdgeBlur(): void;
  130045. /**
  130046. * Sets the amout of grain
  130047. * @param amount Amount of grain
  130048. */
  130049. setGrainAmount(amount: number): void;
  130050. /**
  130051. * Set grain amount to 0
  130052. */
  130053. disableGrain(): void;
  130054. /**
  130055. * Sets the chromatic aberration amount
  130056. * @param amount amount of chromatic aberration
  130057. */
  130058. setChromaticAberration(amount: number): void;
  130059. /**
  130060. * Sets chromatic aberration amount to 0
  130061. */
  130062. disableChromaticAberration(): void;
  130063. /**
  130064. * Sets the EdgeDistortion amount
  130065. * @param amount amount of EdgeDistortion
  130066. */
  130067. setEdgeDistortion(amount: number): void;
  130068. /**
  130069. * Sets edge distortion to 0
  130070. */
  130071. disableEdgeDistortion(): void;
  130072. /**
  130073. * Sets the FocusDistance amount
  130074. * @param amount amount of FocusDistance
  130075. */
  130076. setFocusDistance(amount: number): void;
  130077. /**
  130078. * Disables depth of field
  130079. */
  130080. disableDepthOfField(): void;
  130081. /**
  130082. * Sets the Aperture amount
  130083. * @param amount amount of Aperture
  130084. */
  130085. setAperture(amount: number): void;
  130086. /**
  130087. * Sets the DarkenOutOfFocus amount
  130088. * @param amount amount of DarkenOutOfFocus
  130089. */
  130090. setDarkenOutOfFocus(amount: number): void;
  130091. private _pentagonBokehIsEnabled;
  130092. /**
  130093. * Creates a pentagon bokeh effect
  130094. */
  130095. enablePentagonBokeh(): void;
  130096. /**
  130097. * Disables the pentagon bokeh effect
  130098. */
  130099. disablePentagonBokeh(): void;
  130100. /**
  130101. * Enables noise blur
  130102. */
  130103. enableNoiseBlur(): void;
  130104. /**
  130105. * Disables noise blur
  130106. */
  130107. disableNoiseBlur(): void;
  130108. /**
  130109. * Sets the HighlightsGain amount
  130110. * @param amount amount of HighlightsGain
  130111. */
  130112. setHighlightsGain(amount: number): void;
  130113. /**
  130114. * Sets the HighlightsThreshold amount
  130115. * @param amount amount of HighlightsThreshold
  130116. */
  130117. setHighlightsThreshold(amount: number): void;
  130118. /**
  130119. * Disables highlights
  130120. */
  130121. disableHighlights(): void;
  130122. /**
  130123. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  130124. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  130125. */
  130126. dispose(disableDepthRender?: boolean): void;
  130127. private _createChromaticAberrationPostProcess;
  130128. private _createHighlightsPostProcess;
  130129. private _createDepthOfFieldPostProcess;
  130130. private _createGrainTexture;
  130131. }
  130132. }
  130133. declare module BABYLON {
  130134. /** @hidden */
  130135. export var ssao2PixelShader: {
  130136. name: string;
  130137. shader: string;
  130138. };
  130139. }
  130140. declare module BABYLON {
  130141. /** @hidden */
  130142. export var ssaoCombinePixelShader: {
  130143. name: string;
  130144. shader: string;
  130145. };
  130146. }
  130147. declare module BABYLON {
  130148. /**
  130149. * Render pipeline to produce ssao effect
  130150. */
  130151. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  130152. /**
  130153. * @ignore
  130154. * The PassPostProcess id in the pipeline that contains the original scene color
  130155. */
  130156. SSAOOriginalSceneColorEffect: string;
  130157. /**
  130158. * @ignore
  130159. * The SSAO PostProcess id in the pipeline
  130160. */
  130161. SSAORenderEffect: string;
  130162. /**
  130163. * @ignore
  130164. * The horizontal blur PostProcess id in the pipeline
  130165. */
  130166. SSAOBlurHRenderEffect: string;
  130167. /**
  130168. * @ignore
  130169. * The vertical blur PostProcess id in the pipeline
  130170. */
  130171. SSAOBlurVRenderEffect: string;
  130172. /**
  130173. * @ignore
  130174. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  130175. */
  130176. SSAOCombineRenderEffect: string;
  130177. /**
  130178. * The output strength of the SSAO post-process. Default value is 1.0.
  130179. */
  130180. totalStrength: number;
  130181. /**
  130182. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  130183. */
  130184. maxZ: number;
  130185. /**
  130186. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  130187. */
  130188. minZAspect: number;
  130189. private _samples;
  130190. /**
  130191. * Number of samples used for the SSAO calculations. Default value is 8
  130192. */
  130193. samples: number;
  130194. private _textureSamples;
  130195. /**
  130196. * Number of samples to use for antialiasing
  130197. */
  130198. textureSamples: number;
  130199. /**
  130200. * Ratio object used for SSAO ratio and blur ratio
  130201. */
  130202. private _ratio;
  130203. /**
  130204. * Dynamically generated sphere sampler.
  130205. */
  130206. private _sampleSphere;
  130207. /**
  130208. * Blur filter offsets
  130209. */
  130210. private _samplerOffsets;
  130211. private _expensiveBlur;
  130212. /**
  130213. * If bilateral blur should be used
  130214. */
  130215. expensiveBlur: boolean;
  130216. /**
  130217. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  130218. */
  130219. radius: number;
  130220. /**
  130221. * The base color of the SSAO post-process
  130222. * The final result is "base + ssao" between [0, 1]
  130223. */
  130224. base: number;
  130225. /**
  130226. * Support test.
  130227. */
  130228. static readonly IsSupported: boolean;
  130229. private _scene;
  130230. private _depthTexture;
  130231. private _normalTexture;
  130232. private _randomTexture;
  130233. private _originalColorPostProcess;
  130234. private _ssaoPostProcess;
  130235. private _blurHPostProcess;
  130236. private _blurVPostProcess;
  130237. private _ssaoCombinePostProcess;
  130238. /**
  130239. * Gets active scene
  130240. */
  130241. readonly scene: Scene;
  130242. /**
  130243. * @constructor
  130244. * @param name The rendering pipeline name
  130245. * @param scene The scene linked to this pipeline
  130246. * @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 }
  130247. * @param cameras The array of cameras that the rendering pipeline will be attached to
  130248. */
  130249. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  130250. /**
  130251. * Get the class name
  130252. * @returns "SSAO2RenderingPipeline"
  130253. */
  130254. getClassName(): string;
  130255. /**
  130256. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  130257. */
  130258. dispose(disableGeometryBufferRenderer?: boolean): void;
  130259. private _createBlurPostProcess;
  130260. /** @hidden */
  130261. _rebuild(): void;
  130262. private _bits;
  130263. private _radicalInverse_VdC;
  130264. private _hammersley;
  130265. private _hemisphereSample_uniform;
  130266. private _generateHemisphere;
  130267. private _createSSAOPostProcess;
  130268. private _createSSAOCombinePostProcess;
  130269. private _createRandomTexture;
  130270. /**
  130271. * Serialize the rendering pipeline (Used when exporting)
  130272. * @returns the serialized object
  130273. */
  130274. serialize(): any;
  130275. /**
  130276. * Parse the serialized pipeline
  130277. * @param source Source pipeline.
  130278. * @param scene The scene to load the pipeline to.
  130279. * @param rootUrl The URL of the serialized pipeline.
  130280. * @returns An instantiated pipeline from the serialized object.
  130281. */
  130282. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  130283. }
  130284. }
  130285. declare module BABYLON {
  130286. /** @hidden */
  130287. export var ssaoPixelShader: {
  130288. name: string;
  130289. shader: string;
  130290. };
  130291. }
  130292. declare module BABYLON {
  130293. /**
  130294. * Render pipeline to produce ssao effect
  130295. */
  130296. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  130297. /**
  130298. * @ignore
  130299. * The PassPostProcess id in the pipeline that contains the original scene color
  130300. */
  130301. SSAOOriginalSceneColorEffect: string;
  130302. /**
  130303. * @ignore
  130304. * The SSAO PostProcess id in the pipeline
  130305. */
  130306. SSAORenderEffect: string;
  130307. /**
  130308. * @ignore
  130309. * The horizontal blur PostProcess id in the pipeline
  130310. */
  130311. SSAOBlurHRenderEffect: string;
  130312. /**
  130313. * @ignore
  130314. * The vertical blur PostProcess id in the pipeline
  130315. */
  130316. SSAOBlurVRenderEffect: string;
  130317. /**
  130318. * @ignore
  130319. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  130320. */
  130321. SSAOCombineRenderEffect: string;
  130322. /**
  130323. * The output strength of the SSAO post-process. Default value is 1.0.
  130324. */
  130325. totalStrength: number;
  130326. /**
  130327. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  130328. */
  130329. radius: number;
  130330. /**
  130331. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  130332. * Must not be equal to fallOff and superior to fallOff.
  130333. * Default value is 0.0075
  130334. */
  130335. area: number;
  130336. /**
  130337. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  130338. * Must not be equal to area and inferior to area.
  130339. * Default value is 0.000001
  130340. */
  130341. fallOff: number;
  130342. /**
  130343. * The base color of the SSAO post-process
  130344. * The final result is "base + ssao" between [0, 1]
  130345. */
  130346. base: number;
  130347. private _scene;
  130348. private _depthTexture;
  130349. private _randomTexture;
  130350. private _originalColorPostProcess;
  130351. private _ssaoPostProcess;
  130352. private _blurHPostProcess;
  130353. private _blurVPostProcess;
  130354. private _ssaoCombinePostProcess;
  130355. private _firstUpdate;
  130356. /**
  130357. * Gets active scene
  130358. */
  130359. readonly scene: Scene;
  130360. /**
  130361. * @constructor
  130362. * @param name - The rendering pipeline name
  130363. * @param scene - The scene linked to this pipeline
  130364. * @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 }
  130365. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  130366. */
  130367. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  130368. /**
  130369. * Get the class name
  130370. * @returns "SSAORenderingPipeline"
  130371. */
  130372. getClassName(): string;
  130373. /**
  130374. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  130375. */
  130376. dispose(disableDepthRender?: boolean): void;
  130377. private _createBlurPostProcess;
  130378. /** @hidden */
  130379. _rebuild(): void;
  130380. private _createSSAOPostProcess;
  130381. private _createSSAOCombinePostProcess;
  130382. private _createRandomTexture;
  130383. }
  130384. }
  130385. declare module BABYLON {
  130386. /** @hidden */
  130387. export var standardPixelShader: {
  130388. name: string;
  130389. shader: string;
  130390. };
  130391. }
  130392. declare module BABYLON {
  130393. /**
  130394. * Standard rendering pipeline
  130395. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  130396. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  130397. */
  130398. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  130399. /**
  130400. * Public members
  130401. */
  130402. /**
  130403. * Post-process which contains the original scene color before the pipeline applies all the effects
  130404. */
  130405. originalPostProcess: Nullable<PostProcess>;
  130406. /**
  130407. * Post-process used to down scale an image x4
  130408. */
  130409. downSampleX4PostProcess: Nullable<PostProcess>;
  130410. /**
  130411. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  130412. */
  130413. brightPassPostProcess: Nullable<PostProcess>;
  130414. /**
  130415. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  130416. */
  130417. blurHPostProcesses: PostProcess[];
  130418. /**
  130419. * Post-process array storing all the vertical blur post-processes used by the pipeline
  130420. */
  130421. blurVPostProcesses: PostProcess[];
  130422. /**
  130423. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  130424. */
  130425. textureAdderPostProcess: Nullable<PostProcess>;
  130426. /**
  130427. * Post-process used to create volumetric lighting effect
  130428. */
  130429. volumetricLightPostProcess: Nullable<PostProcess>;
  130430. /**
  130431. * Post-process used to smooth the previous volumetric light post-process on the X axis
  130432. */
  130433. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  130434. /**
  130435. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  130436. */
  130437. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  130438. /**
  130439. * Post-process used to merge the volumetric light effect and the real scene color
  130440. */
  130441. volumetricLightMergePostProces: Nullable<PostProcess>;
  130442. /**
  130443. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  130444. */
  130445. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  130446. /**
  130447. * Base post-process used to calculate the average luminance of the final image for HDR
  130448. */
  130449. luminancePostProcess: Nullable<PostProcess>;
  130450. /**
  130451. * Post-processes used to create down sample post-processes in order to get
  130452. * the average luminance of the final image for HDR
  130453. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  130454. */
  130455. luminanceDownSamplePostProcesses: PostProcess[];
  130456. /**
  130457. * Post-process used to create a HDR effect (light adaptation)
  130458. */
  130459. hdrPostProcess: Nullable<PostProcess>;
  130460. /**
  130461. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  130462. */
  130463. textureAdderFinalPostProcess: Nullable<PostProcess>;
  130464. /**
  130465. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  130466. */
  130467. lensFlareFinalPostProcess: Nullable<PostProcess>;
  130468. /**
  130469. * Post-process used to merge the final HDR post-process and the real scene color
  130470. */
  130471. hdrFinalPostProcess: Nullable<PostProcess>;
  130472. /**
  130473. * Post-process used to create a lens flare effect
  130474. */
  130475. lensFlarePostProcess: Nullable<PostProcess>;
  130476. /**
  130477. * Post-process that merges the result of the lens flare post-process and the real scene color
  130478. */
  130479. lensFlareComposePostProcess: Nullable<PostProcess>;
  130480. /**
  130481. * Post-process used to create a motion blur effect
  130482. */
  130483. motionBlurPostProcess: Nullable<PostProcess>;
  130484. /**
  130485. * Post-process used to create a depth of field effect
  130486. */
  130487. depthOfFieldPostProcess: Nullable<PostProcess>;
  130488. /**
  130489. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  130490. */
  130491. fxaaPostProcess: Nullable<FxaaPostProcess>;
  130492. /**
  130493. * Represents the brightness threshold in order to configure the illuminated surfaces
  130494. */
  130495. brightThreshold: number;
  130496. /**
  130497. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  130498. */
  130499. blurWidth: number;
  130500. /**
  130501. * Sets if the blur for highlighted surfaces must be only horizontal
  130502. */
  130503. horizontalBlur: boolean;
  130504. /**
  130505. * Gets the overall exposure used by the pipeline
  130506. */
  130507. /**
  130508. * Sets the overall exposure used by the pipeline
  130509. */
  130510. exposure: number;
  130511. /**
  130512. * Texture used typically to simulate "dirty" on camera lens
  130513. */
  130514. lensTexture: Nullable<Texture>;
  130515. /**
  130516. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  130517. */
  130518. volumetricLightCoefficient: number;
  130519. /**
  130520. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  130521. */
  130522. volumetricLightPower: number;
  130523. /**
  130524. * Used the set the blur intensity to smooth the volumetric lights
  130525. */
  130526. volumetricLightBlurScale: number;
  130527. /**
  130528. * Light (spot or directional) used to generate the volumetric lights rays
  130529. * The source light must have a shadow generate so the pipeline can get its
  130530. * depth map
  130531. */
  130532. sourceLight: Nullable<SpotLight | DirectionalLight>;
  130533. /**
  130534. * For eye adaptation, represents the minimum luminance the eye can see
  130535. */
  130536. hdrMinimumLuminance: number;
  130537. /**
  130538. * For eye adaptation, represents the decrease luminance speed
  130539. */
  130540. hdrDecreaseRate: number;
  130541. /**
  130542. * For eye adaptation, represents the increase luminance speed
  130543. */
  130544. hdrIncreaseRate: number;
  130545. /**
  130546. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  130547. */
  130548. /**
  130549. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  130550. */
  130551. hdrAutoExposure: boolean;
  130552. /**
  130553. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  130554. */
  130555. lensColorTexture: Nullable<Texture>;
  130556. /**
  130557. * The overall strengh for the lens flare effect
  130558. */
  130559. lensFlareStrength: number;
  130560. /**
  130561. * Dispersion coefficient for lens flare ghosts
  130562. */
  130563. lensFlareGhostDispersal: number;
  130564. /**
  130565. * Main lens flare halo width
  130566. */
  130567. lensFlareHaloWidth: number;
  130568. /**
  130569. * Based on the lens distortion effect, defines how much the lens flare result
  130570. * is distorted
  130571. */
  130572. lensFlareDistortionStrength: number;
  130573. /**
  130574. * Configures the blur intensity used for for lens flare (halo)
  130575. */
  130576. lensFlareBlurWidth: number;
  130577. /**
  130578. * Lens star texture must be used to simulate rays on the flares and is available
  130579. * in the documentation
  130580. */
  130581. lensStarTexture: Nullable<Texture>;
  130582. /**
  130583. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  130584. * flare effect by taking account of the dirt texture
  130585. */
  130586. lensFlareDirtTexture: Nullable<Texture>;
  130587. /**
  130588. * Represents the focal length for the depth of field effect
  130589. */
  130590. depthOfFieldDistance: number;
  130591. /**
  130592. * Represents the blur intensity for the blurred part of the depth of field effect
  130593. */
  130594. depthOfFieldBlurWidth: number;
  130595. /**
  130596. * Gets how much the image is blurred by the movement while using the motion blur post-process
  130597. */
  130598. /**
  130599. * Sets how much the image is blurred by the movement while using the motion blur post-process
  130600. */
  130601. motionStrength: number;
  130602. /**
  130603. * Gets wether or not the motion blur post-process is object based or screen based.
  130604. */
  130605. /**
  130606. * Sets wether or not the motion blur post-process should be object based or screen based
  130607. */
  130608. objectBasedMotionBlur: boolean;
  130609. /**
  130610. * List of animations for the pipeline (IAnimatable implementation)
  130611. */
  130612. animations: Animation[];
  130613. /**
  130614. * Private members
  130615. */
  130616. private _scene;
  130617. private _currentDepthOfFieldSource;
  130618. private _basePostProcess;
  130619. private _fixedExposure;
  130620. private _currentExposure;
  130621. private _hdrAutoExposure;
  130622. private _hdrCurrentLuminance;
  130623. private _motionStrength;
  130624. private _isObjectBasedMotionBlur;
  130625. private _floatTextureType;
  130626. private _camerasToBeAttached;
  130627. private _ratio;
  130628. private _bloomEnabled;
  130629. private _depthOfFieldEnabled;
  130630. private _vlsEnabled;
  130631. private _lensFlareEnabled;
  130632. private _hdrEnabled;
  130633. private _motionBlurEnabled;
  130634. private _fxaaEnabled;
  130635. private _motionBlurSamples;
  130636. private _volumetricLightStepsCount;
  130637. private _samples;
  130638. /**
  130639. * @ignore
  130640. * Specifies if the bloom pipeline is enabled
  130641. */
  130642. BloomEnabled: boolean;
  130643. /**
  130644. * @ignore
  130645. * Specifies if the depth of field pipeline is enabed
  130646. */
  130647. DepthOfFieldEnabled: boolean;
  130648. /**
  130649. * @ignore
  130650. * Specifies if the lens flare pipeline is enabed
  130651. */
  130652. LensFlareEnabled: boolean;
  130653. /**
  130654. * @ignore
  130655. * Specifies if the HDR pipeline is enabled
  130656. */
  130657. HDREnabled: boolean;
  130658. /**
  130659. * @ignore
  130660. * Specifies if the volumetric lights scattering effect is enabled
  130661. */
  130662. VLSEnabled: boolean;
  130663. /**
  130664. * @ignore
  130665. * Specifies if the motion blur effect is enabled
  130666. */
  130667. MotionBlurEnabled: boolean;
  130668. /**
  130669. * Specifies if anti-aliasing is enabled
  130670. */
  130671. fxaaEnabled: boolean;
  130672. /**
  130673. * Specifies the number of steps used to calculate the volumetric lights
  130674. * Typically in interval [50, 200]
  130675. */
  130676. volumetricLightStepsCount: number;
  130677. /**
  130678. * Specifies the number of samples used for the motion blur effect
  130679. * Typically in interval [16, 64]
  130680. */
  130681. motionBlurSamples: number;
  130682. /**
  130683. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  130684. */
  130685. samples: number;
  130686. /**
  130687. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  130688. * @constructor
  130689. * @param name The rendering pipeline name
  130690. * @param scene The scene linked to this pipeline
  130691. * @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)
  130692. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  130693. * @param cameras The array of cameras that the rendering pipeline will be attached to
  130694. */
  130695. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  130696. private _buildPipeline;
  130697. private _createDownSampleX4PostProcess;
  130698. private _createBrightPassPostProcess;
  130699. private _createBlurPostProcesses;
  130700. private _createTextureAdderPostProcess;
  130701. private _createVolumetricLightPostProcess;
  130702. private _createLuminancePostProcesses;
  130703. private _createHdrPostProcess;
  130704. private _createLensFlarePostProcess;
  130705. private _createDepthOfFieldPostProcess;
  130706. private _createMotionBlurPostProcess;
  130707. private _getDepthTexture;
  130708. private _disposePostProcesses;
  130709. /**
  130710. * Dispose of the pipeline and stop all post processes
  130711. */
  130712. dispose(): void;
  130713. /**
  130714. * Serialize the rendering pipeline (Used when exporting)
  130715. * @returns the serialized object
  130716. */
  130717. serialize(): any;
  130718. /**
  130719. * Parse the serialized pipeline
  130720. * @param source Source pipeline.
  130721. * @param scene The scene to load the pipeline to.
  130722. * @param rootUrl The URL of the serialized pipeline.
  130723. * @returns An instantiated pipeline from the serialized object.
  130724. */
  130725. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  130726. /**
  130727. * Luminance steps
  130728. */
  130729. static LuminanceSteps: number;
  130730. }
  130731. }
  130732. declare module BABYLON {
  130733. /** @hidden */
  130734. export var tonemapPixelShader: {
  130735. name: string;
  130736. shader: string;
  130737. };
  130738. }
  130739. declare module BABYLON {
  130740. /** Defines operator used for tonemapping */
  130741. export enum TonemappingOperator {
  130742. /** Hable */
  130743. Hable = 0,
  130744. /** Reinhard */
  130745. Reinhard = 1,
  130746. /** HejiDawson */
  130747. HejiDawson = 2,
  130748. /** Photographic */
  130749. Photographic = 3
  130750. }
  130751. /**
  130752. * Defines a post process to apply tone mapping
  130753. */
  130754. export class TonemapPostProcess extends PostProcess {
  130755. private _operator;
  130756. /** Defines the required exposure adjustement */
  130757. exposureAdjustment: number;
  130758. /**
  130759. * Creates a new TonemapPostProcess
  130760. * @param name defines the name of the postprocess
  130761. * @param _operator defines the operator to use
  130762. * @param exposureAdjustment defines the required exposure adjustement
  130763. * @param camera defines the camera to use (can be null)
  130764. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  130765. * @param engine defines the hosting engine (can be ignore if camera is set)
  130766. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  130767. */
  130768. constructor(name: string, _operator: TonemappingOperator,
  130769. /** Defines the required exposure adjustement */
  130770. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  130771. }
  130772. }
  130773. declare module BABYLON {
  130774. /** @hidden */
  130775. export var depthVertexShader: {
  130776. name: string;
  130777. shader: string;
  130778. };
  130779. }
  130780. declare module BABYLON {
  130781. /** @hidden */
  130782. export var volumetricLightScatteringPixelShader: {
  130783. name: string;
  130784. shader: string;
  130785. };
  130786. }
  130787. declare module BABYLON {
  130788. /** @hidden */
  130789. export var volumetricLightScatteringPassVertexShader: {
  130790. name: string;
  130791. shader: string;
  130792. };
  130793. }
  130794. declare module BABYLON {
  130795. /** @hidden */
  130796. export var volumetricLightScatteringPassPixelShader: {
  130797. name: string;
  130798. shader: string;
  130799. };
  130800. }
  130801. declare module BABYLON {
  130802. /**
  130803. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  130804. */
  130805. export class VolumetricLightScatteringPostProcess extends PostProcess {
  130806. private _volumetricLightScatteringPass;
  130807. private _volumetricLightScatteringRTT;
  130808. private _viewPort;
  130809. private _screenCoordinates;
  130810. private _cachedDefines;
  130811. /**
  130812. * If not undefined, the mesh position is computed from the attached node position
  130813. */
  130814. attachedNode: {
  130815. position: Vector3;
  130816. };
  130817. /**
  130818. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  130819. */
  130820. customMeshPosition: Vector3;
  130821. /**
  130822. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  130823. */
  130824. useCustomMeshPosition: boolean;
  130825. /**
  130826. * If the post-process should inverse the light scattering direction
  130827. */
  130828. invert: boolean;
  130829. /**
  130830. * The internal mesh used by the post-process
  130831. */
  130832. mesh: Mesh;
  130833. /**
  130834. * @hidden
  130835. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  130836. */
  130837. useDiffuseColor: boolean;
  130838. /**
  130839. * Array containing the excluded meshes not rendered in the internal pass
  130840. */
  130841. excludedMeshes: AbstractMesh[];
  130842. /**
  130843. * Controls the overall intensity of the post-process
  130844. */
  130845. exposure: number;
  130846. /**
  130847. * Dissipates each sample's contribution in range [0, 1]
  130848. */
  130849. decay: number;
  130850. /**
  130851. * Controls the overall intensity of each sample
  130852. */
  130853. weight: number;
  130854. /**
  130855. * Controls the density of each sample
  130856. */
  130857. density: number;
  130858. /**
  130859. * @constructor
  130860. * @param name The post-process name
  130861. * @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)
  130862. * @param camera The camera that the post-process will be attached to
  130863. * @param mesh The mesh used to create the light scattering
  130864. * @param samples The post-process quality, default 100
  130865. * @param samplingModeThe post-process filtering mode
  130866. * @param engine The babylon engine
  130867. * @param reusable If the post-process is reusable
  130868. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  130869. */
  130870. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  130871. /**
  130872. * Returns the string "VolumetricLightScatteringPostProcess"
  130873. * @returns "VolumetricLightScatteringPostProcess"
  130874. */
  130875. getClassName(): string;
  130876. private _isReady;
  130877. /**
  130878. * Sets the new light position for light scattering effect
  130879. * @param position The new custom light position
  130880. */
  130881. setCustomMeshPosition(position: Vector3): void;
  130882. /**
  130883. * Returns the light position for light scattering effect
  130884. * @return Vector3 The custom light position
  130885. */
  130886. getCustomMeshPosition(): Vector3;
  130887. /**
  130888. * Disposes the internal assets and detaches the post-process from the camera
  130889. */
  130890. dispose(camera: Camera): void;
  130891. /**
  130892. * Returns the render target texture used by the post-process
  130893. * @return the render target texture used by the post-process
  130894. */
  130895. getPass(): RenderTargetTexture;
  130896. private _meshExcluded;
  130897. private _createPass;
  130898. private _updateMeshScreenCoordinates;
  130899. /**
  130900. * Creates a default mesh for the Volumeric Light Scattering post-process
  130901. * @param name The mesh name
  130902. * @param scene The scene where to create the mesh
  130903. * @return the default mesh
  130904. */
  130905. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  130906. }
  130907. }
  130908. declare module BABYLON {
  130909. interface Scene {
  130910. /** @hidden (Backing field) */
  130911. _boundingBoxRenderer: BoundingBoxRenderer;
  130912. /** @hidden (Backing field) */
  130913. _forceShowBoundingBoxes: boolean;
  130914. /**
  130915. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  130916. */
  130917. forceShowBoundingBoxes: boolean;
  130918. /**
  130919. * Gets the bounding box renderer associated with the scene
  130920. * @returns a BoundingBoxRenderer
  130921. */
  130922. getBoundingBoxRenderer(): BoundingBoxRenderer;
  130923. }
  130924. interface AbstractMesh {
  130925. /** @hidden (Backing field) */
  130926. _showBoundingBox: boolean;
  130927. /**
  130928. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  130929. */
  130930. showBoundingBox: boolean;
  130931. }
  130932. /**
  130933. * Component responsible of rendering the bounding box of the meshes in a scene.
  130934. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  130935. */
  130936. export class BoundingBoxRenderer implements ISceneComponent {
  130937. /**
  130938. * The component name helpfull to identify the component in the list of scene components.
  130939. */
  130940. readonly name: string;
  130941. /**
  130942. * The scene the component belongs to.
  130943. */
  130944. scene: Scene;
  130945. /**
  130946. * Color of the bounding box lines placed in front of an object
  130947. */
  130948. frontColor: Color3;
  130949. /**
  130950. * Color of the bounding box lines placed behind an object
  130951. */
  130952. backColor: Color3;
  130953. /**
  130954. * Defines if the renderer should show the back lines or not
  130955. */
  130956. showBackLines: boolean;
  130957. /**
  130958. * @hidden
  130959. */
  130960. renderList: SmartArray<BoundingBox>;
  130961. private _colorShader;
  130962. private _vertexBuffers;
  130963. private _indexBuffer;
  130964. private _fillIndexBuffer;
  130965. private _fillIndexData;
  130966. /**
  130967. * Instantiates a new bounding box renderer in a scene.
  130968. * @param scene the scene the renderer renders in
  130969. */
  130970. constructor(scene: Scene);
  130971. /**
  130972. * Registers the component in a given scene
  130973. */
  130974. register(): void;
  130975. private _evaluateSubMesh;
  130976. private _activeMesh;
  130977. private _prepareRessources;
  130978. private _createIndexBuffer;
  130979. /**
  130980. * Rebuilds the elements related to this component in case of
  130981. * context lost for instance.
  130982. */
  130983. rebuild(): void;
  130984. /**
  130985. * @hidden
  130986. */
  130987. reset(): void;
  130988. /**
  130989. * Render the bounding boxes of a specific rendering group
  130990. * @param renderingGroupId defines the rendering group to render
  130991. */
  130992. render(renderingGroupId: number): void;
  130993. /**
  130994. * In case of occlusion queries, we can render the occlusion bounding box through this method
  130995. * @param mesh Define the mesh to render the occlusion bounding box for
  130996. */
  130997. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  130998. /**
  130999. * Dispose and release the resources attached to this renderer.
  131000. */
  131001. dispose(): void;
  131002. }
  131003. }
  131004. declare module BABYLON {
  131005. /** @hidden */
  131006. export var depthPixelShader: {
  131007. name: string;
  131008. shader: string;
  131009. };
  131010. }
  131011. declare module BABYLON {
  131012. /**
  131013. * This represents a depth renderer in Babylon.
  131014. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  131015. */
  131016. export class DepthRenderer {
  131017. private _scene;
  131018. private _depthMap;
  131019. private _effect;
  131020. private readonly _storeNonLinearDepth;
  131021. private readonly _clearColor;
  131022. /** Get if the depth renderer is using packed depth or not */
  131023. readonly isPacked: boolean;
  131024. private _cachedDefines;
  131025. private _camera;
  131026. /**
  131027. * Specifiess that the depth renderer will only be used within
  131028. * the camera it is created for.
  131029. * This can help forcing its rendering during the camera processing.
  131030. */
  131031. useOnlyInActiveCamera: boolean;
  131032. /** @hidden */
  131033. static _SceneComponentInitialization: (scene: Scene) => void;
  131034. /**
  131035. * Instantiates a depth renderer
  131036. * @param scene The scene the renderer belongs to
  131037. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  131038. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  131039. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  131040. */
  131041. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  131042. /**
  131043. * Creates the depth rendering effect and checks if the effect is ready.
  131044. * @param subMesh The submesh to be used to render the depth map of
  131045. * @param useInstances If multiple world instances should be used
  131046. * @returns if the depth renderer is ready to render the depth map
  131047. */
  131048. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  131049. /**
  131050. * Gets the texture which the depth map will be written to.
  131051. * @returns The depth map texture
  131052. */
  131053. getDepthMap(): RenderTargetTexture;
  131054. /**
  131055. * Disposes of the depth renderer.
  131056. */
  131057. dispose(): void;
  131058. }
  131059. }
  131060. declare module BABYLON {
  131061. interface Scene {
  131062. /** @hidden (Backing field) */
  131063. _depthRenderer: {
  131064. [id: string]: DepthRenderer;
  131065. };
  131066. /**
  131067. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  131068. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  131069. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  131070. * @returns the created depth renderer
  131071. */
  131072. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  131073. /**
  131074. * Disables a depth renderer for a given camera
  131075. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  131076. */
  131077. disableDepthRenderer(camera?: Nullable<Camera>): void;
  131078. }
  131079. /**
  131080. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  131081. * in several rendering techniques.
  131082. */
  131083. export class DepthRendererSceneComponent implements ISceneComponent {
  131084. /**
  131085. * The component name helpfull to identify the component in the list of scene components.
  131086. */
  131087. readonly name: string;
  131088. /**
  131089. * The scene the component belongs to.
  131090. */
  131091. scene: Scene;
  131092. /**
  131093. * Creates a new instance of the component for the given scene
  131094. * @param scene Defines the scene to register the component in
  131095. */
  131096. constructor(scene: Scene);
  131097. /**
  131098. * Registers the component in a given scene
  131099. */
  131100. register(): void;
  131101. /**
  131102. * Rebuilds the elements related to this component in case of
  131103. * context lost for instance.
  131104. */
  131105. rebuild(): void;
  131106. /**
  131107. * Disposes the component and the associated ressources
  131108. */
  131109. dispose(): void;
  131110. private _gatherRenderTargets;
  131111. private _gatherActiveCameraRenderTargets;
  131112. }
  131113. }
  131114. declare module BABYLON {
  131115. /** @hidden */
  131116. export var outlinePixelShader: {
  131117. name: string;
  131118. shader: string;
  131119. };
  131120. }
  131121. declare module BABYLON {
  131122. /** @hidden */
  131123. export var outlineVertexShader: {
  131124. name: string;
  131125. shader: string;
  131126. };
  131127. }
  131128. declare module BABYLON {
  131129. interface Scene {
  131130. /** @hidden */
  131131. _outlineRenderer: OutlineRenderer;
  131132. /**
  131133. * Gets the outline renderer associated with the scene
  131134. * @returns a OutlineRenderer
  131135. */
  131136. getOutlineRenderer(): OutlineRenderer;
  131137. }
  131138. interface AbstractMesh {
  131139. /** @hidden (Backing field) */
  131140. _renderOutline: boolean;
  131141. /**
  131142. * Gets or sets a boolean indicating if the outline must be rendered as well
  131143. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  131144. */
  131145. renderOutline: boolean;
  131146. /** @hidden (Backing field) */
  131147. _renderOverlay: boolean;
  131148. /**
  131149. * Gets or sets a boolean indicating if the overlay must be rendered as well
  131150. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  131151. */
  131152. renderOverlay: boolean;
  131153. }
  131154. /**
  131155. * This class is responsible to draw bothe outline/overlay of meshes.
  131156. * It should not be used directly but through the available method on mesh.
  131157. */
  131158. export class OutlineRenderer implements ISceneComponent {
  131159. /**
  131160. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  131161. */
  131162. private static _StencilReference;
  131163. /**
  131164. * The name of the component. Each component must have a unique name.
  131165. */
  131166. name: string;
  131167. /**
  131168. * The scene the component belongs to.
  131169. */
  131170. scene: Scene;
  131171. /**
  131172. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  131173. */
  131174. zOffset: number;
  131175. private _engine;
  131176. private _effect;
  131177. private _cachedDefines;
  131178. private _savedDepthWrite;
  131179. /**
  131180. * Instantiates a new outline renderer. (There could be only one per scene).
  131181. * @param scene Defines the scene it belongs to
  131182. */
  131183. constructor(scene: Scene);
  131184. /**
  131185. * Register the component to one instance of a scene.
  131186. */
  131187. register(): void;
  131188. /**
  131189. * Rebuilds the elements related to this component in case of
  131190. * context lost for instance.
  131191. */
  131192. rebuild(): void;
  131193. /**
  131194. * Disposes the component and the associated ressources.
  131195. */
  131196. dispose(): void;
  131197. /**
  131198. * Renders the outline in the canvas.
  131199. * @param subMesh Defines the sumesh to render
  131200. * @param batch Defines the batch of meshes in case of instances
  131201. * @param useOverlay Defines if the rendering is for the overlay or the outline
  131202. */
  131203. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  131204. /**
  131205. * Returns whether or not the outline renderer is ready for a given submesh.
  131206. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  131207. * @param subMesh Defines the submesh to check readyness for
  131208. * @param useInstances Defines wheter wee are trying to render instances or not
  131209. * @returns true if ready otherwise false
  131210. */
  131211. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  131212. private _beforeRenderingMesh;
  131213. private _afterRenderingMesh;
  131214. }
  131215. }
  131216. declare module BABYLON {
  131217. /**
  131218. * Class used to manage multiple sprites of different sizes on the same spritesheet
  131219. * @see http://doc.babylonjs.com/babylon101/sprites
  131220. */
  131221. export class SpritePackedManager extends SpriteManager {
  131222. /** defines the packed manager's name */
  131223. name: string;
  131224. /**
  131225. * Creates a new sprite manager from a packed sprite sheet
  131226. * @param name defines the manager's name
  131227. * @param imgUrl defines the sprite sheet url
  131228. * @param capacity defines the maximum allowed number of sprites
  131229. * @param scene defines the hosting scene
  131230. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  131231. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  131232. * @param samplingMode defines the smapling mode to use with spritesheet
  131233. * @param fromPacked set to true; do not alter
  131234. */
  131235. constructor(
  131236. /** defines the packed manager's name */
  131237. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  131238. }
  131239. }
  131240. declare module BABYLON {
  131241. /**
  131242. * Defines the list of states available for a task inside a AssetsManager
  131243. */
  131244. export enum AssetTaskState {
  131245. /**
  131246. * Initialization
  131247. */
  131248. INIT = 0,
  131249. /**
  131250. * Running
  131251. */
  131252. RUNNING = 1,
  131253. /**
  131254. * Done
  131255. */
  131256. DONE = 2,
  131257. /**
  131258. * Error
  131259. */
  131260. ERROR = 3
  131261. }
  131262. /**
  131263. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  131264. */
  131265. export abstract class AbstractAssetTask {
  131266. /**
  131267. * Task name
  131268. */ name: string;
  131269. /**
  131270. * Callback called when the task is successful
  131271. */
  131272. onSuccess: (task: any) => void;
  131273. /**
  131274. * Callback called when the task is not successful
  131275. */
  131276. onError: (task: any, message?: string, exception?: any) => void;
  131277. /**
  131278. * Creates a new AssetsManager
  131279. * @param name defines the name of the task
  131280. */
  131281. constructor(
  131282. /**
  131283. * Task name
  131284. */ name: string);
  131285. private _isCompleted;
  131286. private _taskState;
  131287. private _errorObject;
  131288. /**
  131289. * Get if the task is completed
  131290. */
  131291. readonly isCompleted: boolean;
  131292. /**
  131293. * Gets the current state of the task
  131294. */
  131295. readonly taskState: AssetTaskState;
  131296. /**
  131297. * Gets the current error object (if task is in error)
  131298. */
  131299. readonly errorObject: {
  131300. message?: string;
  131301. exception?: any;
  131302. };
  131303. /**
  131304. * Internal only
  131305. * @hidden
  131306. */
  131307. _setErrorObject(message?: string, exception?: any): void;
  131308. /**
  131309. * Execute the current task
  131310. * @param scene defines the scene where you want your assets to be loaded
  131311. * @param onSuccess is a callback called when the task is successfully executed
  131312. * @param onError is a callback called if an error occurs
  131313. */
  131314. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131315. /**
  131316. * Execute the current task
  131317. * @param scene defines the scene where you want your assets to be loaded
  131318. * @param onSuccess is a callback called when the task is successfully executed
  131319. * @param onError is a callback called if an error occurs
  131320. */
  131321. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131322. /**
  131323. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  131324. * This can be used with failed tasks that have the reason for failure fixed.
  131325. */
  131326. reset(): void;
  131327. private onErrorCallback;
  131328. private onDoneCallback;
  131329. }
  131330. /**
  131331. * Define the interface used by progress events raised during assets loading
  131332. */
  131333. export interface IAssetsProgressEvent {
  131334. /**
  131335. * Defines the number of remaining tasks to process
  131336. */
  131337. remainingCount: number;
  131338. /**
  131339. * Defines the total number of tasks
  131340. */
  131341. totalCount: number;
  131342. /**
  131343. * Defines the task that was just processed
  131344. */
  131345. task: AbstractAssetTask;
  131346. }
  131347. /**
  131348. * Class used to share progress information about assets loading
  131349. */
  131350. export class AssetsProgressEvent implements IAssetsProgressEvent {
  131351. /**
  131352. * Defines the number of remaining tasks to process
  131353. */
  131354. remainingCount: number;
  131355. /**
  131356. * Defines the total number of tasks
  131357. */
  131358. totalCount: number;
  131359. /**
  131360. * Defines the task that was just processed
  131361. */
  131362. task: AbstractAssetTask;
  131363. /**
  131364. * Creates a AssetsProgressEvent
  131365. * @param remainingCount defines the number of remaining tasks to process
  131366. * @param totalCount defines the total number of tasks
  131367. * @param task defines the task that was just processed
  131368. */
  131369. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  131370. }
  131371. /**
  131372. * Define a task used by AssetsManager to load meshes
  131373. */
  131374. export class MeshAssetTask extends AbstractAssetTask {
  131375. /**
  131376. * Defines the name of the task
  131377. */
  131378. name: string;
  131379. /**
  131380. * Defines the list of mesh's names you want to load
  131381. */
  131382. meshesNames: any;
  131383. /**
  131384. * Defines the root url to use as a base to load your meshes and associated resources
  131385. */
  131386. rootUrl: string;
  131387. /**
  131388. * Defines the filename of the scene to load from
  131389. */
  131390. sceneFilename: string;
  131391. /**
  131392. * Gets the list of loaded meshes
  131393. */
  131394. loadedMeshes: Array<AbstractMesh>;
  131395. /**
  131396. * Gets the list of loaded particle systems
  131397. */
  131398. loadedParticleSystems: Array<IParticleSystem>;
  131399. /**
  131400. * Gets the list of loaded skeletons
  131401. */
  131402. loadedSkeletons: Array<Skeleton>;
  131403. /**
  131404. * Gets the list of loaded animation groups
  131405. */
  131406. loadedAnimationGroups: Array<AnimationGroup>;
  131407. /**
  131408. * Callback called when the task is successful
  131409. */
  131410. onSuccess: (task: MeshAssetTask) => void;
  131411. /**
  131412. * Callback called when the task is successful
  131413. */
  131414. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  131415. /**
  131416. * Creates a new MeshAssetTask
  131417. * @param name defines the name of the task
  131418. * @param meshesNames defines the list of mesh's names you want to load
  131419. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  131420. * @param sceneFilename defines the filename of the scene to load from
  131421. */
  131422. constructor(
  131423. /**
  131424. * Defines the name of the task
  131425. */
  131426. name: string,
  131427. /**
  131428. * Defines the list of mesh's names you want to load
  131429. */
  131430. meshesNames: any,
  131431. /**
  131432. * Defines the root url to use as a base to load your meshes and associated resources
  131433. */
  131434. rootUrl: string,
  131435. /**
  131436. * Defines the filename of the scene to load from
  131437. */
  131438. sceneFilename: string);
  131439. /**
  131440. * Execute the current task
  131441. * @param scene defines the scene where you want your assets to be loaded
  131442. * @param onSuccess is a callback called when the task is successfully executed
  131443. * @param onError is a callback called if an error occurs
  131444. */
  131445. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131446. }
  131447. /**
  131448. * Define a task used by AssetsManager to load text content
  131449. */
  131450. export class TextFileAssetTask extends AbstractAssetTask {
  131451. /**
  131452. * Defines the name of the task
  131453. */
  131454. name: string;
  131455. /**
  131456. * Defines the location of the file to load
  131457. */
  131458. url: string;
  131459. /**
  131460. * Gets the loaded text string
  131461. */
  131462. text: string;
  131463. /**
  131464. * Callback called when the task is successful
  131465. */
  131466. onSuccess: (task: TextFileAssetTask) => void;
  131467. /**
  131468. * Callback called when the task is successful
  131469. */
  131470. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  131471. /**
  131472. * Creates a new TextFileAssetTask object
  131473. * @param name defines the name of the task
  131474. * @param url defines the location of the file to load
  131475. */
  131476. constructor(
  131477. /**
  131478. * Defines the name of the task
  131479. */
  131480. name: string,
  131481. /**
  131482. * Defines the location of the file to load
  131483. */
  131484. url: string);
  131485. /**
  131486. * Execute the current task
  131487. * @param scene defines the scene where you want your assets to be loaded
  131488. * @param onSuccess is a callback called when the task is successfully executed
  131489. * @param onError is a callback called if an error occurs
  131490. */
  131491. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131492. }
  131493. /**
  131494. * Define a task used by AssetsManager to load binary data
  131495. */
  131496. export class BinaryFileAssetTask extends AbstractAssetTask {
  131497. /**
  131498. * Defines the name of the task
  131499. */
  131500. name: string;
  131501. /**
  131502. * Defines the location of the file to load
  131503. */
  131504. url: string;
  131505. /**
  131506. * Gets the lodaded data (as an array buffer)
  131507. */
  131508. data: ArrayBuffer;
  131509. /**
  131510. * Callback called when the task is successful
  131511. */
  131512. onSuccess: (task: BinaryFileAssetTask) => void;
  131513. /**
  131514. * Callback called when the task is successful
  131515. */
  131516. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  131517. /**
  131518. * Creates a new BinaryFileAssetTask object
  131519. * @param name defines the name of the new task
  131520. * @param url defines the location of the file to load
  131521. */
  131522. constructor(
  131523. /**
  131524. * Defines the name of the task
  131525. */
  131526. name: string,
  131527. /**
  131528. * Defines the location of the file to load
  131529. */
  131530. url: string);
  131531. /**
  131532. * Execute the current task
  131533. * @param scene defines the scene where you want your assets to be loaded
  131534. * @param onSuccess is a callback called when the task is successfully executed
  131535. * @param onError is a callback called if an error occurs
  131536. */
  131537. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131538. }
  131539. /**
  131540. * Define a task used by AssetsManager to load images
  131541. */
  131542. export class ImageAssetTask extends AbstractAssetTask {
  131543. /**
  131544. * Defines the name of the task
  131545. */
  131546. name: string;
  131547. /**
  131548. * Defines the location of the image to load
  131549. */
  131550. url: string;
  131551. /**
  131552. * Gets the loaded images
  131553. */
  131554. image: HTMLImageElement;
  131555. /**
  131556. * Callback called when the task is successful
  131557. */
  131558. onSuccess: (task: ImageAssetTask) => void;
  131559. /**
  131560. * Callback called when the task is successful
  131561. */
  131562. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  131563. /**
  131564. * Creates a new ImageAssetTask
  131565. * @param name defines the name of the task
  131566. * @param url defines the location of the image to load
  131567. */
  131568. constructor(
  131569. /**
  131570. * Defines the name of the task
  131571. */
  131572. name: string,
  131573. /**
  131574. * Defines the location of the image to load
  131575. */
  131576. url: string);
  131577. /**
  131578. * Execute the current task
  131579. * @param scene defines the scene where you want your assets to be loaded
  131580. * @param onSuccess is a callback called when the task is successfully executed
  131581. * @param onError is a callback called if an error occurs
  131582. */
  131583. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131584. }
  131585. /**
  131586. * Defines the interface used by texture loading tasks
  131587. */
  131588. export interface ITextureAssetTask<TEX extends BaseTexture> {
  131589. /**
  131590. * Gets the loaded texture
  131591. */
  131592. texture: TEX;
  131593. }
  131594. /**
  131595. * Define a task used by AssetsManager to load 2D textures
  131596. */
  131597. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  131598. /**
  131599. * Defines the name of the task
  131600. */
  131601. name: string;
  131602. /**
  131603. * Defines the location of the file to load
  131604. */
  131605. url: string;
  131606. /**
  131607. * Defines if mipmap should not be generated (default is false)
  131608. */
  131609. noMipmap?: boolean | undefined;
  131610. /**
  131611. * Defines if texture must be inverted on Y axis (default is false)
  131612. */
  131613. invertY?: boolean | undefined;
  131614. /**
  131615. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131616. */
  131617. samplingMode: number;
  131618. /**
  131619. * Gets the loaded texture
  131620. */
  131621. texture: Texture;
  131622. /**
  131623. * Callback called when the task is successful
  131624. */
  131625. onSuccess: (task: TextureAssetTask) => void;
  131626. /**
  131627. * Callback called when the task is successful
  131628. */
  131629. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  131630. /**
  131631. * Creates a new TextureAssetTask object
  131632. * @param name defines the name of the task
  131633. * @param url defines the location of the file to load
  131634. * @param noMipmap defines if mipmap should not be generated (default is false)
  131635. * @param invertY defines if texture must be inverted on Y axis (default is false)
  131636. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131637. */
  131638. constructor(
  131639. /**
  131640. * Defines the name of the task
  131641. */
  131642. name: string,
  131643. /**
  131644. * Defines the location of the file to load
  131645. */
  131646. url: string,
  131647. /**
  131648. * Defines if mipmap should not be generated (default is false)
  131649. */
  131650. noMipmap?: boolean | undefined,
  131651. /**
  131652. * Defines if texture must be inverted on Y axis (default is false)
  131653. */
  131654. invertY?: boolean | undefined,
  131655. /**
  131656. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131657. */
  131658. samplingMode?: number);
  131659. /**
  131660. * Execute the current task
  131661. * @param scene defines the scene where you want your assets to be loaded
  131662. * @param onSuccess is a callback called when the task is successfully executed
  131663. * @param onError is a callback called if an error occurs
  131664. */
  131665. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131666. }
  131667. /**
  131668. * Define a task used by AssetsManager to load cube textures
  131669. */
  131670. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  131671. /**
  131672. * Defines the name of the task
  131673. */
  131674. name: string;
  131675. /**
  131676. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131677. */
  131678. url: string;
  131679. /**
  131680. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131681. */
  131682. extensions?: string[] | undefined;
  131683. /**
  131684. * Defines if mipmaps should not be generated (default is false)
  131685. */
  131686. noMipmap?: boolean | undefined;
  131687. /**
  131688. * Defines the explicit list of files (undefined by default)
  131689. */
  131690. files?: string[] | undefined;
  131691. /**
  131692. * Gets the loaded texture
  131693. */
  131694. texture: CubeTexture;
  131695. /**
  131696. * Callback called when the task is successful
  131697. */
  131698. onSuccess: (task: CubeTextureAssetTask) => void;
  131699. /**
  131700. * Callback called when the task is successful
  131701. */
  131702. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  131703. /**
  131704. * Creates a new CubeTextureAssetTask
  131705. * @param name defines the name of the task
  131706. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131707. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131708. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131709. * @param files defines the explicit list of files (undefined by default)
  131710. */
  131711. constructor(
  131712. /**
  131713. * Defines the name of the task
  131714. */
  131715. name: string,
  131716. /**
  131717. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131718. */
  131719. url: string,
  131720. /**
  131721. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131722. */
  131723. extensions?: string[] | undefined,
  131724. /**
  131725. * Defines if mipmaps should not be generated (default is false)
  131726. */
  131727. noMipmap?: boolean | undefined,
  131728. /**
  131729. * Defines the explicit list of files (undefined by default)
  131730. */
  131731. files?: string[] | undefined);
  131732. /**
  131733. * Execute the current task
  131734. * @param scene defines the scene where you want your assets to be loaded
  131735. * @param onSuccess is a callback called when the task is successfully executed
  131736. * @param onError is a callback called if an error occurs
  131737. */
  131738. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131739. }
  131740. /**
  131741. * Define a task used by AssetsManager to load HDR cube textures
  131742. */
  131743. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  131744. /**
  131745. * Defines the name of the task
  131746. */
  131747. name: string;
  131748. /**
  131749. * Defines the location of the file to load
  131750. */
  131751. url: string;
  131752. /**
  131753. * Defines the desired size (the more it increases the longer the generation will be)
  131754. */
  131755. size: number;
  131756. /**
  131757. * Defines if mipmaps should not be generated (default is false)
  131758. */
  131759. noMipmap: boolean;
  131760. /**
  131761. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131762. */
  131763. generateHarmonics: boolean;
  131764. /**
  131765. * 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)
  131766. */
  131767. gammaSpace: boolean;
  131768. /**
  131769. * Internal Use Only
  131770. */
  131771. reserved: boolean;
  131772. /**
  131773. * Gets the loaded texture
  131774. */
  131775. texture: HDRCubeTexture;
  131776. /**
  131777. * Callback called when the task is successful
  131778. */
  131779. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  131780. /**
  131781. * Callback called when the task is successful
  131782. */
  131783. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  131784. /**
  131785. * Creates a new HDRCubeTextureAssetTask object
  131786. * @param name defines the name of the task
  131787. * @param url defines the location of the file to load
  131788. * @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.
  131789. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131790. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131791. * @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)
  131792. * @param reserved Internal use only
  131793. */
  131794. constructor(
  131795. /**
  131796. * Defines the name of the task
  131797. */
  131798. name: string,
  131799. /**
  131800. * Defines the location of the file to load
  131801. */
  131802. url: string,
  131803. /**
  131804. * Defines the desired size (the more it increases the longer the generation will be)
  131805. */
  131806. size: number,
  131807. /**
  131808. * Defines if mipmaps should not be generated (default is false)
  131809. */
  131810. noMipmap?: boolean,
  131811. /**
  131812. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131813. */
  131814. generateHarmonics?: boolean,
  131815. /**
  131816. * 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)
  131817. */
  131818. gammaSpace?: boolean,
  131819. /**
  131820. * Internal Use Only
  131821. */
  131822. reserved?: boolean);
  131823. /**
  131824. * Execute the current task
  131825. * @param scene defines the scene where you want your assets to be loaded
  131826. * @param onSuccess is a callback called when the task is successfully executed
  131827. * @param onError is a callback called if an error occurs
  131828. */
  131829. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131830. }
  131831. /**
  131832. * Define a task used by AssetsManager to load Equirectangular cube textures
  131833. */
  131834. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  131835. /**
  131836. * Defines the name of the task
  131837. */
  131838. name: string;
  131839. /**
  131840. * Defines the location of the file to load
  131841. */
  131842. url: string;
  131843. /**
  131844. * Defines the desired size (the more it increases the longer the generation will be)
  131845. */
  131846. size: number;
  131847. /**
  131848. * Defines if mipmaps should not be generated (default is false)
  131849. */
  131850. noMipmap: boolean;
  131851. /**
  131852. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  131853. * but the standard material would require them in Gamma space) (default is true)
  131854. */
  131855. gammaSpace: boolean;
  131856. /**
  131857. * Gets the loaded texture
  131858. */
  131859. texture: EquiRectangularCubeTexture;
  131860. /**
  131861. * Callback called when the task is successful
  131862. */
  131863. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  131864. /**
  131865. * Callback called when the task is successful
  131866. */
  131867. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  131868. /**
  131869. * Creates a new EquiRectangularCubeTextureAssetTask object
  131870. * @param name defines the name of the task
  131871. * @param url defines the location of the file to load
  131872. * @param size defines the desired size (the more it increases the longer the generation will be)
  131873. * If the size is omitted this implies you are using a preprocessed cubemap.
  131874. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131875. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  131876. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  131877. * (default is true)
  131878. */
  131879. constructor(
  131880. /**
  131881. * Defines the name of the task
  131882. */
  131883. name: string,
  131884. /**
  131885. * Defines the location of the file to load
  131886. */
  131887. url: string,
  131888. /**
  131889. * Defines the desired size (the more it increases the longer the generation will be)
  131890. */
  131891. size: number,
  131892. /**
  131893. * Defines if mipmaps should not be generated (default is false)
  131894. */
  131895. noMipmap?: boolean,
  131896. /**
  131897. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  131898. * but the standard material would require them in Gamma space) (default is true)
  131899. */
  131900. gammaSpace?: boolean);
  131901. /**
  131902. * Execute the current task
  131903. * @param scene defines the scene where you want your assets to be loaded
  131904. * @param onSuccess is a callback called when the task is successfully executed
  131905. * @param onError is a callback called if an error occurs
  131906. */
  131907. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131908. }
  131909. /**
  131910. * This class can be used to easily import assets into a scene
  131911. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  131912. */
  131913. export class AssetsManager {
  131914. private _scene;
  131915. private _isLoading;
  131916. protected _tasks: AbstractAssetTask[];
  131917. protected _waitingTasksCount: number;
  131918. protected _totalTasksCount: number;
  131919. /**
  131920. * Callback called when all tasks are processed
  131921. */
  131922. onFinish: (tasks: AbstractAssetTask[]) => void;
  131923. /**
  131924. * Callback called when a task is successful
  131925. */
  131926. onTaskSuccess: (task: AbstractAssetTask) => void;
  131927. /**
  131928. * Callback called when a task had an error
  131929. */
  131930. onTaskError: (task: AbstractAssetTask) => void;
  131931. /**
  131932. * Callback called when a task is done (whatever the result is)
  131933. */
  131934. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  131935. /**
  131936. * Observable called when all tasks are processed
  131937. */
  131938. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  131939. /**
  131940. * Observable called when a task had an error
  131941. */
  131942. onTaskErrorObservable: Observable<AbstractAssetTask>;
  131943. /**
  131944. * Observable called when all tasks were executed
  131945. */
  131946. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  131947. /**
  131948. * Observable called when a task is done (whatever the result is)
  131949. */
  131950. onProgressObservable: Observable<IAssetsProgressEvent>;
  131951. /**
  131952. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  131953. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  131954. */
  131955. useDefaultLoadingScreen: boolean;
  131956. /**
  131957. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  131958. * when all assets have been downloaded.
  131959. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  131960. */
  131961. autoHideLoadingUI: boolean;
  131962. /**
  131963. * Creates a new AssetsManager
  131964. * @param scene defines the scene to work on
  131965. */
  131966. constructor(scene: Scene);
  131967. /**
  131968. * Add a MeshAssetTask to the list of active tasks
  131969. * @param taskName defines the name of the new task
  131970. * @param meshesNames defines the name of meshes to load
  131971. * @param rootUrl defines the root url to use to locate files
  131972. * @param sceneFilename defines the filename of the scene file
  131973. * @returns a new MeshAssetTask object
  131974. */
  131975. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  131976. /**
  131977. * Add a TextFileAssetTask to the list of active tasks
  131978. * @param taskName defines the name of the new task
  131979. * @param url defines the url of the file to load
  131980. * @returns a new TextFileAssetTask object
  131981. */
  131982. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  131983. /**
  131984. * Add a BinaryFileAssetTask to the list of active tasks
  131985. * @param taskName defines the name of the new task
  131986. * @param url defines the url of the file to load
  131987. * @returns a new BinaryFileAssetTask object
  131988. */
  131989. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  131990. /**
  131991. * Add a ImageAssetTask to the list of active tasks
  131992. * @param taskName defines the name of the new task
  131993. * @param url defines the url of the file to load
  131994. * @returns a new ImageAssetTask object
  131995. */
  131996. addImageTask(taskName: string, url: string): ImageAssetTask;
  131997. /**
  131998. * Add a TextureAssetTask to the list of active tasks
  131999. * @param taskName defines the name of the new task
  132000. * @param url defines the url of the file to load
  132001. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  132002. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  132003. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  132004. * @returns a new TextureAssetTask object
  132005. */
  132006. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  132007. /**
  132008. * Add a CubeTextureAssetTask to the list of active tasks
  132009. * @param taskName defines the name of the new task
  132010. * @param url defines the url of the file to load
  132011. * @param extensions defines the extension to use to load the cube map (can be null)
  132012. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  132013. * @param files defines the list of files to load (can be null)
  132014. * @returns a new CubeTextureAssetTask object
  132015. */
  132016. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  132017. /**
  132018. *
  132019. * Add a HDRCubeTextureAssetTask to the list of active tasks
  132020. * @param taskName defines the name of the new task
  132021. * @param url defines the url of the file to load
  132022. * @param size defines the size you want for the cubemap (can be null)
  132023. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  132024. * @param generateHarmonics defines if you want to automatically generate (true by default)
  132025. * @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)
  132026. * @param reserved Internal use only
  132027. * @returns a new HDRCubeTextureAssetTask object
  132028. */
  132029. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  132030. /**
  132031. *
  132032. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  132033. * @param taskName defines the name of the new task
  132034. * @param url defines the url of the file to load
  132035. * @param size defines the size you want for the cubemap (can be null)
  132036. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  132037. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  132038. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  132039. * @returns a new EquiRectangularCubeTextureAssetTask object
  132040. */
  132041. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  132042. /**
  132043. * Remove a task from the assets manager.
  132044. * @param task the task to remove
  132045. */
  132046. removeTask(task: AbstractAssetTask): void;
  132047. private _decreaseWaitingTasksCount;
  132048. private _runTask;
  132049. /**
  132050. * Reset the AssetsManager and remove all tasks
  132051. * @return the current instance of the AssetsManager
  132052. */
  132053. reset(): AssetsManager;
  132054. /**
  132055. * Start the loading process
  132056. * @return the current instance of the AssetsManager
  132057. */
  132058. load(): AssetsManager;
  132059. /**
  132060. * Start the loading process as an async operation
  132061. * @return a promise returning the list of failed tasks
  132062. */
  132063. loadAsync(): Promise<void>;
  132064. }
  132065. }
  132066. declare module BABYLON {
  132067. /**
  132068. * Wrapper class for promise with external resolve and reject.
  132069. */
  132070. export class Deferred<T> {
  132071. /**
  132072. * The promise associated with this deferred object.
  132073. */
  132074. readonly promise: Promise<T>;
  132075. private _resolve;
  132076. private _reject;
  132077. /**
  132078. * The resolve method of the promise associated with this deferred object.
  132079. */
  132080. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  132081. /**
  132082. * The reject method of the promise associated with this deferred object.
  132083. */
  132084. readonly reject: (reason?: any) => void;
  132085. /**
  132086. * Constructor for this deferred object.
  132087. */
  132088. constructor();
  132089. }
  132090. }
  132091. declare module BABYLON {
  132092. /**
  132093. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  132094. */
  132095. export class MeshExploder {
  132096. private _centerMesh;
  132097. private _meshes;
  132098. private _meshesOrigins;
  132099. private _toCenterVectors;
  132100. private _scaledDirection;
  132101. private _newPosition;
  132102. private _centerPosition;
  132103. /**
  132104. * Explodes meshes from a center mesh.
  132105. * @param meshes The meshes to explode.
  132106. * @param centerMesh The mesh to be center of explosion.
  132107. */
  132108. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  132109. private _setCenterMesh;
  132110. /**
  132111. * Get class name
  132112. * @returns "MeshExploder"
  132113. */
  132114. getClassName(): string;
  132115. /**
  132116. * "Exploded meshes"
  132117. * @returns Array of meshes with the centerMesh at index 0.
  132118. */
  132119. getMeshes(): Array<Mesh>;
  132120. /**
  132121. * Explodes meshes giving a specific direction
  132122. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  132123. */
  132124. explode(direction?: number): void;
  132125. }
  132126. }
  132127. declare module BABYLON {
  132128. /**
  132129. * Class used to help managing file picking and drag'n'drop
  132130. */
  132131. export class FilesInput {
  132132. /**
  132133. * List of files ready to be loaded
  132134. */
  132135. static readonly FilesToLoad: {
  132136. [key: string]: File;
  132137. };
  132138. /**
  132139. * Callback called when a file is processed
  132140. */
  132141. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  132142. private _engine;
  132143. private _currentScene;
  132144. private _sceneLoadedCallback;
  132145. private _progressCallback;
  132146. private _additionalRenderLoopLogicCallback;
  132147. private _textureLoadingCallback;
  132148. private _startingProcessingFilesCallback;
  132149. private _onReloadCallback;
  132150. private _errorCallback;
  132151. private _elementToMonitor;
  132152. private _sceneFileToLoad;
  132153. private _filesToLoad;
  132154. /**
  132155. * Creates a new FilesInput
  132156. * @param engine defines the rendering engine
  132157. * @param scene defines the hosting scene
  132158. * @param sceneLoadedCallback callback called when scene is loaded
  132159. * @param progressCallback callback called to track progress
  132160. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  132161. * @param textureLoadingCallback callback called when a texture is loading
  132162. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  132163. * @param onReloadCallback callback called when a reload is requested
  132164. * @param errorCallback callback call if an error occurs
  132165. */
  132166. 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);
  132167. private _dragEnterHandler;
  132168. private _dragOverHandler;
  132169. private _dropHandler;
  132170. /**
  132171. * Calls this function to listen to drag'n'drop events on a specific DOM element
  132172. * @param elementToMonitor defines the DOM element to track
  132173. */
  132174. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  132175. /**
  132176. * Release all associated resources
  132177. */
  132178. dispose(): void;
  132179. private renderFunction;
  132180. private drag;
  132181. private drop;
  132182. private _traverseFolder;
  132183. private _processFiles;
  132184. /**
  132185. * Load files from a drop event
  132186. * @param event defines the drop event to use as source
  132187. */
  132188. loadFiles(event: any): void;
  132189. private _processReload;
  132190. /**
  132191. * Reload the current scene from the loaded files
  132192. */
  132193. reload(): void;
  132194. }
  132195. }
  132196. declare module BABYLON {
  132197. /**
  132198. * Defines the root class used to create scene optimization to use with SceneOptimizer
  132199. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132200. */
  132201. export class SceneOptimization {
  132202. /**
  132203. * Defines the priority of this optimization (0 by default which means first in the list)
  132204. */
  132205. priority: number;
  132206. /**
  132207. * Gets a string describing the action executed by the current optimization
  132208. * @returns description string
  132209. */
  132210. getDescription(): string;
  132211. /**
  132212. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132213. * @param scene defines the current scene where to apply this optimization
  132214. * @param optimizer defines the current optimizer
  132215. * @returns true if everything that can be done was applied
  132216. */
  132217. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132218. /**
  132219. * Creates the SceneOptimization object
  132220. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132221. * @param desc defines the description associated with the optimization
  132222. */
  132223. constructor(
  132224. /**
  132225. * Defines the priority of this optimization (0 by default which means first in the list)
  132226. */
  132227. priority?: number);
  132228. }
  132229. /**
  132230. * Defines an optimization used to reduce the size of render target textures
  132231. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132232. */
  132233. export class TextureOptimization extends SceneOptimization {
  132234. /**
  132235. * Defines the priority of this optimization (0 by default which means first in the list)
  132236. */
  132237. priority: number;
  132238. /**
  132239. * 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
  132240. */
  132241. maximumSize: number;
  132242. /**
  132243. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  132244. */
  132245. step: number;
  132246. /**
  132247. * Gets a string describing the action executed by the current optimization
  132248. * @returns description string
  132249. */
  132250. getDescription(): string;
  132251. /**
  132252. * Creates the TextureOptimization object
  132253. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132254. * @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
  132255. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  132256. */
  132257. constructor(
  132258. /**
  132259. * Defines the priority of this optimization (0 by default which means first in the list)
  132260. */
  132261. priority?: number,
  132262. /**
  132263. * 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
  132264. */
  132265. maximumSize?: number,
  132266. /**
  132267. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  132268. */
  132269. step?: number);
  132270. /**
  132271. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132272. * @param scene defines the current scene where to apply this optimization
  132273. * @param optimizer defines the current optimizer
  132274. * @returns true if everything that can be done was applied
  132275. */
  132276. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132277. }
  132278. /**
  132279. * Defines an optimization used to increase or decrease the rendering resolution
  132280. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132281. */
  132282. export class HardwareScalingOptimization extends SceneOptimization {
  132283. /**
  132284. * Defines the priority of this optimization (0 by default which means first in the list)
  132285. */
  132286. priority: number;
  132287. /**
  132288. * Defines the maximum scale to use (2 by default)
  132289. */
  132290. maximumScale: number;
  132291. /**
  132292. * Defines the step to use between two passes (0.5 by default)
  132293. */
  132294. step: number;
  132295. private _currentScale;
  132296. private _directionOffset;
  132297. /**
  132298. * Gets a string describing the action executed by the current optimization
  132299. * @return description string
  132300. */
  132301. getDescription(): string;
  132302. /**
  132303. * Creates the HardwareScalingOptimization object
  132304. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132305. * @param maximumScale defines the maximum scale to use (2 by default)
  132306. * @param step defines the step to use between two passes (0.5 by default)
  132307. */
  132308. constructor(
  132309. /**
  132310. * Defines the priority of this optimization (0 by default which means first in the list)
  132311. */
  132312. priority?: number,
  132313. /**
  132314. * Defines the maximum scale to use (2 by default)
  132315. */
  132316. maximumScale?: number,
  132317. /**
  132318. * Defines the step to use between two passes (0.5 by default)
  132319. */
  132320. step?: number);
  132321. /**
  132322. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132323. * @param scene defines the current scene where to apply this optimization
  132324. * @param optimizer defines the current optimizer
  132325. * @returns true if everything that can be done was applied
  132326. */
  132327. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132328. }
  132329. /**
  132330. * Defines an optimization used to remove shadows
  132331. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132332. */
  132333. export class ShadowsOptimization extends SceneOptimization {
  132334. /**
  132335. * Gets a string describing the action executed by the current optimization
  132336. * @return description string
  132337. */
  132338. getDescription(): string;
  132339. /**
  132340. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132341. * @param scene defines the current scene where to apply this optimization
  132342. * @param optimizer defines the current optimizer
  132343. * @returns true if everything that can be done was applied
  132344. */
  132345. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132346. }
  132347. /**
  132348. * Defines an optimization used to turn post-processes off
  132349. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132350. */
  132351. export class PostProcessesOptimization extends SceneOptimization {
  132352. /**
  132353. * Gets a string describing the action executed by the current optimization
  132354. * @return description string
  132355. */
  132356. getDescription(): string;
  132357. /**
  132358. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132359. * @param scene defines the current scene where to apply this optimization
  132360. * @param optimizer defines the current optimizer
  132361. * @returns true if everything that can be done was applied
  132362. */
  132363. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132364. }
  132365. /**
  132366. * Defines an optimization used to turn lens flares off
  132367. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132368. */
  132369. export class LensFlaresOptimization extends SceneOptimization {
  132370. /**
  132371. * Gets a string describing the action executed by the current optimization
  132372. * @return description string
  132373. */
  132374. getDescription(): string;
  132375. /**
  132376. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132377. * @param scene defines the current scene where to apply this optimization
  132378. * @param optimizer defines the current optimizer
  132379. * @returns true if everything that can be done was applied
  132380. */
  132381. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132382. }
  132383. /**
  132384. * Defines an optimization based on user defined callback.
  132385. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132386. */
  132387. export class CustomOptimization extends SceneOptimization {
  132388. /**
  132389. * Callback called to apply the custom optimization.
  132390. */
  132391. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  132392. /**
  132393. * Callback called to get custom description
  132394. */
  132395. onGetDescription: () => string;
  132396. /**
  132397. * Gets a string describing the action executed by the current optimization
  132398. * @returns description string
  132399. */
  132400. getDescription(): string;
  132401. /**
  132402. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132403. * @param scene defines the current scene where to apply this optimization
  132404. * @param optimizer defines the current optimizer
  132405. * @returns true if everything that can be done was applied
  132406. */
  132407. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132408. }
  132409. /**
  132410. * Defines an optimization used to turn particles off
  132411. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132412. */
  132413. export class ParticlesOptimization extends SceneOptimization {
  132414. /**
  132415. * Gets a string describing the action executed by the current optimization
  132416. * @return description string
  132417. */
  132418. getDescription(): string;
  132419. /**
  132420. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132421. * @param scene defines the current scene where to apply this optimization
  132422. * @param optimizer defines the current optimizer
  132423. * @returns true if everything that can be done was applied
  132424. */
  132425. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132426. }
  132427. /**
  132428. * Defines an optimization used to turn render targets off
  132429. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132430. */
  132431. export class RenderTargetsOptimization extends SceneOptimization {
  132432. /**
  132433. * Gets a string describing the action executed by the current optimization
  132434. * @return description string
  132435. */
  132436. getDescription(): string;
  132437. /**
  132438. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132439. * @param scene defines the current scene where to apply this optimization
  132440. * @param optimizer defines the current optimizer
  132441. * @returns true if everything that can be done was applied
  132442. */
  132443. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132444. }
  132445. /**
  132446. * Defines an optimization used to merge meshes with compatible materials
  132447. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132448. */
  132449. export class MergeMeshesOptimization extends SceneOptimization {
  132450. private static _UpdateSelectionTree;
  132451. /**
  132452. * Gets or sets a boolean which defines if optimization octree has to be updated
  132453. */
  132454. /**
  132455. * Gets or sets a boolean which defines if optimization octree has to be updated
  132456. */
  132457. static UpdateSelectionTree: boolean;
  132458. /**
  132459. * Gets a string describing the action executed by the current optimization
  132460. * @return description string
  132461. */
  132462. getDescription(): string;
  132463. private _canBeMerged;
  132464. /**
  132465. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132466. * @param scene defines the current scene where to apply this optimization
  132467. * @param optimizer defines the current optimizer
  132468. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  132469. * @returns true if everything that can be done was applied
  132470. */
  132471. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  132472. }
  132473. /**
  132474. * Defines a list of options used by SceneOptimizer
  132475. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132476. */
  132477. export class SceneOptimizerOptions {
  132478. /**
  132479. * Defines the target frame rate to reach (60 by default)
  132480. */
  132481. targetFrameRate: number;
  132482. /**
  132483. * Defines the interval between two checkes (2000ms by default)
  132484. */
  132485. trackerDuration: number;
  132486. /**
  132487. * Gets the list of optimizations to apply
  132488. */
  132489. optimizations: SceneOptimization[];
  132490. /**
  132491. * Creates a new list of options used by SceneOptimizer
  132492. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  132493. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  132494. */
  132495. constructor(
  132496. /**
  132497. * Defines the target frame rate to reach (60 by default)
  132498. */
  132499. targetFrameRate?: number,
  132500. /**
  132501. * Defines the interval between two checkes (2000ms by default)
  132502. */
  132503. trackerDuration?: number);
  132504. /**
  132505. * Add a new optimization
  132506. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  132507. * @returns the current SceneOptimizerOptions
  132508. */
  132509. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  132510. /**
  132511. * Add a new custom optimization
  132512. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  132513. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  132514. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132515. * @returns the current SceneOptimizerOptions
  132516. */
  132517. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  132518. /**
  132519. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  132520. * @param targetFrameRate defines the target frame rate (60 by default)
  132521. * @returns a SceneOptimizerOptions object
  132522. */
  132523. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132524. /**
  132525. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  132526. * @param targetFrameRate defines the target frame rate (60 by default)
  132527. * @returns a SceneOptimizerOptions object
  132528. */
  132529. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132530. /**
  132531. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  132532. * @param targetFrameRate defines the target frame rate (60 by default)
  132533. * @returns a SceneOptimizerOptions object
  132534. */
  132535. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132536. }
  132537. /**
  132538. * Class used to run optimizations in order to reach a target frame rate
  132539. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132540. */
  132541. export class SceneOptimizer implements IDisposable {
  132542. private _isRunning;
  132543. private _options;
  132544. private _scene;
  132545. private _currentPriorityLevel;
  132546. private _targetFrameRate;
  132547. private _trackerDuration;
  132548. private _currentFrameRate;
  132549. private _sceneDisposeObserver;
  132550. private _improvementMode;
  132551. /**
  132552. * Defines an observable called when the optimizer reaches the target frame rate
  132553. */
  132554. onSuccessObservable: Observable<SceneOptimizer>;
  132555. /**
  132556. * Defines an observable called when the optimizer enables an optimization
  132557. */
  132558. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  132559. /**
  132560. * Defines an observable called when the optimizer is not able to reach the target frame rate
  132561. */
  132562. onFailureObservable: Observable<SceneOptimizer>;
  132563. /**
  132564. * Gets a boolean indicating if the optimizer is in improvement mode
  132565. */
  132566. readonly isInImprovementMode: boolean;
  132567. /**
  132568. * Gets the current priority level (0 at start)
  132569. */
  132570. readonly currentPriorityLevel: number;
  132571. /**
  132572. * Gets the current frame rate checked by the SceneOptimizer
  132573. */
  132574. readonly currentFrameRate: number;
  132575. /**
  132576. * Gets or sets the current target frame rate (60 by default)
  132577. */
  132578. /**
  132579. * Gets or sets the current target frame rate (60 by default)
  132580. */
  132581. targetFrameRate: number;
  132582. /**
  132583. * Gets or sets the current interval between two checks (every 2000ms by default)
  132584. */
  132585. /**
  132586. * Gets or sets the current interval between two checks (every 2000ms by default)
  132587. */
  132588. trackerDuration: number;
  132589. /**
  132590. * Gets the list of active optimizations
  132591. */
  132592. readonly optimizations: SceneOptimization[];
  132593. /**
  132594. * Creates a new SceneOptimizer
  132595. * @param scene defines the scene to work on
  132596. * @param options defines the options to use with the SceneOptimizer
  132597. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  132598. * @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)
  132599. */
  132600. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  132601. /**
  132602. * Stops the current optimizer
  132603. */
  132604. stop(): void;
  132605. /**
  132606. * Reset the optimizer to initial step (current priority level = 0)
  132607. */
  132608. reset(): void;
  132609. /**
  132610. * Start the optimizer. By default it will try to reach a specific framerate
  132611. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  132612. */
  132613. start(): void;
  132614. private _checkCurrentState;
  132615. /**
  132616. * Release all resources
  132617. */
  132618. dispose(): void;
  132619. /**
  132620. * Helper function to create a SceneOptimizer with one single line of code
  132621. * @param scene defines the scene to work on
  132622. * @param options defines the options to use with the SceneOptimizer
  132623. * @param onSuccess defines a callback to call on success
  132624. * @param onFailure defines a callback to call on failure
  132625. * @returns the new SceneOptimizer object
  132626. */
  132627. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  132628. }
  132629. }
  132630. declare module BABYLON {
  132631. /**
  132632. * Class used to serialize a scene into a string
  132633. */
  132634. export class SceneSerializer {
  132635. /**
  132636. * Clear cache used by a previous serialization
  132637. */
  132638. static ClearCache(): void;
  132639. /**
  132640. * Serialize a scene into a JSON compatible object
  132641. * @param scene defines the scene to serialize
  132642. * @returns a JSON compatible object
  132643. */
  132644. static Serialize(scene: Scene): any;
  132645. /**
  132646. * Serialize a mesh into a JSON compatible object
  132647. * @param toSerialize defines the mesh to serialize
  132648. * @param withParents defines if parents must be serialized as well
  132649. * @param withChildren defines if children must be serialized as well
  132650. * @returns a JSON compatible object
  132651. */
  132652. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  132653. }
  132654. }
  132655. declare module BABYLON {
  132656. /**
  132657. * Class used to host texture specific utilities
  132658. */
  132659. export class TextureTools {
  132660. /**
  132661. * Uses the GPU to create a copy texture rescaled at a given size
  132662. * @param texture Texture to copy from
  132663. * @param width defines the desired width
  132664. * @param height defines the desired height
  132665. * @param useBilinearMode defines if bilinear mode has to be used
  132666. * @return the generated texture
  132667. */
  132668. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  132669. }
  132670. }
  132671. declare module BABYLON {
  132672. /**
  132673. * This represents the different options available for the video capture.
  132674. */
  132675. export interface VideoRecorderOptions {
  132676. /** Defines the mime type of the video. */
  132677. mimeType: string;
  132678. /** Defines the FPS the video should be recorded at. */
  132679. fps: number;
  132680. /** Defines the chunk size for the recording data. */
  132681. recordChunckSize: number;
  132682. /** The audio tracks to attach to the recording. */
  132683. audioTracks?: MediaStreamTrack[];
  132684. }
  132685. /**
  132686. * This can help with recording videos from BabylonJS.
  132687. * This is based on the available WebRTC functionalities of the browser.
  132688. *
  132689. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  132690. */
  132691. export class VideoRecorder {
  132692. private static readonly _defaultOptions;
  132693. /**
  132694. * Returns whether or not the VideoRecorder is available in your browser.
  132695. * @param engine Defines the Babylon Engine.
  132696. * @returns true if supported otherwise false.
  132697. */
  132698. static IsSupported(engine: Engine): boolean;
  132699. private readonly _options;
  132700. private _canvas;
  132701. private _mediaRecorder;
  132702. private _recordedChunks;
  132703. private _fileName;
  132704. private _resolve;
  132705. private _reject;
  132706. /**
  132707. * True when a recording is already in progress.
  132708. */
  132709. readonly isRecording: boolean;
  132710. /**
  132711. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  132712. * @param engine Defines the BabylonJS Engine you wish to record.
  132713. * @param options Defines options that can be used to customize the capture.
  132714. */
  132715. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  132716. /**
  132717. * Stops the current recording before the default capture timeout passed in the startRecording function.
  132718. */
  132719. stopRecording(): void;
  132720. /**
  132721. * Starts recording the canvas for a max duration specified in parameters.
  132722. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  132723. * If null no automatic download will start and you can rely on the promise to get the data back.
  132724. * @param maxDuration Defines the maximum recording time in seconds.
  132725. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  132726. * @return A promise callback at the end of the recording with the video data in Blob.
  132727. */
  132728. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  132729. /**
  132730. * Releases internal resources used during the recording.
  132731. */
  132732. dispose(): void;
  132733. private _handleDataAvailable;
  132734. private _handleError;
  132735. private _handleStop;
  132736. }
  132737. }
  132738. declare module BABYLON {
  132739. /**
  132740. * Class containing a set of static utilities functions for screenshots
  132741. */
  132742. export class ScreenshotTools {
  132743. /**
  132744. * Captures a screenshot of the current rendering
  132745. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132746. * @param engine defines the rendering engine
  132747. * @param camera defines the source camera
  132748. * @param size This parameter can be set to a single number or to an object with the
  132749. * following (optional) properties: precision, width, height. If a single number is passed,
  132750. * it will be used for both width and height. If an object is passed, the screenshot size
  132751. * will be derived from the parameters. The precision property is a multiplier allowing
  132752. * rendering at a higher or lower resolution
  132753. * @param successCallback defines the callback receives a single parameter which contains the
  132754. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  132755. * src parameter of an <img> to display it
  132756. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  132757. * Check your browser for supported MIME types
  132758. */
  132759. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  132760. /**
  132761. * Captures a screenshot of the current rendering
  132762. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132763. * @param engine defines the rendering engine
  132764. * @param camera defines the source camera
  132765. * @param size This parameter can be set to a single number or to an object with the
  132766. * following (optional) properties: precision, width, height. If a single number is passed,
  132767. * it will be used for both width and height. If an object is passed, the screenshot size
  132768. * will be derived from the parameters. The precision property is a multiplier allowing
  132769. * rendering at a higher or lower resolution
  132770. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  132771. * Check your browser for supported MIME types
  132772. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  132773. * to the src parameter of an <img> to display it
  132774. */
  132775. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  132776. /**
  132777. * Generates an image screenshot from the specified camera.
  132778. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132779. * @param engine The engine to use for rendering
  132780. * @param camera The camera to use for rendering
  132781. * @param size This parameter can be set to a single number or to an object with the
  132782. * following (optional) properties: precision, width, height. If a single number is passed,
  132783. * it will be used for both width and height. If an object is passed, the screenshot size
  132784. * will be derived from the parameters. The precision property is a multiplier allowing
  132785. * rendering at a higher or lower resolution
  132786. * @param successCallback The callback receives a single parameter which contains the
  132787. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  132788. * src parameter of an <img> to display it
  132789. * @param mimeType The MIME type of the screenshot image (default: image/png).
  132790. * Check your browser for supported MIME types
  132791. * @param samples Texture samples (default: 1)
  132792. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  132793. * @param fileName A name for for the downloaded file.
  132794. */
  132795. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  132796. /**
  132797. * Generates an image screenshot from the specified camera.
  132798. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132799. * @param engine The engine to use for rendering
  132800. * @param camera The camera to use for rendering
  132801. * @param size This parameter can be set to a single number or to an object with the
  132802. * following (optional) properties: precision, width, height. If a single number is passed,
  132803. * it will be used for both width and height. If an object is passed, the screenshot size
  132804. * will be derived from the parameters. The precision property is a multiplier allowing
  132805. * rendering at a higher or lower resolution
  132806. * @param mimeType The MIME type of the screenshot image (default: image/png).
  132807. * Check your browser for supported MIME types
  132808. * @param samples Texture samples (default: 1)
  132809. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  132810. * @param fileName A name for for the downloaded file.
  132811. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  132812. * to the src parameter of an <img> to display it
  132813. */
  132814. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  132815. /**
  132816. * Gets height and width for screenshot size
  132817. * @private
  132818. */
  132819. private static _getScreenshotSize;
  132820. }
  132821. }
  132822. declare module BABYLON {
  132823. /**
  132824. * Interface for a data buffer
  132825. */
  132826. export interface IDataBuffer {
  132827. /**
  132828. * Reads bytes from the data buffer.
  132829. * @param byteOffset The byte offset to read
  132830. * @param byteLength The byte length to read
  132831. * @returns A promise that resolves when the bytes are read
  132832. */
  132833. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  132834. /**
  132835. * The byte length of the buffer.
  132836. */
  132837. readonly byteLength: number;
  132838. }
  132839. /**
  132840. * Utility class for reading from a data buffer
  132841. */
  132842. export class DataReader {
  132843. /**
  132844. * The data buffer associated with this data reader.
  132845. */
  132846. readonly buffer: IDataBuffer;
  132847. /**
  132848. * The current byte offset from the beginning of the data buffer.
  132849. */
  132850. byteOffset: number;
  132851. private _dataView;
  132852. private _dataByteOffset;
  132853. /**
  132854. * Constructor
  132855. * @param buffer The buffer to read
  132856. */
  132857. constructor(buffer: IDataBuffer);
  132858. /**
  132859. * Loads the given byte length.
  132860. * @param byteLength The byte length to load
  132861. * @returns A promise that resolves when the load is complete
  132862. */
  132863. loadAsync(byteLength: number): Promise<void>;
  132864. /**
  132865. * Read a unsigned 32-bit integer from the currently loaded data range.
  132866. * @returns The 32-bit integer read
  132867. */
  132868. readUint32(): number;
  132869. /**
  132870. * Read a byte array from the currently loaded data range.
  132871. * @param byteLength The byte length to read
  132872. * @returns The byte array read
  132873. */
  132874. readUint8Array(byteLength: number): Uint8Array;
  132875. /**
  132876. * Read a string from the currently loaded data range.
  132877. * @param byteLength The byte length to read
  132878. * @returns The string read
  132879. */
  132880. readString(byteLength: number): string;
  132881. /**
  132882. * Skips the given byte length the currently loaded data range.
  132883. * @param byteLength The byte length to skip
  132884. */
  132885. skipBytes(byteLength: number): void;
  132886. }
  132887. }
  132888. declare module BABYLON {
  132889. /**
  132890. * A cursor which tracks a point on a path
  132891. */
  132892. export class PathCursor {
  132893. private path;
  132894. /**
  132895. * Stores path cursor callbacks for when an onchange event is triggered
  132896. */
  132897. private _onchange;
  132898. /**
  132899. * The value of the path cursor
  132900. */
  132901. value: number;
  132902. /**
  132903. * The animation array of the path cursor
  132904. */
  132905. animations: Animation[];
  132906. /**
  132907. * Initializes the path cursor
  132908. * @param path The path to track
  132909. */
  132910. constructor(path: Path2);
  132911. /**
  132912. * Gets the cursor point on the path
  132913. * @returns A point on the path cursor at the cursor location
  132914. */
  132915. getPoint(): Vector3;
  132916. /**
  132917. * Moves the cursor ahead by the step amount
  132918. * @param step The amount to move the cursor forward
  132919. * @returns This path cursor
  132920. */
  132921. moveAhead(step?: number): PathCursor;
  132922. /**
  132923. * Moves the cursor behind by the step amount
  132924. * @param step The amount to move the cursor back
  132925. * @returns This path cursor
  132926. */
  132927. moveBack(step?: number): PathCursor;
  132928. /**
  132929. * Moves the cursor by the step amount
  132930. * If the step amount is greater than one, an exception is thrown
  132931. * @param step The amount to move the cursor
  132932. * @returns This path cursor
  132933. */
  132934. move(step: number): PathCursor;
  132935. /**
  132936. * Ensures that the value is limited between zero and one
  132937. * @returns This path cursor
  132938. */
  132939. private ensureLimits;
  132940. /**
  132941. * Runs onchange callbacks on change (used by the animation engine)
  132942. * @returns This path cursor
  132943. */
  132944. private raiseOnChange;
  132945. /**
  132946. * Executes a function on change
  132947. * @param f A path cursor onchange callback
  132948. * @returns This path cursor
  132949. */
  132950. onchange(f: (cursor: PathCursor) => void): PathCursor;
  132951. }
  132952. }
  132953. declare module BABYLON {
  132954. /** @hidden */
  132955. export var blurPixelShader: {
  132956. name: string;
  132957. shader: string;
  132958. };
  132959. }
  132960. declare module BABYLON {
  132961. /** @hidden */
  132962. export var pointCloudVertexDeclaration: {
  132963. name: string;
  132964. shader: string;
  132965. };
  132966. }
  132967. // Mixins
  132968. interface Window {
  132969. mozIndexedDB: IDBFactory;
  132970. webkitIndexedDB: IDBFactory;
  132971. msIndexedDB: IDBFactory;
  132972. webkitURL: typeof URL;
  132973. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  132974. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  132975. WebGLRenderingContext: WebGLRenderingContext;
  132976. MSGesture: MSGesture;
  132977. CANNON: any;
  132978. AudioContext: AudioContext;
  132979. webkitAudioContext: AudioContext;
  132980. PointerEvent: any;
  132981. Math: Math;
  132982. Uint8Array: Uint8ArrayConstructor;
  132983. Float32Array: Float32ArrayConstructor;
  132984. mozURL: typeof URL;
  132985. msURL: typeof URL;
  132986. VRFrameData: any; // WebVR, from specs 1.1
  132987. DracoDecoderModule: any;
  132988. setImmediate(handler: (...args: any[]) => void): number;
  132989. }
  132990. interface HTMLCanvasElement {
  132991. requestPointerLock(): void;
  132992. msRequestPointerLock?(): void;
  132993. mozRequestPointerLock?(): void;
  132994. webkitRequestPointerLock?(): void;
  132995. /** Track wether a record is in progress */
  132996. isRecording: boolean;
  132997. /** Capture Stream method defined by some browsers */
  132998. captureStream(fps?: number): MediaStream;
  132999. }
  133000. interface CanvasRenderingContext2D {
  133001. msImageSmoothingEnabled: boolean;
  133002. }
  133003. interface MouseEvent {
  133004. mozMovementX: number;
  133005. mozMovementY: number;
  133006. webkitMovementX: number;
  133007. webkitMovementY: number;
  133008. msMovementX: number;
  133009. msMovementY: number;
  133010. }
  133011. interface Navigator {
  133012. mozGetVRDevices: (any: any) => any;
  133013. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  133014. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  133015. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  133016. webkitGetGamepads(): Gamepad[];
  133017. msGetGamepads(): Gamepad[];
  133018. webkitGamepads(): Gamepad[];
  133019. }
  133020. interface HTMLVideoElement {
  133021. mozSrcObject: any;
  133022. }
  133023. interface Math {
  133024. fround(x: number): number;
  133025. imul(a: number, b: number): number;
  133026. }
  133027. interface WebGLRenderingContext {
  133028. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  133029. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  133030. vertexAttribDivisor(index: number, divisor: number): void;
  133031. createVertexArray(): any;
  133032. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  133033. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  133034. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  133035. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  133036. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  133037. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  133038. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  133039. // Queries
  133040. createQuery(): WebGLQuery;
  133041. deleteQuery(query: WebGLQuery): void;
  133042. beginQuery(target: number, query: WebGLQuery): void;
  133043. endQuery(target: number): void;
  133044. getQueryParameter(query: WebGLQuery, pname: number): any;
  133045. getQuery(target: number, pname: number): any;
  133046. MAX_SAMPLES: number;
  133047. RGBA8: number;
  133048. READ_FRAMEBUFFER: number;
  133049. DRAW_FRAMEBUFFER: number;
  133050. UNIFORM_BUFFER: number;
  133051. HALF_FLOAT_OES: number;
  133052. RGBA16F: number;
  133053. RGBA32F: number;
  133054. R32F: number;
  133055. RG32F: number;
  133056. RGB32F: number;
  133057. R16F: number;
  133058. RG16F: number;
  133059. RGB16F: number;
  133060. RED: number;
  133061. RG: number;
  133062. R8: number;
  133063. RG8: number;
  133064. UNSIGNED_INT_24_8: number;
  133065. DEPTH24_STENCIL8: number;
  133066. MIN: number;
  133067. MAX: number;
  133068. /* Multiple Render Targets */
  133069. drawBuffers(buffers: number[]): void;
  133070. readBuffer(src: number): void;
  133071. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  133072. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  133073. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  133074. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  133075. // Occlusion Query
  133076. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  133077. ANY_SAMPLES_PASSED: number;
  133078. QUERY_RESULT_AVAILABLE: number;
  133079. QUERY_RESULT: number;
  133080. }
  133081. interface WebGLProgram {
  133082. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  133083. }
  133084. interface EXT_disjoint_timer_query {
  133085. QUERY_COUNTER_BITS_EXT: number;
  133086. TIME_ELAPSED_EXT: number;
  133087. TIMESTAMP_EXT: number;
  133088. GPU_DISJOINT_EXT: number;
  133089. QUERY_RESULT_EXT: number;
  133090. QUERY_RESULT_AVAILABLE_EXT: number;
  133091. queryCounterEXT(query: WebGLQuery, target: number): void;
  133092. createQueryEXT(): WebGLQuery;
  133093. beginQueryEXT(target: number, query: WebGLQuery): void;
  133094. endQueryEXT(target: number): void;
  133095. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  133096. deleteQueryEXT(query: WebGLQuery): void;
  133097. }
  133098. interface WebGLUniformLocation {
  133099. _currentState: any;
  133100. }
  133101. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  133102. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  133103. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  133104. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  133105. interface WebGLRenderingContext {
  133106. readonly RASTERIZER_DISCARD: number;
  133107. readonly DEPTH_COMPONENT24: number;
  133108. readonly TEXTURE_3D: number;
  133109. readonly TEXTURE_2D_ARRAY: number;
  133110. readonly TEXTURE_COMPARE_FUNC: number;
  133111. readonly TEXTURE_COMPARE_MODE: number;
  133112. readonly COMPARE_REF_TO_TEXTURE: number;
  133113. readonly TEXTURE_WRAP_R: number;
  133114. readonly HALF_FLOAT: number;
  133115. readonly RGB8: number;
  133116. readonly RED_INTEGER: number;
  133117. readonly RG_INTEGER: number;
  133118. readonly RGB_INTEGER: number;
  133119. readonly RGBA_INTEGER: number;
  133120. readonly R8_SNORM: number;
  133121. readonly RG8_SNORM: number;
  133122. readonly RGB8_SNORM: number;
  133123. readonly RGBA8_SNORM: number;
  133124. readonly R8I: number;
  133125. readonly RG8I: number;
  133126. readonly RGB8I: number;
  133127. readonly RGBA8I: number;
  133128. readonly R8UI: number;
  133129. readonly RG8UI: number;
  133130. readonly RGB8UI: number;
  133131. readonly RGBA8UI: number;
  133132. readonly R16I: number;
  133133. readonly RG16I: number;
  133134. readonly RGB16I: number;
  133135. readonly RGBA16I: number;
  133136. readonly R16UI: number;
  133137. readonly RG16UI: number;
  133138. readonly RGB16UI: number;
  133139. readonly RGBA16UI: number;
  133140. readonly R32I: number;
  133141. readonly RG32I: number;
  133142. readonly RGB32I: number;
  133143. readonly RGBA32I: number;
  133144. readonly R32UI: number;
  133145. readonly RG32UI: number;
  133146. readonly RGB32UI: number;
  133147. readonly RGBA32UI: number;
  133148. readonly RGB10_A2UI: number;
  133149. readonly R11F_G11F_B10F: number;
  133150. readonly RGB9_E5: number;
  133151. readonly RGB10_A2: number;
  133152. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  133153. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  133154. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  133155. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  133156. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  133157. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  133158. 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;
  133159. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  133160. readonly TRANSFORM_FEEDBACK: number;
  133161. readonly INTERLEAVED_ATTRIBS: number;
  133162. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  133163. createTransformFeedback(): WebGLTransformFeedback;
  133164. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  133165. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  133166. beginTransformFeedback(primitiveMode: number): void;
  133167. endTransformFeedback(): void;
  133168. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  133169. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  133170. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  133171. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  133172. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  133173. }
  133174. interface ImageBitmap {
  133175. readonly width: number;
  133176. readonly height: number;
  133177. close(): void;
  133178. }
  133179. interface WebGLQuery extends WebGLObject {
  133180. }
  133181. declare var WebGLQuery: {
  133182. prototype: WebGLQuery;
  133183. new(): WebGLQuery;
  133184. };
  133185. interface WebGLSampler extends WebGLObject {
  133186. }
  133187. declare var WebGLSampler: {
  133188. prototype: WebGLSampler;
  133189. new(): WebGLSampler;
  133190. };
  133191. interface WebGLSync extends WebGLObject {
  133192. }
  133193. declare var WebGLSync: {
  133194. prototype: WebGLSync;
  133195. new(): WebGLSync;
  133196. };
  133197. interface WebGLTransformFeedback extends WebGLObject {
  133198. }
  133199. declare var WebGLTransformFeedback: {
  133200. prototype: WebGLTransformFeedback;
  133201. new(): WebGLTransformFeedback;
  133202. };
  133203. interface WebGLVertexArrayObject extends WebGLObject {
  133204. }
  133205. declare var WebGLVertexArrayObject: {
  133206. prototype: WebGLVertexArrayObject;
  133207. new(): WebGLVertexArrayObject;
  133208. };
  133209. // Type definitions for WebVR API
  133210. // Project: https://w3c.github.io/webvr/
  133211. // Definitions by: six a <https://github.com/lostfictions>
  133212. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  133213. interface VRDisplay extends EventTarget {
  133214. /**
  133215. * Dictionary of capabilities describing the VRDisplay.
  133216. */
  133217. readonly capabilities: VRDisplayCapabilities;
  133218. /**
  133219. * z-depth defining the far plane of the eye view frustum
  133220. * enables mapping of values in the render target depth
  133221. * attachment to scene coordinates. Initially set to 10000.0.
  133222. */
  133223. depthFar: number;
  133224. /**
  133225. * z-depth defining the near plane of the eye view frustum
  133226. * enables mapping of values in the render target depth
  133227. * attachment to scene coordinates. Initially set to 0.01.
  133228. */
  133229. depthNear: number;
  133230. /**
  133231. * An identifier for this distinct VRDisplay. Used as an
  133232. * association point in the Gamepad API.
  133233. */
  133234. readonly displayId: number;
  133235. /**
  133236. * A display name, a user-readable name identifying it.
  133237. */
  133238. readonly displayName: string;
  133239. readonly isConnected: boolean;
  133240. readonly isPresenting: boolean;
  133241. /**
  133242. * If this VRDisplay supports room-scale experiences, the optional
  133243. * stage attribute contains details on the room-scale parameters.
  133244. */
  133245. readonly stageParameters: VRStageParameters | null;
  133246. /**
  133247. * Passing the value returned by `requestAnimationFrame` to
  133248. * `cancelAnimationFrame` will unregister the callback.
  133249. * @param handle Define the hanle of the request to cancel
  133250. */
  133251. cancelAnimationFrame(handle: number): void;
  133252. /**
  133253. * Stops presenting to the VRDisplay.
  133254. * @returns a promise to know when it stopped
  133255. */
  133256. exitPresent(): Promise<void>;
  133257. /**
  133258. * Return the current VREyeParameters for the given eye.
  133259. * @param whichEye Define the eye we want the parameter for
  133260. * @returns the eye parameters
  133261. */
  133262. getEyeParameters(whichEye: string): VREyeParameters;
  133263. /**
  133264. * Populates the passed VRFrameData with the information required to render
  133265. * the current frame.
  133266. * @param frameData Define the data structure to populate
  133267. * @returns true if ok otherwise false
  133268. */
  133269. getFrameData(frameData: VRFrameData): boolean;
  133270. /**
  133271. * Get the layers currently being presented.
  133272. * @returns the list of VR layers
  133273. */
  133274. getLayers(): VRLayer[];
  133275. /**
  133276. * Return a VRPose containing the future predicted pose of the VRDisplay
  133277. * when the current frame will be presented. The value returned will not
  133278. * change until JavaScript has returned control to the browser.
  133279. *
  133280. * The VRPose will contain the position, orientation, velocity,
  133281. * and acceleration of each of these properties.
  133282. * @returns the pose object
  133283. */
  133284. getPose(): VRPose;
  133285. /**
  133286. * Return the current instantaneous pose of the VRDisplay, with no
  133287. * prediction applied.
  133288. * @returns the current instantaneous pose
  133289. */
  133290. getImmediatePose(): VRPose;
  133291. /**
  133292. * The callback passed to `requestAnimationFrame` will be called
  133293. * any time a new frame should be rendered. When the VRDisplay is
  133294. * presenting the callback will be called at the native refresh
  133295. * rate of the HMD. When not presenting this function acts
  133296. * identically to how window.requestAnimationFrame acts. Content should
  133297. * make no assumptions of frame rate or vsync behavior as the HMD runs
  133298. * asynchronously from other displays and at differing refresh rates.
  133299. * @param callback Define the eaction to run next frame
  133300. * @returns the request handle it
  133301. */
  133302. requestAnimationFrame(callback: FrameRequestCallback): number;
  133303. /**
  133304. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  133305. * Repeat calls while already presenting will update the VRLayers being displayed.
  133306. * @param layers Define the list of layer to present
  133307. * @returns a promise to know when the request has been fulfilled
  133308. */
  133309. requestPresent(layers: VRLayer[]): Promise<void>;
  133310. /**
  133311. * Reset the pose for this display, treating its current position and
  133312. * orientation as the "origin/zero" values. VRPose.position,
  133313. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  133314. * updated when calling resetPose(). This should be called in only
  133315. * sitting-space experiences.
  133316. */
  133317. resetPose(): void;
  133318. /**
  133319. * The VRLayer provided to the VRDisplay will be captured and presented
  133320. * in the HMD. Calling this function has the same effect on the source
  133321. * canvas as any other operation that uses its source image, and canvases
  133322. * created without preserveDrawingBuffer set to true will be cleared.
  133323. * @param pose Define the pose to submit
  133324. */
  133325. submitFrame(pose?: VRPose): void;
  133326. }
  133327. declare var VRDisplay: {
  133328. prototype: VRDisplay;
  133329. new(): VRDisplay;
  133330. };
  133331. interface VRLayer {
  133332. leftBounds?: number[] | Float32Array | null;
  133333. rightBounds?: number[] | Float32Array | null;
  133334. source?: HTMLCanvasElement | null;
  133335. }
  133336. interface VRDisplayCapabilities {
  133337. readonly canPresent: boolean;
  133338. readonly hasExternalDisplay: boolean;
  133339. readonly hasOrientation: boolean;
  133340. readonly hasPosition: boolean;
  133341. readonly maxLayers: number;
  133342. }
  133343. interface VREyeParameters {
  133344. /** @deprecated */
  133345. readonly fieldOfView: VRFieldOfView;
  133346. readonly offset: Float32Array;
  133347. readonly renderHeight: number;
  133348. readonly renderWidth: number;
  133349. }
  133350. interface VRFieldOfView {
  133351. readonly downDegrees: number;
  133352. readonly leftDegrees: number;
  133353. readonly rightDegrees: number;
  133354. readonly upDegrees: number;
  133355. }
  133356. interface VRFrameData {
  133357. readonly leftProjectionMatrix: Float32Array;
  133358. readonly leftViewMatrix: Float32Array;
  133359. readonly pose: VRPose;
  133360. readonly rightProjectionMatrix: Float32Array;
  133361. readonly rightViewMatrix: Float32Array;
  133362. readonly timestamp: number;
  133363. }
  133364. interface VRPose {
  133365. readonly angularAcceleration: Float32Array | null;
  133366. readonly angularVelocity: Float32Array | null;
  133367. readonly linearAcceleration: Float32Array | null;
  133368. readonly linearVelocity: Float32Array | null;
  133369. readonly orientation: Float32Array | null;
  133370. readonly position: Float32Array | null;
  133371. readonly timestamp: number;
  133372. }
  133373. interface VRStageParameters {
  133374. sittingToStandingTransform?: Float32Array;
  133375. sizeX?: number;
  133376. sizeY?: number;
  133377. }
  133378. interface Navigator {
  133379. getVRDisplays(): Promise<VRDisplay[]>;
  133380. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  133381. }
  133382. interface Window {
  133383. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  133384. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  133385. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  133386. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  133387. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  133388. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  133389. }
  133390. interface Gamepad {
  133391. readonly displayId: number;
  133392. }
  133393. type XRSessionMode =
  133394. | "inline"
  133395. | "immersive-vr"
  133396. | "immersive-ar";
  133397. type XRReferenceSpaceType =
  133398. | "viewer"
  133399. | "local"
  133400. | "local-floor"
  133401. | "bounded-floor"
  133402. | "unbounded";
  133403. type XREnvironmentBlendMode =
  133404. | "opaque"
  133405. | "additive"
  133406. | "alpha-blend";
  133407. type XRVisibilityState =
  133408. | "visible"
  133409. | "visible-blurred"
  133410. | "hidden";
  133411. type XRHandedness =
  133412. | "none"
  133413. | "left"
  133414. | "right";
  133415. type XRTargetRayMode =
  133416. | "gaze"
  133417. | "tracked-pointer"
  133418. | "screen";
  133419. type XREye =
  133420. | "none"
  133421. | "left"
  133422. | "right";
  133423. interface XRSpace extends EventTarget {
  133424. }
  133425. interface XRRenderState {
  133426. depthNear?: number;
  133427. depthFar?: number;
  133428. inlineVerticalFieldOfView?: number;
  133429. baseLayer?: XRWebGLLayer;
  133430. }
  133431. interface XRInputSource {
  133432. handedness: XRHandedness;
  133433. targetRayMode: XRTargetRayMode;
  133434. targetRaySpace: XRSpace;
  133435. gripSpace: XRSpace | undefined;
  133436. gamepad: Gamepad | undefined;
  133437. profiles: Array<string>;
  133438. }
  133439. interface XRSession {
  133440. addEventListener: Function;
  133441. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  133442. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  133443. requestAnimationFrame: Function;
  133444. end(): Promise<void>;
  133445. renderState: XRRenderState;
  133446. inputSources: Array<XRInputSource>;
  133447. }
  133448. interface XRReferenceSpace extends XRSpace {
  133449. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  133450. onreset: any;
  133451. }
  133452. interface XRFrame {
  133453. session: XRSession;
  133454. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  133455. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  133456. }
  133457. interface XRViewerPose extends XRPose {
  133458. views: Array<XRView>;
  133459. }
  133460. interface XRPose {
  133461. transform: XRRigidTransform;
  133462. emulatedPosition: boolean;
  133463. }
  133464. interface XRWebGLLayerOptions {
  133465. antialias ?: boolean;
  133466. depth ?: boolean;
  133467. stencil ?: boolean;
  133468. alpha ?: boolean;
  133469. multiview ?: boolean;
  133470. framebufferScaleFactor ?: number;
  133471. }
  133472. declare var XRWebGLLayer: {
  133473. prototype: XRWebGLLayer;
  133474. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  133475. };
  133476. interface XRWebGLLayer {
  133477. framebuffer: WebGLFramebuffer;
  133478. framebufferWidth: number;
  133479. framebufferHeight: number;
  133480. getViewport: Function;
  133481. }
  133482. interface XRRigidTransform {
  133483. position: DOMPointReadOnly;
  133484. orientation: DOMPointReadOnly;
  133485. matrix: Float32Array;
  133486. inverse: XRRigidTransform;
  133487. }
  133488. interface XRView {
  133489. eye: XREye;
  133490. projectionMatrix: Float32Array;
  133491. transform: XRRigidTransform;
  133492. }
  133493. interface XRInputSourceChangeEvent {
  133494. session: XRSession;
  133495. removed: Array<XRInputSource>;
  133496. added: Array<XRInputSource>;
  133497. }